What Are Multi-Agent Systems and Why Use Them
A multi-agent system is a program where two or more LLM-powered agents, each with its own instructions, tools and context, cooperate to finish a task that none of them handles alone. One agent might plan, another might search, a third might review. Your code, or one of the agents, decides who does what and how results flow between them.
What counts as an agent here
In this course an agent is a model call (or a loop of model calls) with a system prompt, optionally some tools, and a defined job. The agent reads input, may call tools, and returns an output. A multi-agent system is simply several of these wired together. There is no magic framework requirement: a few functions that call the model and pass strings around already qualify.
If you want to learn how a single agent loop works first, see the Tool Use and Agent Loops topic. This course starts where that one ends: what changes when you have more than one agent.
Why split work across agents
There are four practical reasons, and they are the only reasons that justify the extra complexity.
- Focused context. Each agent sees only what it needs. A research subagent can read twenty pages without filling the main agent's context window; it returns a short summary instead.
- Specialisation. A narrow system prompt with a few tools often behaves better than one huge prompt that tries to cover every case.
- Parallelism. Independent subtasks can run at the same time, which cuts wall-clock time.
- Independent review. A reviewer agent that did not write the draft is less likely to share its blind spots, especially if it has different instructions.
What it costs
Every extra agent adds model calls, tokens, latency and failure points. Messages between agents can lose information. Bugs become harder to trace because a wrong answer may come from any step. Teams that jump straight to many agents often end up with a slower, more expensive system that is no more accurate than one well-prompted agent. The rest of the course teaches you how to get the benefits while controlling those costs.
A first look in code
The smallest useful multi-agent system has two agents and a function that connects them. This Python example uses the Anthropic SDK (pip install anthropic, with ANTHROPIC_API_KEY set). The first agent drafts an answer; the second critiques it.
import anthropic
client = anthropic.Anthropic()
def run_agent(system: str, task: str) -> str:
response = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=2000,
system=system,
messages=[{"role": "user", "content": task}],
)
return "".join(b.text for b in response.content if b.type == "text")
draft = run_agent(
"You are a technical writer. Write clearly and briefly.",
"Explain what a database index is in three sentences.",
)
review = run_agent(
"You are a strict reviewer. List factual errors or unclear wording. "
"If the text is fine, reply with exactly: OK",
"Review this text:\n\n" + draft,
)
print("DRAFT:", draft)
print("REVIEW:", review)
Run it and you will see two printed blocks: a short explanation, then either OK or a list of problems. The point is the structure, not the output. Two agents with different instructions looked at the same text, and your code moved the string between them.
Where multi-agent systems are used
- Research tools that send several subagents to look at different sources, then merge the findings.
- Coding assistants that separate a planning step from an editing step and a test-running step.
- Support systems that triage a request and hand it to a billing, technical or account specialist.
- Content pipelines where a draft goes through fact-checking and style review stages.
What to remember
- A multi-agent system is several agents with separate instructions, tools and context that cooperate.
- Use it for context isolation, specialisation, parallelism or independent review.
- Expect higher cost, higher latency and harder debugging than a single agent.
- Start with the simplest design that works, and add agents only when you can name the problem each one solves.
The next post compares single and multi-agent designs directly, so you can decide which one your task needs.
Comments
No comments yet. Have a question or a tip? Be the first to share it.