Skip to content

Tool

Data Structures for Tools.

ToolCall

Bases: BaseModel

Tool call.

Attributes:

Name Type Description
id_ str

String identifier for tool call.

tool_name str

Name of tool to call.

arguments dict[str, Any]

The arguments to pass to the tool execution.

Source code in src/llm_agents_from_scratch/data_structures/tool.py
class ToolCall(BaseModel):
    """Tool call.

    Attributes:
        id_: String identifier for tool call.
        tool_name: Name of tool to call.
        arguments: The arguments to pass to the tool execution.
    """

    id_: str = Field(default_factory=lambda: str(uuid.uuid4()))
    tool_name: str
    arguments: dict[str, Any]

ToolCallResult

Bases: BaseModel

Result of a tool call execution.

Attributes:

Name Type Description
tool_call_id str

The id of the associated tool call.

content Any | None

The content of tool call.

error bool

Whether or not the tool call yielded an error.

Source code in src/llm_agents_from_scratch/data_structures/tool.py
class ToolCallResult(BaseModel):
    """Result of a tool call execution.

    Attributes:
        tool_call_id: The id of the associated tool call.
        content: The content of tool call.
        error: Whether or not the tool call yielded an error.
    """

    tool_call_id: str
    content: Any | None
    error: bool = False