ToolCallResult records the output of a tool call so an agent can match it to the request and return it to the LLM. A BaseTool accepts a ToolCall through __call__() and returns one ToolCallResult. section 2.1 section 2.5
The Python implementation extends pydantic.BaseModel and defines three fields:
- tool_call_id: str identifies the associated ToolCall. section 2.1.1
- content: Any | None holds the execution result or other result information. section 2.1.1 section 2.2.1
- error: bool indicates whether an error occurred and defaults to False. section 2.1.1
Listing 2.2 Implementing ToolCallResult
# llm_agents_from_scratch/data_structures/tool.py
import uuid
from typing import Any
from pydantic import BaseModel, Field
… #A
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 #B
content: Any | None #C
error: bool = False #DThe implementation defines the field types and the default error flag. section 2.1.1
A successful execution puts its output in content and sets error to False. A basic failure representation uses content=None and error=True. Individual tools can provide more detail: SimpleFunctionTool returns a JSON-serialized error description in content when argument validation or function execution fails. section 2.1.1 section 2.2.1
Return a hailstone step
For a ToolCall with arguments {"x": 3}, the hailstone tool computes 10 and returns ToolCallResult(tool_call_id=tool_call.id_, content=10, error=False). The identifier links the result to the original request. section 2.1.2
To continue a chat, pass one or more results and the chat history to continue_chat_with_tool_results(). It creates TOOL-role ChatMessage objects from the results and returns them alongside the LLM’s response; append both to the running history. section 3.1.2 section 3.2.2
The same result interface can carry remote-agent responses. An A2A tool converts a remote response into ToolCallResult; its content can also indicate that the remote agent needs further input. section 10.2.2 section 10.2.3
