6# Multi-Agent Architecture Patterns
7
8Multi-agent architectures distribute work across multiple language model instances, each with its own context window. When designed well, this distribution enables capabilities beyond single-agent limits. When designed poorly, it introduces coordination overhead that negates benefits. The critical insight is that sub-agents exist primarily to isolate context, not to anthropomorphize role division.
9
10## When to Activate
11
12Activate this skill when:
13- Single-agent context limits constrain task complexity
14- Tasks decompose naturally into parallel subtasks
15- Different subtasks require different tool sets or system prompts
16- Building systems that must handle multiple domains simultaneously
17- Scaling agent capabilities beyond single-context limits
18- Designing production agent systems with multiple specialized components
19
20Do not activate this skill for adjacent work owned by other skills:
21- Deciding task-model fit, pipeline shape, or project-level cost before topology is known: project-development.
22- Designing hosted sandboxes, warm pools, remote sessions, or background runtime infrastructure: hosted-agents.
23- Sharing orchestrator state through KV-cache compaction in controlled runtimes: latent-briefing.
24- Designing the tools each agent exposes: tool-design.
25
26## Core Concepts
27
28Use multi-agent patterns when a single agent's context window cannot hold all task-relevant information. Context isolation is the primary benefit — each agent operates in a clean context without accumulated noise from other subtasks, preventing the telephone game problem where information degrades through repeated summarization.
29
30Choose among three dominant patterns based on coordination needs, not organizational metaphor:
31
32- **Supervisor/orchestrator** — Use for centralized control when tasks have clear decomposition and human oversight matters. A single coordinator delegates to specialists and synthesizes results.
33- **Peer-to-peer/swarm** — Use for flexible exploration when rigid planning is counterproductive. Any agent can transfer control to any other through explicit handoff mechanisms.
34- **Hierarchical** — Use for large-scale projects with layered abstraction (strategy, planning, execution). Each layer operates at a different level of detail with its own context structure.
35
36Design every multi-agent system around explicit coordination protocols, consensus mechanisms that resist sycophancy, and failure handling that prevents error propagation cascades.
37
38## Detailed Topics
39
40### Why Multi-Agent Architectures
41
42**The Context Bottleneck**
43Reach for multi-agent architectures when a single agent's context fills with accumulated history, retrieved documents, and tool outputs to the point where performance degrades. Recognize three degradation signals: the lost-in-middle effect (attention weakens for mid-context content), attention scarcity (too many competing items), and context poisoning (irrelevant content displaces useful content).
44
45Partition work across multiple context windows so each agent operates in a clean context focused on its subtask. Aggregate results at a coordination layer without any single context bearing the full burden.
46
47**The Token Economics Reality**
48Budget for substantially higher token costs. Production data shows multi-agent systems can cost far more tokens than single-agent chat (claim-multi-agent-token-multiplier):
49
50| Architecture | Token Multiplier | Use Case |
51|--------------|------------------|----------|
52| Single agent chat | Baseline | Simple queries |
53| Single agent with tools | Higher than baseline | Tool-using tasks |
54| Multi-agent system | Much higher than baseline | Complex research/coordination |
55
56Browsing-agent evaluation research suggests token usage, tool calls, and model choice dominate performance variance (claim-evaluation-browsecomp-variance). This supports measuring multi-agent setups against single-agent baselines instead of assuming extra agents help.
57
58Prioritize model selection alongside architecture design — upgrading to better models often provides larger performance gains than doubling token budgets. BrowseComp data shows that model quality improvements frequently outperform raw token increases. Treat model selection and multi-agent architecture as complementary strategies.
59
60**The Parallelization Argument**
61Assign parallelizable subtasks to dedicated agents with fresh contexts rather than processing them sequentially in a single agent. A research task requiring searches across multiple independent sources, analysis of different documents, or comparison of competing approaches benefits from parallel execution. Total real-world time approaches the duration of the longest subtask rather than the sum of all subtasks.
62
63**The Specialization Argument**
64Configure each agent with only the system prompt, tools, and context it needs for its specific subtask. A general-purpose agent must carry all possible configurations in context, diluting attention. Specialized agents carry only what they need, operating with lean context optimized for their domain. Route from a coordinator to specialized agents to achieve specialization without combinatorial explosion.
65
66### Architectural Patterns
67
68**Pattern 1: Supervisor/Orchestrator**
69Deploy a central agent that maintains global state and trajectory, decomposes user objectives into subtasks, and routes to appropriate workers.
70
71```
72User Query -> Supervisor -> [Specialist, Specialist, Specialist] -> Aggregation -> Final Output
73```
74
75Choose this pattern when: tasks have clear decomposition, coordination across domains is needed, or human oversight is important.
76
77Expect these trade-offs: strict workflow control and easier human-in-the-loop interventions, but the supervisor context becomes a bottleneck, supervisor failures cascade to all workers, and the "telephone game" problem emerges where supervisors paraphrase sub-agent responses incorrectly.
78
79**The Telephone Game Problem and Solution**
80Anticipate that supervisor architectures initially perform approximately 50% worse than optimized versions due to the telephone game problem (LangGraph benchmarks). Supervisors paraphrase sub-agent responses, losing fidelity with each pass.
81
82Fix this by implementing a forward_message tool that allows sub-agents to pass responses directly to users:
83
84```python
85def forward_message(message: str, to_user: bool = True):
86 """
87 Forward sub-agent response directly to user without supervisor synthesis.
88
89 Use when:
90 - Sub-agent response is final and complete
91 - Supervisor synthesis would lose important details
92 - Response format must be preserved exactly
93 """
94 if to_user:
95 return {"type": "direct_response", "content": message}
96 return {"type": "supervisor_input", "content": message}
97```
98
99Prefer swarm architectures over supervisors when sub-agents can respond directly to users, as this eliminates translation errors entirely.
100
101**Pattern 2: Peer-to-Peer/Swarm**
102Remove central control and allow agents to communicate directly based on predefined protocols. Any agent transfers control to any other through explicit handoff mechanisms.
103
104```python
105def transfer_to_agent_b():
106 return agent_b # Handoff via function return
107
108agent_a = Agent(
109 name="Agent A",
110 functions=[transfer_to_agent_b]
111)
112```
113
114Choose this pattern when: tasks require flexible exploration, rigid planning is counterproductive, or requirements emerge dynamically and defy upfront decomposition.
115
116Expect these trade-offs: no single point of failure and effective breadth-first scaling, but coordination complexity increases with agent count, divergence risk rises without a central state keeper, and robust convergence constraints become essential.
117
118Define explicit handoff protocols with state passing. Ensure agents communicate their context needs to receiving agents.
119
120**Pattern 3: Hierarchical**
121Organize agents into layers of abstraction: strategy (goal definition), planning (task decomposition), and execution (atomic tasks).
122
123```
124Strategy Layer (Goal Definition) -> Planning Layer (Task Decomposition) -> Execution Layer (Atomic Tasks)
125```
126
127Choose this pattern when: projects have clear hierarchical structure, workflows involve management layers, or tasks require both high-level planning and detailed execution.
128
129Expect these trade-offs: clear separation of concerns and support for different context structures at different levels, but coordination overhead between layers, potential strategy-execution misalignment, and complex error propagation paths.
130
131### Context Isolation as Design Principle
132
133Treat context isolation as the primary purpose of multi-agent architectures. Each sub-agent should operate in a clean context window focused on its subtask without carrying accumulated context from other subtasks.
134
135**Isolation Mechanisms**
136Select the right isolation mechanism for each subtask:
137
138- **Full context delegation** — Share the planner's entire context with the sub-agent. Use for complex tasks where the sub-agent needs complete understanding. The sub-agent has its own tools and instructions but receives full context for its decisions. Note: this partially defeats the purpose of context isolation.
139- **Instruction passing** — Create instructions via function call; the sub-agent receives only what it needs. Use for simple, well-defined subtasks. Maintains isolation but limits sub-agent flexibility.
140- **File system memory** — Agents read and write to persistent storage. Use for complex tasks requiring shared state. The file system serves as the coordination mechanism, avoiding context bloat from shared state passing. Introduces latency and consistency challenges but scales better than message-passing.
141
142Choose based on task complexity, coordination needs, and acceptable latency. Default to instruction passing and escalate to file system memory when shared state is needed. Avoid full context delegation unless the subtask genuinely requires it.
143
144### Consensus and Coordination
145
146**The Voting Problem**
147Avoid simple majority voting — it treats hallucinations from weak models as equal to reasoning from strong models. Without intervention, multi-agent discussions devolve into consensus on false premises due to inherent bias toward agreement.
148
149**Weighted Voting**
150Weight agent votes by confidence or expertise. Agents with higher confidence or domain expertise should carry more weight in final decisions.
151
152**Debate Protocols**
153Structure agents to critique each other's outputs over multiple rounds. Adversarial critique often yields higher accuracy on complex reasoning than collaborative consensus. Guard against sycophantic convergence where agents agree to be agreeable rather than correct.
154
155**Trigger-Based Intervention**
156Monitor multi-agent interactions for behavioral markers. Activate stall triggers when discussions make no progress. Detect sycophancy triggers when agents mimic each other's answers without unique reasoning.
157
158### Framework Considerations
159
160Different frameworks implement these patterns with different philosophies. LangGraph uses graph-based state machines with explicit nodes and edges. AutoGen uses conversational/event-driven patterns with GroupChat. CrewAI uses role-based process flows with hierarchical crew structures.
161
162## Practical Guidance
163
164### Failure Modes and Mitigations
165
166**Failure: Supervisor Bottleneck**
167The supervisor accumulates context from all workers, becoming susceptible to saturation and degradation.
168
169Mitigate by constraining worker output schemas so workers return only distilled summaries. Use checkpointing to persist supervisor state without carrying full history in context.
170
171**Failure: Coordination Overhead**
172Agent communication consumes tokens and introduces latency. Complex coordination can negate parallelization benefits.
173
174Mitigate by minimizing communication through clear handoff protocols. Batch results where possible. Use asynchronous communication patterns. Measure whether multi-agent coordination actually saves time versus a single agent with a longer context.
175
176**Failure: Divergence**
177Agents pursuing different goals without central coordination drift from intended objectives.
178
179Mitigate by defining clear objective boundaries for each agent. Implement convergence checks that verify progress toward shared goals. Set time-to-live limits on agent execution to prevent unbounded exploration.
180
181**Failure: Error Propagation**
182Errors in one agent's output propagate to downstream agents that consume that output, compounding into increasingly wrong results.
183
184Mitigate by validating agent outputs before passing to consumers. Implement retry logic with circuit breakers. Use idempotent operations where possible. Consider adding a verification agent that cross-checks critical outputs before they enter the pipeline.
185
186## Examples
187
188**Example 1: Research Team Architecture**
189```text
190Supervisor
191├── Researcher (web search, document retrieval)
192├── Analyzer (data analysis, statistics)
193├── Fact-checker (verification, validation)
194└── Writer (report generation, formatting)
195```
196
197**Example 2: Handoff Protocol**
198```python
199def handle_customer_request(request):
200 if request.type == "billing":
201 return transfer_to(billing_agent)
202 elif request.type == "technical":
203 return transfer_to(technical_agent)
204 elif request.type == "sales":
205 return transfer_to(sales_agent)
206 else:
207 return handle_general(request)
208```
209
210## Guidelines
211
2121. Design for context isolation as the primary benefit of multi-agent systems
2132. Choose architecture pattern based on coordination needs, not organizational metaphor
2143. Implement explicit handoff protocols with state passing
2154. Use weighted voting or debate protocols for consensus
2165. Monitor for supervisor bottlenecks and implement checkpointing
2176. Validate outputs before passing between agents
2187. Set time-to-live limits to prevent infinite loops
2198. Test failure scenarios explicitly
220
221## Gotchas
222
2231. **Supervisor bottleneck scaling** — Supervisor context pressure grows non-linearly with worker count. At 5+ workers, the supervisor spends more tokens processing summaries than workers spend on actual tasks. Set a hard cap on workers per supervisor (3-5) and add a second supervisor tier rather than overloading one.
2242. **Token cost underestimation** — Multi-agent runs cost approximately 15x baseline. Teams consistently underbudget because they estimate per-agent costs without accounting for coordination overhead, retries, and consensus rounds. Budget for 15x and treat anything less as a bonus.
2253. **Sycophantic consensus** — Agents in debate patterns tend to converge on agreeable answers, not correct ones. LLMs have an inherent bias toward agreement. Counter this by assigning explicit adversarial roles and requiring agents to state disagreements before convergence is allowed.
2264. **Agent sprawl** — Adding more agents past 3-5 shows diminishing returns and increases coordination overhead. Each additional agent adds communication channels quadratically. Start with the minimum viable number of agents and add only when a clear context isolation benefit exists.
2275. **Telephone game in message-passing** — Information degrades through repeated summarization as it passes between agents. Each agent paraphrases and loses nuance. Use filesystem coordination instead of message-passing for state that multiple agents need to access faithfully.
2286. **Error propagation cascades** — One agent's hallucination becomes another agent's "fact." Downstream agents have no way to distinguish upstream hallucinations from genuine information. Add validation checkpoints between agents and never trust upstream output without verification.
2297. **Over-decomposition** — Splitting tasks too finely creates more coordination overhead than the task itself. A 10-step pipeline with 10 agents spends more tokens on handoffs than on actual work. Decompose only when subtasks genuinely benefit from separate contexts.
2308. **Missing shared state** — Agents operating without a shared filesystem or state store duplicate work, produce inconsistent outputs, and lose track of what has already been accomplished. Establish shared persistent storage before building multi-agent workflows.
231
232## Integration
233
234This skill owns agent topology and coordination protocols. Adjacent skills own project shape, hosted runtime, and latent-state transfer:
235
236- project-development: project-level single-vs-multi choice before topology details.
237- hosted-agents: remote sandbox, session, warm-pool, and multiplayer infrastructure.
238- memory-systems: shared persistent state across agents.
239- tool-design: tool specialization and spawn/status tool contracts.
240- context-optimization: partitioning as one token-efficiency tactic.
241- latent-briefing: KV-cache trajectory handoff between orchestrator and worker when models align.
242- evaluation: measuring whether multiple agents improve outcomes after coordination cost.
243
244## References
245
246Internal reference:
247- [Frameworks Reference](./references/frameworks.md) - Read when: implementing a specific multi-agent pattern in LangGraph, AutoGen, or CrewAI and needing framework-specific code examples
248
249Related skills in this collection:
250- context-fundamentals - Read when: needing to understand context window mechanics before designing agent partitioning
251- memory-systems - Read when: agents need to share state across context boundaries or persist information between runs
252- context-optimization - Read when: individual agent contexts are too large and need partitioning or compression strategies
253
254External resources:
255- [LangGraph Documentation](https://langchain-ai.github.io/langgraph/) - Read when: building graph-based multi-agent workflows with explicit state machines
256- [AutoGen Framework](https://microsoft.github.io/autogen/) - Read when: implementing conversational GroupChat patterns or event-driven agent coordination
257- [CrewAI Documentation](https://docs.crewai.com/) - Read when: designing role-based hierarchical agent processes
258- [Research on Multi-Agent Coordination](https://arxiv.org/abs/2308.00352) - Read when: needing academic grounding on multi-agent system theory and evaluation
259
260---
261
262## Skill Metadata
263
264**Created**: 2025-12-20
265**Last Updated**: 2026-05-15
266**Author**: Agent Skills for Context Engineering Contributors
267**Version**: 2.1.0
268