LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coremessagescontentToolCallChunk
    Classā—Since v1.0

    ToolCallChunk

    Copy
    ToolCallChunk()

    Bases

    TypedDict

    Constructors

    Attributes

    View source on GitHub
    constructor
    __init__
    NameType
    typeLiteral['tool_call_chunk']
    idstr | None
    namestr | None
    argsstr | None
    indexNotRequired[int | str]
    extrasNotRequired[dict[str, Any]]
    attribute
    type: Literal['tool_call_chunk']

    Used for serialization.

    attribute
    id: str | None

    An identifier associated with the tool call.

    An identifier is needed to associate a tool call request with a tool call result in events when multiple concurrent tool calls are made.

    attribute
    name: str | None

    The name of the tool to be called.

    attribute
    args: str | None

    The arguments to the tool call.

    attribute
    index: NotRequired[int | str]

    The index of the tool call in a sequence.

    attribute
    extras: NotRequired[dict[str, Any]]

    Provider-specific metadata.

    A chunk of a tool call (yielded when streaming).

    When merging ToolCallChunks (e.g., via AIMessageChunk.__add__), all string attributes are concatenated. Chunks are only merged if their values of index are equal and not None.

    Example:

    left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
    right_chunks = [ToolCallChunk(name=None, args="1}", index=0)]
    
    (
        AIMessageChunk(content="", tool_call_chunks=left_chunks)
        + AIMessageChunk(content="", tool_call_chunks=right_chunks)
    ).tool_call_chunks == [ToolCallChunk(name="foo", args='{"a":1}', index=0)]