fix: include reasoning block with empty text and non-empty signature#2150
Open
gaurav71531 wants to merge 2 commits intostrands-agents:mainfrom
Open
fix: include reasoning block with empty text and non-empty signature#2150gaurav71531 wants to merge 2 commits intostrands-agents:mainfrom
gaurav71531 wants to merge 2 commits intostrands-agents:mainfrom
Conversation
Contributor
|
/strands |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
poshinchen
requested changes
Apr 20, 2026
Contributor
poshinchen
left a comment
There was a problem hiding this comment.
Could you add / update the unit tests so we know what the expected behaviors are?
…on-empty signature
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.
Motivation
Some models like Opus 4.7 emit reasoning content blocks that carry only a
signaturewith no accompanyingreasoningText. The prior condition inhandle_content_block_stopchecked onlyreasoning_text, which evaluated to falsy for an empty string, causing the entire reasoning content block (including the signature) to be silently dropped from the assembled message content.Public API Changes
No public API changes. This is an internal streaming assembly fix.
Change
The condition in
handle_content_block_stopis broadened from:to:
This ensures that reasoning blocks carrying only a signature are preserved in the output content, matching the behavior models like Opus 4.7 expect.
Testing
Added two tests covering the signature-only reasoning scenario:
test_handle_content_block_stopfor emptyreasoningTextwith asignaturepresenttest_process_stream_with_signature_onlythat simulates the Opus 4.7 streaming pattern (signature-only reasoning block followed by a text response)