The Core Idea: A multi-agent system splits a big job among several agents, each with its own role, tools and instructions. Specialization keeps each agent's prompt small and lets work run in parallel, but it adds coordination cost.
- Beginner: Why Multiple Agents?
A single agent with fifty tools and a long list of duties becomes confused, slow and expensive. Human teams solve the same problem by specializing: a researcher, an analyst and an assistant each do what they are best at.
| Reason | What it means |
|---|---|
| Specialization | Each agent has a focused role and a few tools, so it picks the right tool more often |
| Smaller prompts | Fewer tool descriptions and instructions per call |
| Parallel work | Independent tasks run at the same time |
| Separation of concerns | A writer and a reviewer can check each other |
| Easier to improve | You can test and upgrade one agent without touching the rest |
Analogy: One employee doing sales, support, accounting and engineering will be mediocre at all of them. A team with clear roles works better, as long as it communicates well.
- Beginner: Single-Agent vs. Multi-Agent
| Single agent | Multi-agent system | |
|---|---|---|
| Design | One loop, all tools | Several loops with different roles |
| Cost | Lower | Higher, from extra model calls and messages |
| Speed | Sequential | Can be parallel |
| Debugging | Easier, one trace | Harder, many traces and interactions |
| Predictability | Higher | Lower |
| Best for | Focused tasks with a few tools | Broad tasks with distinct skills |
Rule of thumb: Start with one agent. Add more only when you can show that one agent is failing because of too many tools, too long a prompt, or tasks that could run in parallel.
- Medium: Agent Specialization
A specialist agent is defined by three things: a role in its instructions, a small set of tools, and often a different model, such as a cheaper one for simple work.
| Specialist | Tools | Typical job |
|---|---|---|
| Researcher | web_search, read_page | Find and read sources |
| Analyst | sql_query, make_chart | Analyze data |
| Assistant | send_email, write_file | Take actions |
In the code: The generalist needs a 1,160-token prompt on every call. The researcher needs only 570, the analyst 640, and the assistant 550. Less to read means lower cost, less confusion and faster calls.
- Medium: The Speed-Up From Parallel Specialists
When tasks need different skills and do not depend on each other, specialists can work at the same time.
In the code: Six tasks take 18 seconds for one agent in sequence. With three specialists in parallel, the slowest specialist finishes after 8 seconds, because the researcher has 8 seconds of work and the others have less.
The total time is set by the busiest specialist, so balancing the workload matters.
- Advanced: The Hidden Costs
| Cost | Why it appears | Mitigation |
|---|---|---|
| Coordination | Agents need messages, handoffs and merging | Clear interfaces and few agents |
| Duplicated context | Each agent may need the same background | Share a common context store |
| Error compounding | A mistake by one agent feeds the next | Validate at each handoff |
| Conflicting actions | Two agents change the same thing | Shared state with version checks |
| Harder debugging | Many agents, many traces | Trace every message with a run id |
| More tokens | Every extra agent adds calls | Use small prompts and cheaper models for easy roles |
Do not over-split. More agents is not better by itself. Many tiny agents with overlapping duties usually mean more bugs and a bigger bill.
- Visual Explanation: Generalist vs. Specialists: Prompts and Time
The figure compares the prompt size of one generalist with three specialists, then shows the time saved by working in parallel.
Click to see when one agent is still betterCompare ▼
Part 1 uses the token counts from the code. Part 2 uses the time numbers. Open the bar to see when a single agent is still the better choice.
- Python Implementation: Comparing One Agent With a Team of Specialists
This script counts the prompt tokens needed by a generalist with six tools versus three specialists with two tools each, and compares the time to finish six tasks in sequence against a parallel team.
# One generalist agent vs a team of specialistsTOOL_TOKENS = {"web_search": 150, "read_page": 120, "sql_query": 180, "make_chart": 160, "send_email": 140, "write_file": 110}BASE_INSTRUCTIONS = 300 # tokens of instructions every agent needs specialists = { "researcher": ["web_search", "read_page"], "analyst": ["sql_query", "make_chart"], "assistant": ["send_email", "write_file"],} def prompt_tokens(tools): return BASE_INSTRUCTIONS + sum(TOOL_TOKENS[t] for t in tools) generalist = prompt_tokens(list(TOOL_TOKENS))print("Generalist prompt:", generalist, "tokens on every model call")for name, tools in specialists.items(): print(name.ljust(11), "prompt:", prompt_tokens(tools), "tokens |", len(tools), "tools") # Time: tasks that need different skills can run at the same timetasks = [("researcher", 5), ("analyst", 4), ("researcher", 3), ("assistant", 2), ("analyst", 3), ("assistant", 1)]single_agent_time = sum(seconds for _, seconds in tasks) per_specialist = {}for skill, seconds in tasks: per_specialist[skill] = per_specialist.get(skill, 0) + secondsteam_time = max(per_specialist.values()) print("One agent does all tasks in sequence:", single_agent_time, "seconds")print("Three specialists work in parallel: ", team_time, "seconds", per_specialist)print("Coordination is not free: the team also needs messages, shared context and a way to merge results.")Each specialist carries about half the prompt of the generalist, and the team finishes in 8 seconds instead of 18. The last line is the catch: coordination is not free, which is why the later lessons cover communication, architectures and orchestration.
Knowledge Check
Key Points
The Big Picture
Split by skill → keep each agent small → run independent work in parallel → pay the coordination cost
The art of multi-agent design is deciding how few agents you really need.
Up Next: Agents on a team must talk to each other. In Agent Communication and Collaboration you will learn message passing, shared context and collaborative problem solving.