fix: skip reasoning parts from different models to prevent Anthropic signature errors#17
Open
lgarceau768 wants to merge 3 commits intoflexfrom
Open
fix: skip reasoning parts from different models to prevent Anthropic signature errors#17lgarceau768 wants to merge 3 commits intoflexfrom
lgarceau768 wants to merge 3 commits intoflexfrom
Conversation
…signature errors When switching models mid-conversation, Anthropic reasoning (thinking) blocks carry a cryptographic signature bound to the model that generated them. Replaying those parts to a different model causes a 400 error: 'thinking.signature: Field required'. - message-v2.ts: skip reasoning parts entirely when the historical message came from a different model (differentModel flag already computed upstream) - transform.ts: defence-in-depth guard that strips unsigned reasoning parts before they reach the Anthropic/Bedrock SDK, preventing the 400 even if message-v2 reconstruction is bypassed
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
…text parts DeepSeek R1 (deepseek-reasoner) does not honour the tools parameter on the standard api.deepseek.com endpoint despite models.dev reporting tool_call: true. When tools are sent, R1 ignores them and writes the invocation as markdown text, causing tool calls to appear as plain text instead of being executed. - llm.ts: disable canTool for deepseek-reasoner so tools are never sent to it, avoiding the markdown-text fallback entirely - processor.ts: strip <think>...</think> blocks from text parts for reasoning models that emit chain-of-thought inline rather than as dedicated reasoning events, preventing raw thinking tokens from appearing in the UI
…field
The previous guard checked providerID === 'deepseek' and api.id containing
'reasoner', which only matched the direct DeepSeek API. Bedrock-hosted R1 has
providerID 'amazon-bedrock' and api.id 'deepseek.r1-v1:0' — neither condition
fired, so tools were still being sent to Bedrock R1.
Broaden the guard to use the provider-agnostic family field ('deepseek-thinking')
which is set for all DeepSeek reasoning variants regardless of hosting provider.
Fall back to api.id substring matching ('deepseek.r1') as an additional safety net
for cases where family may be absent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
thinking.signature: Field requiredChanges
differentModelflag already computed upstream)Testing
Reproduce by:
claude-sonnet-4-5with thinking enabled)