ToolCallChunk Class — langchain Architecture
Architecture documentation for the ToolCallChunk class in content.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 420b694a_6167_9288_f15b_000779f6db67["ToolCallChunk"] c7f11daf_e104_efbe_7225_f1d6da8e8630["content.py"] 420b694a_6167_9288_f15b_000779f6db67 -->|defined in| c7f11daf_e104_efbe_7225_f1d6da8e8630
Relationship Graph
Source Code
libs/core/langchain_core/messages/content.py lines 291–333
class ToolCallChunk(TypedDict):
"""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:
```python
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)]
```
"""
# TODO: Consider making fields NotRequired[str] in the future.
type: Literal["tool_call_chunk"]
"""Used for serialization."""
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.
"""
# TODO: Consider making this NotRequired[str] in the future.
name: str | None
"""The name of the tool to be called."""
args: str | None
"""The arguments to the tool call."""
index: NotRequired[int | str]
"""The index of the tool call in a sequence."""
extras: NotRequired[dict[str, Any]]
"""Provider-specific metadata."""
Defined In
Source
Frequently Asked Questions
What is the ToolCallChunk class?
ToolCallChunk is a class in the langchain codebase, defined in libs/core/langchain_core/messages/content.py.
Where is ToolCallChunk defined?
ToolCallChunk is defined in libs/core/langchain_core/messages/content.py at line 291.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free