liveBook · Manning

Tool-based agent consumption

As explained in Build an AI Agent (From Scratch)

The agent as tool pattern exposes an AI agent through a callable tool interface so another agent can invoke it with parameters and receive its result.

When a request may need different specialists, a coordinator can consume each specialist as a tool. The LLM chooses which to call, receives the result, and remains responsible for the response. Use this pattern when the coordinator must combine expert results rather than follow a fixed pipeline or hand over the conversation. section 9.4 section 9.2

An agent tool has the same outward shape as an ordinary tool: a name, description, parameters, and returned result. AgentTool adapts a specialist agent to the BaseTool interface, so the coordinator can list it alongside tools such as web search or a calculator. section 9.4.1 section 9.4.2

The adapter handles the boundary between coordinator and specialist:

  • Expose a default string parameter named request, or derive structured parameters from a Pydantic input_schema. section 9.4.2
  • Validate structured input when supplied, convert it to a string, and run the child agent with that string; otherwise, pass request directly. section 9.4.2
  • Return the child’s result without passing the parent’s execution context into the child. section 9.4.2

Research and code on demand

For a request to research AI agent frameworks and write a Python script comparing their GitHub stars, give one specialist web search and another code execution. Register both with the coordinator as tools: orchestrator = Agent( model=llm, name="coordinator", instructions="Delegate research and coding; combine their results.", tools=[AgentTool(researcher), AgentTool(coder)], ) The coordinator can call the researcher, the coder, or both as the request requires, then synthesize their results. section 9.4.4 section 9.4

Figure 9.8 Agent as Tool: the child agent runs in an isolated environment and returns only the final result.

The context diagram shows the boundary: the specialist works in isolation, and only its final result returns to the coordinator. section 9.4.3

Isolation keeps intermediate tool calls and reasoning out of the coordinator’s context, but child activity needs separate inspection when debugging. If later agents need intermediate state, use a workflow instead. Unlike transfer, a tool call does not give the specialist control of follow-up conversation. section 9.4.3 section 9.5.1

How Build an AI Agent (From Scratch) covers it

How deep it goes
Builds the BaseTool adapter through parameter schemas, input validation, child execution, and context isolation.
Examples
Uses web-search and code-execution specialists to research AI agent frameworks and compare their GitHub stars with Python.
What it assumes
Assumes familiarity with agents, tools, and execution contexts; develops the agent-to-tool adapter explicitly.
What you can do after
Build it from scratch by wrapping specialist agents as tools and registering them with a coordinating Agent.
How it connects
Contrasts with Workflow and Transfer through execution-order choice, context sharing, and control of follow-up conversation.

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.