multi-agent-patterns
Master orchestrator, peer-to-peer, and hierarchical multi-agent architectures
Best use case
multi-agent-patterns is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Master orchestrator, peer-to-peer, and hierarchical multi-agent architectures
Teams using multi-agent-patterns should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/multi-agent-patterns/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How multi-agent-patterns Compares
| Feature / Agent | multi-agent-patterns | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Master orchestrator, peer-to-peer, and hierarchical multi-agent architectures
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Multi-Agent Architecture Patterns
Distribute work across multiple LM instances w/ isolated context windows. Sub-agents exist to isolate context, not to anthropomorphize roles.
## When to Activate
- Single-agent context limits constrain task complexity
- Tasks decompose into parallel subtasks
- Different subtasks need different tools | system prompts
- Building multi-domain agent systems
## Core Concepts
Three patterns: supervisor/orchestrator (centralized), peer-to-peer/swarm (flexible handoffs), hierarchical (layered abstraction). Key principle: context isolation — sub-agents partition context, not simulate org roles. Requires explicit coordination protocols & consensus mechanisms avoiding sycophancy.
## Token Economics
| Architecture | Token Multiplier | Use Case |
|---|---|---|
| Single agent | 1x | Simple queries |
| Agent w/ tools | ~4x | Tool-using tasks |
| Multi-agent | ~15x | Complex research/coordination |
BrowseComp: token usage explains 80% of performance variance. Model upgrades often outperform doubling token budgets — model selection & multi-agent architecture are complementary.
## Parallelization
Tasks w/ independent subtasks: assign each to dedicated agent w/ fresh context. All work simultaneously -> total time approaches longest subtask, not sum of all.
## Architectural Patterns
### Pattern 1: Supervisor/Orchestrator
```
User Query -> Supervisor -> [Specialist, Specialist, Specialist] -> Aggregation -> Final Output
```
**Use when:** Clear decomposition, cross-domain coordination, human oversight needed
**Pros:** Strict workflow control, easier human-in-the-loop
**Cons:** Supervisor context bottleneck, cascade failures, "telephone game" problem
**Telephone Game Fix:** `forward_message` tool lets sub-agents pass responses directly to users:
```python
def forward_message(message: str, to_user: bool = True):
"""Forward sub-agent response directly to user w/o supervisor synthesis."""
if to_user:
return {"type": "direct_response", "content": message}
return {"type": "supervisor_input", "content": message}
```
### Pattern 2: Peer-to-Peer/Swarm
Agents communicate directly via handoff mechanisms. No central control.
```python
def transfer_to_agent_b():
return agent_b # Handoff via fn return
agent_a = Agent(name="Agent A", functions=[transfer_to_agent_b])
```
**Use when:** Flexible exploration, emergent requirements
**Pros:** No single point of failure, scales for breadth-first exploration
**Cons:** Coordination complexity grows w/ agent count, divergence risk
### Pattern 3: Hierarchical
```
Strategy Layer (Goals) -> Planning Layer (Decomposition) -> Execution Layer (Atomic Tasks)
```
**Use when:** Large-scale projects, enterprise workflows, mixed high/low-level tasks
**Pros:** Clear separation of concerns, different context per level
**Cons:** Inter-layer coordination overhead, strategy-execution misalignment
## Context Isolation
Primary purpose of multi-agent architecture. Three mechanisms:
- **Full context delegation:** Planner shares entire context -> max capability but defeats isolation purpose
- **Instruction passing:** Planner creates instructions via fn call -> maintains isolation, limits flexibility
- **File system memory:** Agents read/write persistent storage -> shared state w/o context bloat, adds latency
## Consensus & Coordination
- **Weighted voting:** Weight by confidence/expertise (not simple majority)
- **Debate protocols:** Adversarial critique > collaborative consensus for complex reasoning
- **Trigger-based intervention:** Stall triggers (no progress), sycophancy triggers (mimicked answers)
## Failure Modes
| Failure | Mitigation |
|---|---|
| Supervisor bottleneck | Output schema constraints, workers return distilled summaries, checkpointing |
| Coordination overhead | Clear handoff protocols, batch results, async communication |
| Divergence | Objective boundaries per agent, convergence checks, TTL limits |
| Error propagation | Validate outputs before passing, retry w/ circuit breakers, idempotent ops |
## Examples
```text
Supervisor
├── Researcher (web search, doc retrieval)
├── Analyzer (data analysis, statistics)
├── Fact-checker (verification)
└── Writer (report generation)
```
```python
def handle_customer_request(request):
if request.type == "billing":
return transfer_to(billing_agent)
elif request.type == "technical":
return transfer_to(technical_agent)
elif request.type == "sales":
return transfer_to(sales_agent)
else:
return handle_general(request)
```
## Guidelines
1. Design for context isolation as primary benefit
2. Choose pattern by coordination needs, not org metaphor
3. Explicit handoff protocols w/ state passing
4. Weighted voting | debate for consensus
5. Monitor supervisor bottlenecks, use checkpointing
6. Validate outputs between agents
7. Set TTL limits to prevent infinite loops
8. Test failure scenarios explicitly
## Integration
Builds on context-fundamentals & context-degradation:
- memory-systems — shared state across agents
- tool-design — tool specialization per agent
- context-optimization — context partitioning strategies
## References
- [LangGraph](https://langchain-ai.github.io/langgraph/) — Multi-agent patterns & state management
- [AutoGen](https://microsoft.github.io/autogen/) — GroupChat & conversational patterns
- [CrewAI](https://docs.crewai.com/) — Hierarchical agent processes
- [Multi-Agent Coordination Survey](https://arxiv.org/abs/2308.00352)Related Skills
swiftui-patterns
SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.
vercel-composition-patterns
React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
web-quality
Web quality optimization skills based on Google Lighthouse guidelines and Core Web Vitals. Use when asked to audit web quality, optimize performance, improve accessibility, fix SEO, apply best practices, or analyze Core Web Vitals (LCP, INP, CLS).
vercel-react-native-skills
React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.
upgrade-packages-js
Safely upgrade JavaScript packages with breaking change detection, migration guidance, and automated code migrations (npm/pnpm/yarn). Cross-platform with git safety branch enforcement.
uiux-toolkit
Comprehensive UX/UI evaluation meta-skill combining design theory and UX methodology. Use when conducting UI/UX audits, visual design reviews, accessibility compliance (WCAG 2.2), user flow analysis, responsive testing, interaction design evaluation, or design system audits. Evaluates using Nielsen's heuristics, Gestalt principles, typography theory, color theory, and modern methodologies (OOUX, JTBD, Cognitive Walkthrough).
ui-ux-pro-max
UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 9 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient. Integrations: shadcn/ui MCP for component search and examples.
trailofbits-security
Security-focused static analysis and code auditing skills from Trail of Bits. Includes CodeQL deep analysis, Semgrep scanning, and SARIF result processing. Use when performing security audits, running static analysis, scanning for vulnerabilities, or processing scan results.
token-optimizer
Reduce token count in prompts, docs, and prose. Covers prompt compression (40-60% savings), doc formatting, TOON data serialization, and Strunk's prose clarity rules. Use when compressing prompts, optimizing docs for LLM context, or writing clear technical prose.
testing-automation-expert
Production-grade testing strategies for robust, maintainable systems. Covers unit/integration/E2E testing, contract testing, accessibility, mutation testing, and CI/CD patterns. Supports Python (pytest) and TypeScript (Jest/Vitest/Playwright).
test-levels
This skill explains the 3 test levels (Unit, Integration, E2E) using the "Building a Car" analogy and provides guidance on when to use each type. Includes project-specific Playwright examples.