Skip to content

Fix Anthropic error 400: The final block in an assistant message cannot be thinking#3073

Open
Alexx999 wants to merge 5 commits intotailcallhq:mainfrom
Alexx999:pr-anthropic-trailing-thinking
Open

Fix Anthropic error 400: The final block in an assistant message cannot be thinking#3073
Alexx999 wants to merge 5 commits intotailcallhq:mainfrom
Alexx999:pr-anthropic-trailing-thinking

Conversation

@Alexx999
Copy link
Copy Markdown
Contributor

@Alexx999 Alexx999 commented Apr 18, 2026

Reasoning-only turns have to be filtered out for Anthropic models, otherwise they cause error 400

Fixes #3071

@github-actions github-actions bot added the type: fix Iterations on existing features or infrastructure. label Apr 18, 2026
Comment thread crates/forge_app/src/dto/anthropic/request.rs Outdated
@Alexx999
Copy link
Copy Markdown
Contributor Author

Alexx999 commented Apr 19, 2026

One remaining open question is whether DropReasoningOnlyMessages should be applied to Anthropic models (I've experienced error 400 from Anthropic APIs - it's hard error there) or to all?
In general, Thinking/Reasoning only message seems broken:
you'd expect
...Thinking...Some response
or
...Thinking...Some tool call

If there's thinking but NO tool call and no response it's quite likely a broken message anyway no matter the provider/model
Unless I'm missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Anthropic rejects request when last assistant message has a trailing thinking block

2 participants