StreamToolCallHandler(
self,
stream: Callable[[StreamChunk], None],
subgraphs: bool,
*BaseCallbackHandler_StreamingCallbackHandler| Name | Type | Description |
|---|---|---|
stream* | Callable[[StreamChunk], None] | Callable that accepts a |
subgraphs* | bool | Whether to emit events from tools called inside
nested subgraphs. When False, only tools at the
handler's own scope ( |
parent_ns | tuple[str, ...] | None | Default: None |
| Name | Type |
|---|---|
| stream | Callable[[StreamChunk], None] |
| subgraphs | bool |
| parent_ns | tuple[str, ...] | None |
Callback handler that emits tool-call lifecycle events on the stream.
Fires on LangChain's on_tool_* callbacks and pushes to the tools
stream mode. Emits tool-started / tool-output-delta /
tool-finished / tool-error payloads keyed by tool_call_id.
While a tool is executing, this handler sets _tool_call_writer to a
closure bound to that call's namespace and tool_call_id.
ToolRuntime.emit_output_delta reads that ContextVar so tool bodies
can stream partial output without threading the writer through their
own signature.
Attached by Pregel.stream / astream when "tools" is in
stream_modes. run_inline = True keeps event ordering
deterministic.
Namespace where the handler was attached.
Mirrors the StreamMessagesHandler escape hatch:
tools whose containing namespace equals parent_ns
still emit even with subgraphs=False, so a node that
explicitly streams a subgraph with stream_mode="tools"
sees its own tools.