Skip to content

fix(prebuilt): Propagate tool_call_id to checkpoint_ns in ToolNode #6714#6722

Open
Aparnap2 wants to merge 1 commit intolangchain-ai:mainfrom
Aparnap2:fix/6714-tool-node-checkpoint-ns
Open

fix(prebuilt): Propagate tool_call_id to checkpoint_ns in ToolNode #6714#6722
Aparnap2 wants to merge 1 commit intolangchain-ai:mainfrom
Aparnap2:fix/6714-tool-node-checkpoint-ns

Conversation

@Aparnap2
Copy link

Description

Fixes #6714

Updates ToolNode to include the tool_call_id in the checkpoint_ns configuration when creating ToolRuntime. This ensures that events emitted by subgraphs (tools) are properly namespaced, allowing streaming UIs to correlate subgraph events with the specific tool call that triggered them.

Changes

  • Modified ToolNode._func and ToolNode._afunc in libs/prebuilt/langgraph/prebuilt/tool_node.py to append |{tool_call_id} to the checkpoint_ns.
  • Added 4 new test cases in libs/prebuilt/tests/test_tool_node.py covering:
    • Sync and async execution paths.
    • Nested namespaces (with parent_ns).
    • Direct tool calls (no parent_ns).
    • Concurrent tool calls.

Verification

  • All new tests passed.
  • Existing tests passed.
  • Linting passed (ruff check + ruff format).

Updates the configuration passed to tools to include the tool_call_id in the
checkpoint_ns, enabling correct correlation of subgraph events with parent
tool calls during streaming. This fix addresses Issue langchain-ai#6714 where subgraph
namespaces could not be correlated with parent tool calls.

Changes:
- Modified _func and _afunc methods to update checkpoint_ns before creating
  ToolRuntime instances
- Added 4 test cases to verify checkpoint_ns propagation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@GeekRicardo
Copy link

This feature is blocking my production use case.
I need proper event correlation in streaming UIs when using subgraph tools.
Looking forward to seeing this merged!

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.

[Streaming] Cannot correlate subgraph namespace with parent tool_call_id when streaming with subgraphs=True

2 participants