fix: read thinking_delta content from the thinking field - #2578
Merged
gavrissh merged 5 commits intoSep 15, 2026
Merged
Conversation
text_delta and thinking_delta are separate variants of the SDK's
RawContentBlockDeltaUnion and carry their payload in different fields:
.Text is populated only for text_delta, .Thinking only for
thinking_delta. The parser read .Text for both, so every extended
thinking token reached OpenAI clients as an empty string.
The union documents this itself:
// This field is from variant [TextDelta].
Text string `json:"text"`
// This field is from variant [ThinkingDelta].
Thinking string `json:"thinking"`
Affects the Anthropic-to-OpenAI streaming path for any backend using
this parser (GCPAnthropic, AWSAnthropic) whenever the model streams
extended thinking.
TestAnthropicStreamParser_ThinkingDelta drives a stream with one
thinking block and one text block. Before the change it collects only
the text block's content; after it collects both thinking deltas in
order.
Signed-off-by: khaliddaoud <mohamed.khalid@gmail.com>
gavrissh
approved these changes
Sep 8, 2026
gavrissh
left a comment
Contributor
There was a problem hiding this comment.
Thanks for helping out with this change!
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
✅ Deploy Preview for theagentrouter canceled.
|
Contributor
|
@khalidDaoud There are some Test failures. Could you check? |
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.
Description
text_deltaandthinking_deltaare separate variants of the SDK'sRawContentBlockDeltaUnionand carry their payload in different fields. TheAnthropic stream parser read
.Textfor both, so every extended thinking tokenreached OpenAI clients as an empty string.
The union documents the split itself:
thinking_deltanow reads.Thinking. Everything else about the handling isunchanged — thinking is still folded into
delta.contentalongside text.Impact: the Anthropic-to-OpenAI streaming path, for any backend using this
parser (
GCPAnthropic,AWSAnthropic), whenever the model streams extendedthinking. The response is well-formed and returns 200; the reasoning content is
just missing, which makes it easy to miss in testing.
Related Issues/PRs (if applicable)
None that I could find — happy to open an issue first if you would prefer that.
Special notes for reviewers (if applicable)
TestAnthropicStreamParser_ThinkingDeltadrives a stream with one thinkingblock (two deltas plus a
signature_delta) followed by one text block, andcollects the non-empty
delta.contentvalues in order. Before the change itcollects only the text block's content:
make precommitis clean andgo test ./internal/translator/... -count=1passes.
make testhas four pre-existing failures ininternal/controller(
TestBackendSecurityPolicyController_{ReconcileOIDC_Fail,RotateCredential, RotateExpiredCredential,ExecutionRotation}) which reproduce unmodified onmainand are unrelated to this change.Per the generative AI policy: this change was developed with AI assistance
(Claude). I have reviewed it, understand it, and can revise any part of it on
request.