Skip to content

fix(anthropic): preserve empty thinking field in signature_delta streaming#38765

Open
Yuchen Fan (Functionhx) wants to merge 3 commits into
langchain-ai:masterfrom
Functionhx:fix/anthropic-thinking-field
Open

fix(anthropic): preserve empty thinking field in signature_delta streaming#38765
Yuchen Fan (Functionhx) wants to merge 3 commits into
langchain-ai:masterfrom
Functionhx:fix/anthropic-thinking-field

Conversation

@Functionhx

Copy link
Copy Markdown

Fixes #38639

Streamed signature_delta chunks from empty adaptive-thinking blocks were missing the required thinking key, causing 400 errors on replay. Added setdefault.

@github-actions github-actions Bot added anthropic `langchain-anthropic` package issues & PRs fix For PRs that implement a fix integration PR made that is related to a provider partner package integration size: S 50-199 LOC labels Jul 10, 2026
Empty adaptive-thinking blocks with only a signature_delta were
missing the thinking key in the reconstructed chunk. Replay to the
API failed with 400 thinking.thinking: Field required.

Added setdefault("thinking", "") so the field is always present.

Signed-off-by: Yuchen Fan <functionhx@gmail.com>
@Functionhx
Yuchen Fan (Functionhx) force-pushed the fix/anthropic-thinking-field branch from 9a27ab1 to 1ca5062 Compare July 10, 2026 02:25
Yuchen Fan (Functionhx) and others added 2 commits July 10, 2026 10:26
@Seo-yul

Copy link
Copy Markdown

ccurme (@ccurme) I previously raised an issue about this PR. This solution looks reasonable to me. After reviewing the overall implementation, do you think there might be a more fundamental way to solve this? I'd appreciate your thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

anthropic `langchain-anthropic` package issues & PRs external fix For PRs that implement a fix integration PR made that is related to a provider partner package integration new-contributor size: S 50-199 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChatAnthropic streaming drops thinking field from empty thinking blocks (signature_delta-only), replay fails with 400 thinking.thinking: Field required

2 participants