Sub topic 3
Why Use More Than One Agent
This chapter assumes you can write basic Python, know how LLM messages and prompts work, can read JSON, and have seen tool (function) calling before. An agent here means a model, a set of instructions, a set of tools, and a loop that runs until the model gives a final answer. Later chapters build the handoff and orchestrator patterns. This chapter answers an earlier question: when is a second agent worth having at all?
Start with one agent
A single agent is the default. It has one prompt, one tool list, and one message history. It is easy to trace, cheap to run, and has few places to fail. Every extra agent adds a prompt to maintain, a boundary where information can get lost, and more model calls to pay for.
So the question is not "how many agents can I build?" It is "what specific problem does a single agent have that a split would fix?" If you can't name the problem, keep one agent.
Problems that a split can fix
Four problems come up repeatedly. Each one is a symptom you can observe before you decide to split.
1. Too many tools
Each tool adds a name, a description, and a parameter schema to the prompt. As the list grows, the model more often picks the wrong tool or fills in arguments incorrectly. There is no fixed limit. Many teams see selection errors rise noticeably somewhere between ten and twenty tools, especially when the tools have similar descriptions, such as refund_order and cancel_order.
Splitting by domain gives each agent a short, distinct tool list. A billing agent sees four billing tools. A shipping agent sees four shipping tools.
2. Conflicting or bloated instructions
One prompt that says "be formal and brief with legal questions, be friendly and chatty with sales questions, never discuss pricing unless asked" is hard for the model to follow. It is also hard for you to edit, because a change meant for one case can alter behavior in another.
Separate agents let each prompt describe one role and one tone. You can then change and test the billing prompt without touching the sales prompt.
3. Context that grows too large
Every tool result stays in the message history. A research step that reads ten web pages can add tens of thousands of tokens. Later steps pay for that text on every call, and the model may lose track of the original goal in the middle of it.
A specialist that runs in its own history can read all ten pages and return a two-paragraph summary. The caller never sees the raw pages.
4. Different needs per step
Some steps need a strong, slow model, such as planning or checking a legal clause. Others need only a fast, cheap one, such as classifying a message. With one agent, the whole run uses one model. With several, each agent can use the model that fits its job.
Problems that a split does not fix
Splitting is not a general quality boost. These cases usually do not improve:
- A weak prompt. Two agents with vague prompts produce vague answers twice.
- A missing tool. If no agent can look up the order, no arrangement of agents will.
- Strictly sequential, tightly coupled work. If step two needs every detail of step one, passing a summary loses information that the second step needed.
- Simple tasks. A task that takes three tool calls does not need a team.
Anthropic and OpenAI both advise in their agent guides to try a single agent first and add structure only when measurements show a need. Treat that as the baseline.
What a split costs
| Cost | What happens |
|---|---|
| Model calls | Each agent adds at least one call. A routing step adds a call before any work starts. |
| Latency | Sequential agents add their delays together. |
| Information loss | A summary passed between agents drops details. |
| Debugging | A wrong answer may come from any agent or from the message between them. |
| Failure surface | Each agent can loop, error, or be misled. A bad output from one becomes input to the next. |
Later chapters cover turn limits, retries, tracing, and cost in detail. For now, remember that these costs are certain, while the benefits depend on your workload.
Two ways to split
The rest of the tutorial centers on two patterns. They differ in who is in control after the split.
- Handoff. The active agent transfers control. The next agent continues the same conversation with the user and the previous agent steps out.
- Orchestrator. A manager agent keeps control. It calls specialists as tools, gets their results back, and combines them into one answer.
Both patterns solve the four problems above. They differ in how they handle the shared history, which the next chapters explore.
A concrete decision
Suppose you run a support assistant with 22 tools covering billing, shipping, and account settings. Users report that it sometimes calls cancel_order when they ask about a refund. You also find the prompt has grown to 1,800 words of mixed rules.
Here is how to reason about it:
- The symptom is wrong tool selection, which points to problem 1 (too many tools).
- The prompt has mixed rules, which points to problem 2.
- Context size is not a complaint, so problem 3 is not a driver.
- Users talk to the assistant directly and conversations continue across topics, which fits a handoff: a triage agent routes to billing, shipping, or account agents.
Before you build it, measure. Take 50 logged conversations and count how often the single agent picks the wrong tool. After the split, run the same 50 and compare. If the error rate does not drop, the split did not help and you have added cost for nothing.
A quick sketch
The Agent dataclass below shows how little a "separate agent" requires. Each agent is just a name, instructions, and its own tool list. The point is that splitting tools narrows what the model has to choose from.
from dataclasses import dataclass, field
from typing import Callable
@dataclass
class Agent:
name: str
instructions: str
tools: dict[str, Callable] = field(default_factory=dict)
handoffs: dict[str, "Agent"] = field(default_factory=dict)
def refund_order(order_id: str) -> str:
return f"Refund started for {order_id}"
def cancel_order(order_id: str) -> str:
return f"Order {order_id} cancelled"
def track_package(order_id: str) -> str:
return f"Order {order_id} is in transit"
# One agent: every tool competes for the model's attention.
single = Agent(
name="support",
instructions="Handle billing and shipping questions.",
tools={
"refund_order": refund_order,
"cancel_order": cancel_order,
"track_package": track_package,
},
)
# Two agents: each model call sees fewer, more distinct tools.
billing = Agent(
name="billing",
instructions="Handle refunds and cancellations only.",
tools={"refund_order": refund_order, "cancel_order": cancel_order},
)
shipping = Agent(
name="shipping",
instructions="Handle delivery questions only.",
tools={"track_package": track_package},
)
print(len(single.tools), len(billing.tools), len(shipping.tools))Running it prints 3 2 1. With three tools the gain is tiny. With twenty it can matter, which is why you measure first.
Common mistakes
- Splitting by job title instead of by need. Agents named "Manager," "Analyst," and "Reviewer" with overlapping prompts add calls without separating anything. Split along tool sets, context size, or model needs.
- Splitting too early. Without a baseline from a single agent, you cannot tell whether the split helped.
- Expecting agents to share memory automatically. Unless you pass it, a second agent knows only what is in its own message history. Chapter on context passing covers this.
- Ignoring the added attack surface. An agent that reads untrusted web content and then passes text to an agent with payment tools can be steered by that text. Trust boundaries get their own chapter.
Summary
Use one agent until you can point to a measurable problem: tool confusion, conflicting instructions, bloated context, or mismatched model needs. Then split along that problem, choose handoff or orchestrator based on who should hold control, and compare the result against the single-agent baseline.
Exercise
Your single agent has 6 tools, a 300-word prompt, and short conversations. It answers correctly about 95% of the time on your test set. A teammate proposes splitting it into four agents. Which of the four problems from this chapter apply, and what do you recommend?
Show answer
None clearly apply. Six tools is a small list, the prompt is short and unlikely to conflict, the conversations are short so context is not large, and nothing suggests different steps need different models. Accuracy is already high. Recommend keeping one agent. If the teammate wants to split, ask for a specific failure in the test set that a split would fix, then measure before and after.
Exercise
A research step reads ten long web pages, and later steps in the same agent become slow, expensive, and sometimes forget the user's original question. Which problem is this, and how does a split help?
Show answer
This is the context-growth problem. Every page stays in the message history and is paid for on each later call. A specialist agent with its own history can read the pages and return a short summary, so the calling agent's history stays small and focused on the original question. The trade-off is that details not in the summary are lost, so the specialist's instructions should say what the summary must include.