-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: final assistant content cannot end with trailing whitespace error from Anthropic
#5967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ror from Anthropic API
| ) | ||
| } | ||
|
|
||
| fn trim_assistant_text_whitespace(messages: Vec<Message>) -> (Vec<Message>, Vec<String>) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
* 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)
* 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)
…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)
* '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
* '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) ...
No description provided.