ToolCall Class — langchain Architecture
Architecture documentation for the ToolCall class in content.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 6bc62cef_f33e_f1ca_7a0d_9d6bb604b4c5["ToolCall"] c7f11daf_e104_efbe_7225_f1d6da8e8630["content.py"] 6bc62cef_f33e_f1ca_7a0d_9d6bb604b4c5 -->|defined in| c7f11daf_e104_efbe_7225_f1d6da8e8630
Relationship Graph
Source Code
libs/core/langchain_core/messages/content.py lines 247–288
class ToolCall(TypedDict):
"""Represents an AI's request to call a tool.
Example:
```python
{"name": "foo", "args": {"a": 1}, "id": "123"}
```
This represents a request to call the tool named "foo" with arguments {"a": 1}
and an identifier of "123".
!!! note "Factory function"
`create_tool_call` may also be used as a factory to create a
`ToolCall`. Benefits include:
* Automatic ID generation (when not provided)
* Required arguments strictly validated at creation time
"""
type: Literal["tool_call"]
"""Used for discrimination."""
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
"""The name of the tool to be called."""
args: dict[str, Any]
"""The arguments to the tool call."""
index: NotRequired[int | str]
"""Index of block in aggregate response. Used during streaming."""
extras: NotRequired[dict[str, Any]]
"""Provider-specific metadata."""
Defined In
Source
Frequently Asked Questions
What is the ToolCall class?
ToolCall is a class in the langchain codebase, defined in libs/core/langchain_core/messages/content.py.
Where is ToolCall defined?
ToolCall is defined in libs/core/langchain_core/messages/content.py at line 247.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free