LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Graphs
    • Functional API
    • Pregel
    • Checkpointing
    • Storage
    • Caching
    • Types
    • Runtime
    • Config
    • Errors
    • Constants
    • Channels
    • Agents
    LangGraph Checkpoint
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewGraphsFunctional APIPregelCheckpointingStorageCachingTypesRuntimeConfigErrorsConstantsChannelsAgents
    LangGraph Checkpoint
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraphpregel_toolsStreamToolCallHandler
    Class●Since v1.1

    StreamToolCallHandler

    Copy
    StreamToolCallHandler(
      self,
      stream: Callable[[StreamChunk], None],
      subgraphs: bool,
      *

    Bases

    BaseCallbackHandler_StreamingCallbackHandler

    Constructors

    Attributes

    Methods

    Inherited fromBaseCallbackHandler(langchain_core)

    Attributes

    Araise_errorAignore_llmAignore_retryAignore_chainA
    View source on GitHub
    ,
    parent_ns
    :
    tuple
    [
    str
    ,
    .
    .
    .
    ]
    |
    None
    =
    None
    )
    ignore_agent
    Aignore_retriever
    Aignore_chat_model
    Aignore_custom_event

    Inherited fromLLMManagerMixin(langchain_core)

    Methods

    Mon_llm_new_tokenMon_llm_endMon_llm_errorMon_stream_event

    Inherited fromChainManagerMixin(langchain_core)

    Methods

    Mon_chain_endMon_chain_errorMon_agent_actionMon_agent_finish

    Inherited fromRetrieverManagerMixin(langchain_core)

    Methods

    Mon_retriever_errorMon_retriever_end

    Inherited fromCallbackManagerMixin(langchain_core)

    Methods

    Mon_llm_startMon_chat_model_startMon_retriever_startMon_chain_start

    Inherited fromRunManagerMixin(langchain_core)

    Methods

    Mon_textMon_retryMon_custom_event

    Parameters

    NameTypeDescription
    stream*Callable[[StreamChunk], None]

    Callable that accepts a StreamChunk tuple (namespace, mode, payload) and enqueues it.

    subgraphs*bool

    Whether to emit events from tools called inside nested subgraphs. When False, only tools at the handler's own scope (parent_ns) emit.

    parent_nstuple[str, ...] | None
    Default:None
    constructor
    __init__
    NameType
    streamCallable[[StreamChunk], None]
    subgraphsbool
    parent_nstuple[str, ...] | None
    attribute
    run_inline: bool
    attribute
    stream: stream
    attribute
    subgraphs: subgraphs
    attribute
    parent_ns: parent_ns
    method
    tap_output_aiter

    Pass-through — required by the _StreamingCallbackHandler protocol.

    method
    tap_output_iter

    Pass-through — sync counterpart to tap_output_aiter.

    method
    on_tool_start
    method
    on_tool_end
    method
    on_tool_error

    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.