fix(langgraph): keep the tool call that starts on the chunk ending streamed text - #2607
Open
itsklimov wants to merge 1 commit into
Open
fix(langgraph): keep the tool call that starts on the chunk ending streamed text#2607itsklimov wants to merge 1 commit into
itsklimov wants to merge 1 commit into
Conversation
…reamed text When a model streams text and then a tool call inside the same assistant message (Anthropic emits the tool_use block right after the text block), the OnChatModelStream handler ended the text message and returned. The tool call's start and every argument chunk were dropped: it never reached the client unless a later on_tool_end re-emitted it, which does not happen for tool calls handled outside a ToolNode. Fall through to the tool-call start after ending the text, matching the Python adapter.
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.
Fixes #2606
Problem
When a model streams text and then a tool call inside the same assistant message (Anthropic emits the
tool_useblock right after thetextblock), theOnChatModelStreamhandler ended the text message and returned. The tool call's start and every argument chunk were dropped. AToolNodetool was re-emitted whole onon_tool_end; a tool call handled outside aToolNode(frontend tools, the injected A2UI render tool) never reached the client.Fix
After
TEXT_MESSAGE_END, fall through to the tool-call start when the chunk carries a named tool call. Same behaviour as the Python adapter. Oneconstbecameletfor that.Adds
text-then-tool-call.test.tswith the Anthropic chunk sequence; it fails onmainand passes with the fix. The rest of the package suite passes.Changes written by Claude Fable 5.1 in Claude Code, reviewed by the submitter.