Skip to content

Conversation

@tlongwell-block
Copy link
Collaborator

No description provided.

)
}

fn trim_assistant_text_whitespace(messages: Vec<Message>) -> (Vec<Message>, Vec<String>) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I might just add a fn trim which trims both leading and trailing whitespace of all messages. Would be simpler, and in theory doesn't cause any issues. Only makes messages smaller.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, looked into this a bit and tried out some edge cases. We could get into trouble with messages that contain things like ascii art, tables, charts, or other space-dependent content in user message. So, I'm just going to leave this as trimming only the trailing whitespace on assistant messages

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could limit the trimming to only the very latest assistant message since that appears to be the only one Anthropic cares about per that message. Any thoughts there @alexhancock ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this stops things from crashing so that's good and agree, leading whitespace you can't trim in general. do we know where the issue comes from though? it would be better if we could fix it at the source.

Copy link
Collaborator Author

@tlongwell-block tlongwell-block Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the error is to be believed at face value, it's an assistant message causing the issue.

So that rules out tool responses, the moim, and special/control input from the user/client. So my thought is that the LLM itself is generating a trailing whitespace for some reason? They do get weird sometimes once context gets long enough.

tool call seems likely and fits with what I was seeing

@tlongwell-block tlongwell-block marked this pull request as ready for review December 4, 2025 16:00
@tlongwell-block tlongwell-block merged commit 704546d into main Dec 4, 2025
16 checks passed
@tlongwell-block tlongwell-block deleted the convo_cleaning branch December 4, 2025 16:41
tlongwell-block added a commit that referenced this pull request Dec 4, 2025
* origin/main:
  Update Anthropic and Google Gemini models to latest API versions (#5980)
  docs: chat recall tutorial (#5975)
  fix: `final assistant content cannot end with trailing whitespace` error from Anthropic (#5967)
  5527 multiple file popups (#5905)
  Groq configure fix  (#5833)
  added sidebar contextual information for firefox (#5433)
  docs: council of mine MCP (#5979)
  docs: nano banana extension (#5977)
  fix: remove prompt change, read model from config (#5976)
  Enable recipe deeplink parameters for pre-population (#5757)
  chore: upgrade npm packages (#5951)
  feat: ActionRequired (#5897)
  feat(acp): support loading sessions in acp (#5942)
  docs: add videos to multi-model page (#5938)
  docs: promote planning guide (#5934)
michaelneale added a commit that referenced this pull request Dec 5, 2025
* main:
  fix params not being substituted in activities (#5992)
  blog: MCP Sampling (#5987)
  Update Anthropic and Google Gemini models to latest API versions (#5980)
  docs: chat recall tutorial (#5975)
  fix: `final assistant content cannot end with trailing whitespace` error from Anthropic (#5967)
  5527 multiple file popups (#5905)
  Groq configure fix  (#5833)
  added sidebar contextual information for firefox (#5433)
  docs: council of mine MCP (#5979)
  docs: nano banana extension (#5977)
  fix: remove prompt change, read model from config (#5976)
  Enable recipe deeplink parameters for pre-population (#5757)
katzdave added a commit that referenced this pull request Dec 5, 2025
…nses-streaming

* 'main' of github.com:block/goose:
  blog: MCP Sampling (#5987)
  Update Anthropic and Google Gemini models to latest API versions (#5980)
  docs: chat recall tutorial (#5975)
  fix: `final assistant content cannot end with trailing whitespace` error from Anthropic (#5967)
  5527 multiple file popups (#5905)
  Groq configure fix  (#5833)
  added sidebar contextual information for firefox (#5433)
  docs: council of mine MCP (#5979)
  docs: nano banana extension (#5977)
  fix: remove prompt change, read model from config (#5976)
  Enable recipe deeplink parameters for pre-population (#5757)
  chore: upgrade npm packages (#5951)
  feat: ActionRequired (#5897)
  feat(acp): support loading sessions in acp (#5942)
  docs: add videos to multi-model page (#5938)
zanesq added a commit that referenced this pull request Dec 8, 2025
* 'main' of github.com:block/goose: (21 commits)
  Hide recipe icon in empty chat (#6022)
  docs: provider and model config (#6008)
  Show modal selector after configuring a provider (#6005)
  docs: additional mcp sampling resources (#6020)
  Flutter PR Code Review (#6011)
  feat(mcp): elicitation support (#5965)
  Onboarding detect provider from api key (#5955)
  Fix PATH on Windows for extensions (#6000)
  recipe(datahub): Add a recipe for searching & understanding data in DataHub (#5859)
  fix params not being substituted in activities (#5992)
  blog: MCP Sampling (#5987)
  Update Anthropic and Google Gemini models to latest API versions (#5980)
  docs: chat recall tutorial (#5975)
  fix: `final assistant content cannot end with trailing whitespace` error from Anthropic (#5967)
  5527 multiple file popups (#5905)
  Groq configure fix  (#5833)
  added sidebar contextual information for firefox (#5433)
  docs: council of mine MCP (#5979)
  docs: nano banana extension (#5977)
  fix: remove prompt change, read model from config (#5976)
  ...

# Conflicts:
#	ui/desktop/src/api/sdk.gen.ts
#	ui/desktop/src/components/bottom_menu/DirSwitcher.tsx
katzdave added a commit that referenced this pull request Dec 10, 2025
* 'main' of github.com:block/goose: (159 commits)
  Cleanup: Remove Recipe Key Flow (#6015)
  chore(deps): bump mdast-util-to-hast from 13.2.0 to 13.2.1 in /documentation (#5963)
  remove problematic corrupted woff font (#6006)
  Added search bar / filtering for recipes (#6019)
  Hide recipe icon in empty chat (#6022)
  docs: provider and model config (#6008)
  Show modal selector after configuring a provider (#6005)
  docs: additional mcp sampling resources (#6020)
  Flutter PR Code Review (#6011)
  feat(mcp): elicitation support (#5965)
  Onboarding detect provider from api key (#5955)
  Fix PATH on Windows for extensions (#6000)
  recipe(datahub): Add a recipe for searching & understanding data in DataHub (#5859)
  fix params not being substituted in activities (#5992)
  blog: MCP Sampling (#5987)
  Update Anthropic and Google Gemini models to latest API versions (#5980)
  docs: chat recall tutorial (#5975)
  fix: `final assistant content cannot end with trailing whitespace` error from Anthropic (#5967)
  5527 multiple file popups (#5905)
  Groq configure fix  (#5833)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants