fix(agents): keep streamed thinking ahead of text and tool calls - #11837
Open
filipkujawa wants to merge 1 commit into
Open
fix(agents): keep streamed thinking ahead of text and tool calls#11837filipkujawa wants to merge 1 commit into
filipkujawa wants to merge 1 commit into
Conversation
Both loops moved thinking that streamed before the text onto the tool-call message, which turned [thinking, text, tool_use] into [text, thinking, tool_use] on replay. Anthropic binds each thinking signature to the blocks before it in the same message, so Claude Fable 5.1 dropped the block on the next request of every tool round. Thinking now stays where the model produced it. The unrolled agent loop only drops a copy of reasoning the provider repeats on the tool-call chunk. The legacy loop copies the turn's thinking onto split tool-call messages after the first one, which DeepSeek and Kimi still require, and fix_conversation removes the signed copies before an Anthropic request. Wire-verified on Claude Fable 5.1 with block binding: both loops replay [thinking, text, tool_use] with input_transformations [].
This was referenced Sep 4, 2026
filipkujawa
changed the base branch from
main
to
fix/anthropic-preserved-thinking
September 4, 2026 20:18
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.
Fixed part of #11800
Summary
Both agent loops moved thinking that streamed before the text onto the tool-call message, so a turn the model produced as
[thinking, text, tool_use]was persisted and replayed as[text, thinking, tool_use]. Anthropic binds each thinking signature to the blocks before it in the same message, so on Claude Fable 5.1 this alone drops the block on the next request of every tool round. Users lose the model's reasoning mid-task without any error.Thinking now stays where the model produced it.
fix_conversationalready removes the signed copies before an Anthropic request.Net deletion. The wire payload for OpenAI-compatible, Google, and Responses providers is unchanged.
Testing
Existing DeepSeek, Kimi, and multi-tool reasoning tests pass unchanged. The Anthropic test now asserts signed thinking appears once and leads the tool-call message; the unrolled-loop pipeline test pins the block order. Wire-verified on Fable 5.1 with block binding: both loops replay
[thinking, text, tool_use]withinput_transformations: [].Stack