fix(adapters/langgraph): stamp tool_call_id onto client_tool_request interrupts#11
Open
spichen wants to merge 1 commit into
Open
fix(adapters/langgraph): stamp tool_call_id onto client_tool_request interrupts#11spichen wants to merge 1 commit into
spichen wants to merge 1 commit into
Conversation
…interrupts
A ClientTool hands control back to the caller by raising
interrupt({"type": "client_tool_request", ...}), but the payload omitted the
originating tool_call_id. Callers resuming a run correlate the tool result they
return to the parked interrupt by tool_call_id, so without it the resume could
not match and the agent went silent after the user answered (e.g.
ask_user_question).
Wire a ClientToolCallIdMiddleware into create_agent for agents that declare a
ClientTool; running in the tool-call path where the id is available, it stamps
the tool_call_id onto the client_tool_request interrupt as it propagates so a
resuming caller can correlate its tool result.
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.
Problem
A
ClientToolhands control back to the caller by raisinginterrupt({"type": "client_tool_request", ...}), but the interrupt payload omitted the originatingtool_call_id. A caller resuming the run correlates the tool result it returns to the parked interrupt bytool_call_id, so without it the resume never matched — failing withNo pending client_tool_request interrupt found for tool_call_id(...)— and the agent went silent after the user answered (e.g.ask_user_question).Approach
The earlier payload-injection approach (#7) was dropped in favour of a middleware. This adds
ClientToolCallIdMiddlewarein the langgraph adapter: inwrap_tool_call/awrap_tool_callit catches theGraphInterruptand stampstool_call_id(available onrequest.tool_call) onto theclient_tool_requestinterrupt value as it propagates. It is auto-wired intocreate_agentonly for agents that declare aClientTool, via the existingAgentSpecLoader → create_agentmiddleware forwarding. The tool-conversion payload is left untouched.Tests
test_client_tool_in_agent_interrupt_carries_tool_call_id(agent path: model calls a client tool → assert the parked interrupt carriestool_call_id).black+isortclean.