ToolCallChunk Class — langchain Architecture
Architecture documentation for the ToolCallChunk class in tool.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 5a0d3200_8f52_b0a0_cc10_b8b5c02f53ea["ToolCallChunk"] 210f83c5_4be3_e20e_b877_98a194178520["tool.py"] 5a0d3200_8f52_b0a0_cc10_b8b5c02f53ea -->|defined in| 210f83c5_4be3_e20e_b877_98a194178520
Relationship Graph
Source Code
libs/core/langchain_core/messages/tool.py lines 261–300
class ToolCallChunk(TypedDict):
"""A chunk of a tool call (yielded when streaming).
When merging `ToolCallChunk` objects (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)]
```
"""
name: str | None
"""The name of the tool to be called."""
args: str | None
"""The arguments to the tool call as a JSON-parseable string."""
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.
"""
index: int | None
"""The index of the tool call in a sequence.
Used for merging chunks.
"""
type: NotRequired[Literal["tool_call_chunk"]]
"""Used for discrimination."""
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/tool.py.
Where is ToolCallChunk defined?
ToolCallChunk is defined in libs/core/langchain_core/messages/tool.py at line 261.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free