Repository navigation
fix(py/plugins/anthropic): send back empty signed thinking blocks - #147
Merged
huangjeff5 merged 4 commits intoNov 30, 2026
Merged
huangjeff5 merged 4 commits into
huangjeff5 merged 4 commits into
Conversation
Claude can return a thinking block with an empty `thinking` string and a valid signature, often on the turn right after a tool call. The request converter checked `if reasoning:`, so the block was dropped. With thinking enabled, an assistant turn that uses a tool has to start with its thinking block, so the next request failed. Check `is not None` instead. Unsigned reasoning is still dropped. Same bug as #6798 on the JS side.
…t standard endpoint in test
A model on Bedrock can sign a thinking block with empty text, and a tool-use turn has to start with that block. The request encoder only emitted reasoning when both text and signature were set, and the stream accumulator only kept a block when it had text or redacted content, so the block was lost on the next request. Encode and keep any block that has a signature. Unsigned empty reasoning is still dropped. Same fix as the earlier commit in this PR.
hkarmoush
force-pushed
the
fix/anthropic-bedrock-empty-signed-thinking
branch
from
November 29, 2026 22:57
9f33c61 to
9aad71f
Compare
huangjeff5
approved these changes
Nov 30, 2026
huangjeff5
left a comment
Collaborator
There was a problem hiding this comment.
LGTM! Pushed a small test tweak (c9d2406) so test_reasoning_without_text_or_signature_is_dropped sends an empty reasoning_delta to cover the drop path directly.
huangjeff5
enabled auto-merge (squash)
November 30, 2026 19:52
Merged
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.
Moved over from genkit-ai/genkit#6839 now that the Python SDK lives here. It was approved there, including the Bedrock follow-up.
Claude sometimes returns a thinking block with an empty
thinkingstring and a valid signature, mostly on the turn right after a tool call._to_anthropic_blockcheckedif reasoning:, so that block was quietly dropped when the history was sent back. With thinking enabled, an assistant turn that containstool_usehas to start with its thinking block, so the next request in the tool loop gets rejected.The check is now
reasoning is not None. Unsigned reasoning is still dropped like before, so cross-provider history behaves the same. The Bedrock converter and stream accumulator had the same drop, so they now keep any signed reasoning block too.Tests cover signed empty reasoning being kept and unsigned empty reasoning still being dropped, on both the Anthropic and Bedrock sides, plus an
ai.generateround trip checking the thinking block stays first.uv run pytest packages/genkit-anthropic/tests packages/genkit-amazon-bedrock/testspasses (975 passed, live tests skipped).