When to use several agents
7 min read
One agent first
A single AI agentA program that uses a language model to work toward a goal. It chooses its own steps, uses tools to act, reads the results and repeats until the goal is met or a limit stops it. has one history, one set of instructions and one place to debug. Splitting it into several makes the system harder to follow, even when each part is simple. Messages pass between agents, and each message is a chance to lose a fact.
So the default is one agent with a good set of tools. Add more agents only for a reason you can name.
Two good reasons to split
The context is overloaded. One agent that researches, writes and checks code will fill its window with all three jobs. If the research output swamps the task, give research to a separate agent. It does the reading in its own window and returns a short summary.
The jobs need different setups. A reviewer should see the work with fresh eyes and strict rules. A writer needs a loose style and different tools. Separate instructions and separate tool lists keep each agent focused. A reviewer that did not write the draft also does not defend it.
If neither reason applies, a single agent or a fixed Agentic workflowA fixed sequence of steps in which your code decides the order and a language model does the work inside each step. It is cheaper and easier to test than an agent, which chooses its own steps. is usually better.
The common shape: one lead, several workers
The most common design has one lead agent that breaks the task into parts and sends each part to a worker. The workers do their jobs and report back. The lead combines the results.
def research_worker(topic):
return f"3 key facts about {topic}"
def writing_worker(facts):
return f"Draft based on: {facts}"
def lead(task):
facts = research_worker(task)
draft = writing_worker(facts)
return draft
print(lead("solar panels"))In a real system each worker would be its own agent with its own prompt, and the lead would use a model to decide which worker to call and in what order. The shape stays the same: the lead sees summaries, and the workers see the details.
What each hand-off costs
Count these costs before you add an agent.
- Lost detail. The summary that the worker returns leaves things out. Make workers return what the lead needs, in a fixed format.
- More calls. Each agent makes its own calls, so cost and delay go up.
- Harder debugging. A wrong answer may come from any agent. Log every message between them.
- Compounding errors. A small mistake in one worker passes to the next as if it were fact.
Test the single-agent version first. If it works well enough, stop there.
What do you build first?
You are starting a task that researches a topic and writes a short report.
One agent is simpler to run, test and debug. Split only when you can name the reason.
Is splitting a good idea here?
Reading long web pages fills your agent's window, so it forgets the task.
A worker reads in its own window and sends back only what the lead needs.
What does a hand-off cost?
A worker returns a summary to the lead agent.
Every message between agents can drop a fact, so keep the format fixed and log it.
Your reading position is saved
0 of 20 complete
Lesson complete
When to use several agents
Up next