Multi-Agent Collaboration is a pattern where multiple specialized LLM agents work together on a task. Each agent has a defined role, toolset, and expertise area. A coordinator routes subtasks to the right agent and merges their outputs into one result.
At a Glance
- Problem: A single agent asked to cover research, design, coding, and testing fills its context window, accumulates competing instructions, and picks the wrong tool from an unwieldy set, ending up mediocre at every part of the task.
- Forces: Specialization improves each agent's results, but every handoff can lose context; peer-to-peer control is more flexible, while a supervisor is easier to debug; each added agent brings expertise and also coordination cost.
- Solution: Give each agent a narrow role with its own system prompt and tools, then coordinate them through a supervisor, direct peer-to-peer messaging, or a hierarchy of supervisors that delegates subtasks and merges the results.
- Consequences: Gains: modularity, per-task model choice, agents you can test in isolation, and concurrency for independent subtasks. Costs: more tokens spent on inter-agent messages, added latency from sequential handoffs, more infrastructure, and debugging that spans several agents.
What problem does Multi-Agent Collaboration solve?
Some tasks are too broad for a single agent to handle well. Consider building a system that takes a product requirements document and produces a working prototype. That involves understanding the requirements, designing an architecture, writing frontend code, writing backend code, setting up a database schema, and writing tests. A single agent attempting all of this struggles: its context window fills up, its instructions pull in competing directions, and its tool set grows unwieldy.
The problem gets worse as you try to make the agent more capable. Adding more tools increases the chance the agent picks the wrong one. Adding more instructions makes the system prompt longer and harder for the model to follow consistently. You end up with one large agent that does no part of the job especially well.
Software engineers know this problem already. A single class that handles authentication, database queries, email sending, and PDF generation is painful to maintain, and an agent with the same spread of jobs has the same problem. Specialized agents give better results and are easier to debug.
How does Multi-Agent Collaboration work?
Instead of one agent doing everything, you create multiple agents that each focus on a narrow domain. A research agent knows how to search the web and synthesize findings. A coding agent knows how to write and modify code. A review agent knows how to evaluate code quality. Each agent has its own system prompt, its own set of tools, and its own area of expertise.
The design work is in how these agents coordinate. Three orchestration patterns are common.
In the supervisor pattern, one agent acts as the coordinator. It receives the user request, decides which specialist agent should handle each part, delegates work, collects results, and assembles the final response. The specialist agents never talk to each other directly. All communication goes through the supervisor. This is the simplest pattern to implement and reason about.
The peer-to-peer pattern lets agents communicate directly with each other. A coding agent might ask a research agent to look up an API specification, receive the answer, and continue its work without a central coordinator. This is more flexible but harder to debug, because no single agent controls the flow. You need clear protocols for how agents discover and message each other.
The hierarchical pattern adds layers of delegation. A top-level supervisor delegates to mid-level supervisors, who delegate to specialist agents. This works for very complex tasks where even the subtasks are too broad for a single agent. Think of a software project manager who delegates to a frontend lead and a backend lead, each of whom manages their own team of specialists.
These three styles say who coordinates; the shape of the work gives a finer choice among seven topologies, from fixed sequential and parallel workflows to the model-driven hierarchical and network shapes. Multi-Agent Topologies shows how to read that shape off the task and compose shapes, and Orchestrator-Workers covers the one-level form of the hierarchy in detail.
Whichever orchestration pattern you pick, each agent stays small and focused, and you can test it on its own. You can swap out the coding agent for a better one without touching the research agent. You can test the review agent in isolation by feeding it code samples.
When should you use Multi-Agent Collaboration?
Multi-agent collaboration makes sense when the task splits cleanly into distinct domains that require different expertise, tools, or context.
Good indicators:
- The task involves multiple disciplines (research, coding, design, analysis) that would require very different tool sets
- A single agent's context window cannot hold all the information needed for the full task
- You want to use different models for different subtasks, perhaps a cheaper model for simple classification and a more capable model for code generation
- You need clear audit trails showing which agent made which decision
- The system needs to scale, and different subtasks have different latency or cost profiles
If the task is straightforward enough that a single agent with a few tools can handle it reliably, adding more agents only adds overhead, because every message between agents costs tokens and adds latency.
When not to use it: when the subtasks are independent pieces of the same kind of work, use Parallelization instead of separate specialist agents. When the steps are known in advance and run in a fixed order, Prompt Chaining gives the same structure without inter-agent messaging. Also avoid it when the pieces must share many design decisions to stay consistent, since every handoff is a chance to lose context and agents drift apart on their assumptions.
Implementation
# Using OpenAI SDK for illustration — swap client for any provider
from openai import OpenAI
client = OpenAI()
def call_agent(system_prompt: str, task: str) -> str:
"""Run a specialist agent with a focused system prompt."""
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": task},
],
)
return response.choices[0].message.content
def supervisor(task: str) -> str:
"""Supervisor pattern: delegate to specialists, then synthesize."""
# Step 1: Research agent gathers information
research = call_agent(
"You are a research specialist. Gather key facts and data points. Be concise.",
task,
)
# Step 2: Writing agent drafts a response using the research
draft = call_agent(
"You are a writing specialist. Write a clear, well-structured response based on the research provided.",
f"Task: {task}\n\nResearch findings:\n{research}",
)
# Step 3: Review agent checks quality
review = call_agent(
"You are a review specialist. Check for accuracy, clarity, and completeness. Return the final version with any corrections.",
f"Original task: {task}\n\nDraft to review:\n{draft}",
)
return review
# Usage
print(supervisor("Write a brief comparison of PostgreSQL vs. MySQL for a startup"))
Worked Example: Cost and Latency
A writing assistant produces 1,000 technical comparisons a day, like the PostgreSQL vs. MySQL example above.
| Setup | Calls per request | Tokens per request (in / out) | Cost per 1,000 requests | Latency per request |
|---|---|---|---|---|
| Single agent, one call | 1 | 800 / 900 | $15.90 | 15.5 s |
| Supervisor with three specialists, all on the large model | 3 | 4,000 / 2,400 | $48.00 | 41.5 s |
| Same, with the research specialist on the small model | 3 | 4,000 / 2,400 | $38.51 | 35.5 s |
Assumptions: the single agent reads an 800-token prompt and writes a 900-token answer. In the supervisor version, research reads 300 tokens and writes 600; the writer reads 1,700 tokens (task, instructions, research) and writes 900; the reviewer reads 2,000 tokens and writes 900. The three calls run in sequence.
All on the large model, 4,000 input tokens × $3.00 per million = $0.012 and 2,400 output tokens × $15.00 per million = $0.036, so $48.00 per 1,000. Latency is (0.5 + 600 / 60) + (0.5 + 900 / 60) + (0.5 + 900 / 60) = 41.5 s. Moving research to the small model costs $0.000405 for that step instead of $0.0099, and its 600 tokens take 4.5 s instead of 10.5 s.
Three specialists cost about 3 times as much and take 2.7 times as long as one call, so the split pays off only when it measurably improves the output; putting simple roles on a smaller model recovers part of the difference.
What are the common pitfalls?
Coordination overhead is the most immediate risk. If agents spend more time communicating than working, you have built a bureaucracy. The supervisor becomes a bottleneck, reformulating messages and routing information. Keep the number of agents small and the interfaces between them clean.
Lost context happens when important information fails to transfer between agents. The research agent discovers an important constraint, but the summary it passes to the coding agent omits that detail. Each message between agents is an opportunity for information loss. Be explicit about what information must flow between agents.
Infinite delegation loops occur when agents pass work back and forth without making progress. Agent A asks Agent B for clarification, Agent B asks Agent A for more context, and neither produces useful work. Set maximum iteration limits and include circuit breakers that escalate to a human when agents are stuck.
Inconsistent outputs arise when agents make conflicting assumptions. The frontend agent assumes a REST API while the backend agent builds a GraphQL endpoint. Without shared context about architectural decisions, agents will drift apart. A shared scratchpad or state document that all agents can read helps maintain consistency.
Debugging becomes harder because the execution path spans multiple agents. When the final output is wrong, you need to trace through several agents to find where things went off track. Log every agent boundary so you can follow the trail.
What are the trade-offs?
You gain modularity, the ability to use different models per task, easier testing of individual components, and parallelism where independent subtasks can run concurrently.
You pay with increased system complexity, higher total token usage due to inter-agent communication, more infrastructure to manage, and harder debugging when things go wrong.
Latency increases because sequential agent calls add up. If Agent A must finish before Agent B can start, total time is the sum of both. Identify which subtasks can run in parallel and execute them concurrently where possible.
Cost scales with communication. Every message between agents is an LLM call. A chatty multi-agent system, where agents keep asking each other for clarification, can get expensive fast. Design agent interfaces to minimize round trips.
The sweet spot is usually 2 to 5 agents. With fewer, you probably do not need multiple agents at all; with more, coordination overhead starts to dominate. Start with the minimum number of agents and add more only when you have evidence that a single agent cannot handle a particular subtask well.
Goes Well With
Plan and Execute gives the supervisor agent a structure to work from. The planner creates a structured plan, and each step in the plan gets delegated to the appropriate specialist agent. The planner decides the order of work, and the specialists bring their domain tools and prompts.
Tool Calling is what each individual agent uses to interact with external systems. The research agent calls search APIs. The coding agent calls file system tools. Multi-agent collaboration is about how agents coordinate with each other, while tool calling is about how each agent interacts with the outside world.
ReAct Loop can serve as the execution pattern within each individual agent. Each specialist agent reasons about its subtask, takes actions, and observes results using the ReAct cycle. The multi-agent layer sits above this, coordinating which agent runs when.
Parallelization is the same fan-out at the level of single calls. When the subtasks are independent and don't need tools or multi-step reasoning, parallel calls give you the speed of multiple agents without the coordination overhead.
Orchestrator-Workers is the supervisor shape where the subtasks are decided at run time and the workers are interchangeable. It is the one-level form of the hierarchical pattern, with the plan validation, worker bounds, and synthesis rules worked out.
Agent Handoffs applies when the conversation itself should move to another specialist instead of returning to a supervisor. It defines what the receiving agent is given and caps how many times a user can be passed along.
Shared Memory gives the agents one versioned store of findings to read and write, so facts are not paraphrased at each step and every claim records which agent wrote it.
References
- Wu, Q., et al. (2023). AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation. arXiv preprint. arXiv
- Hong, S., et al. (2023). MetaGPT: Meta Programming for a Multi-Agent Collaborative Framework. ICLR 2024. arXiv
Further Reading
- Wu et al., "AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation" (2023). Introduces a framework for building multi-agent systems where customizable agents converse with each other to solve tasks, demonstrating the supervisor and peer-to-peer patterns. arXiv:2308.08155