Skip to content

fix(langgraph): keep the tool call that starts on the chunk ending streamed text - #2607

Open
itsklimov wants to merge 1 commit into
ag-ui-protocol:mainfrom
itsklimov:fix/langgraph-text-then-tool-call
Open

fix(langgraph): keep the tool call that starts on the chunk ending streamed text#2607
itsklimov wants to merge 1 commit into
ag-ui-protocol:mainfrom
itsklimov:fix/langgraph-text-then-tool-call

Conversation

@itsklimov

Copy link
Copy Markdown

Fixes #2606

Problem

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. A ToolNode tool was re-emitted whole on on_tool_end; a tool call handled outside a ToolNode (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. One const became let for that.

Adds text-then-tool-call.test.ts with the Anthropic chunk sequence; it fails on main and 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.

…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.
@itsklimov
itsklimov requested a review from a team as a code owner September 2, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LangGraph TS adapter drops a tool call that starts on the chunk ending streamed text

1 participant