liveBook · Manning

Tool result

As explained in Build an AI Agent (From Scratch)

A tool result is the output produced by an external tool after processing an invocation and its arguments, including whether execution succeeded or failed.

A tool result is the structured record produced after a tool processes a tool call. It carries the originating call identifier, tool name, execution status, and returned content, including failure information when execution does not succeed. section 4.3.1

A tool result participates in an execution loop:

  • The model emits a tool call containing a name, identifier, and arguments. section 3.2.1 section 4.3.1
  • The host system parses the arguments, invokes the selected function, and captures its output or failure. section 3.2.1 section 4.3.1
  • The host associates the result with the original call through tool_call_id, allowing parallel executions to remain distinguishable. section 4.3.1
  • The result can be appended as a tool-role message so the model can interpret raw output and continue reasoning. section 3.2.1

Calculator result

For a multiplication call with arguments 1234 and 5678, the host executes the calculator and records content as 7006652. It then appends a tool message with the matching call identifier; the model turns that raw value into “1234 × 5678 = 7,006,652.” section 3.2.1

Listing 4.2 Content types for agent communication
class Message(BaseModel):
    """A text message in the conversation."""
    type: Literal["message"] = "message"
    role: Literal["system", "user", "assistant"]
    content: str

class ToolCall(BaseModel):
    """LLM's request to execute a tool."""
    type: Literal["tool_call"] = "tool_call"
    tool_call_id: str
    name: str
    arguments: dict

class ToolResult(BaseModel):
    """Result from tool execution."""
    type: Literal["tool_result"] = "tool_result"
    tool_call_id: str
    name: str
    status: Literal["success", "error"]
    content: list

ContentItem = Union[Message, ToolCall, ToolResult]

Use the typed content definitions to inspect how ToolResult differs from Message and ToolCall and how a discriminator identifies each kind. section 4.3.1

Wrapping tool results in execution events adds authorship, timestamps, and an execution_id, turning individual results into an auditable trace for debugging. section 4.3.1

How Build an AI Agent (From Scratch) covers it

How deep it goes
Defines fields, correlation, statuses, and event wrapping, but does not specify tool-specific result schemas.
Examples
Uses calculator multiplication, web search, Wikipedia search, and a multi-step distance-to-time calculation.
What it assumes
Assumes familiarity with model messages and tool calls while defining result types and execution tracking explicitly.
What you can do after
Operate agent loops that execute tools, correlate outputs, return results to models, and retain debugging traces.
How it connects
Connects tool calls, messages, agent execution, events, and model reasoning.

Also explained in

Compare how 2 books explain tool result →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build an AI Agent (From Scratch). The section links point to the parts of the book it draws on.