Lesson 11: Multi-Agent Orchestration
Coordinate multiple AI agents to work together on complex tasks, each specializing in different aspects.
The Multi-Agent Paradigm
Instead of one AI doing everything, multi-agent systems assign different roles to different "agents" (prompt instances), each specializing in a specific task. This mirrors how effective teams work — specialists collaborate to achieve more than any individual could.
Why Multi-Agent?
| Benefit | Description |
|---|---|
| Specialization | Each agent excels at one thing |
| Parallel Processing | Multiple agents work simultaneously |
| Quality | Specialist agents produce better outputs |
| Scalability | Easy to add more agents for new tasks |
| Maintainability | Easier to update individual agents |
Mental model: Think of multi-agent systems like a movie production — you have directors, writers, actors, editors, each an expert in their role, working together to create something none could alone.
Agent Role Design
Common Agent Roles
| Role | Responsibility | Example Prompts |
|---|---|---|
| Researcher | Gather information and data | "Research [topic] and provide key findings" |
| Planner | Create strategy and structure | "Based on research, create an action plan" |
| Writer | Generate content | "Write [content type] following this plan" |
| Editor | Review and improve quality | "Edit this content for accuracy and clarity" |
| Critic | Identify weaknesses | "Critique this work and suggest improvements" |
| Summarizer | Condense information | "Summarize this into key points" |
| Validator | Check facts and quality | "Verify these claims are accurate" |
Agent Communication Protocol
Agent A Output → Shared Memory → Agent B Input
Standardized format:
{
"agent_id": "researcher",
"task_id": "research-001",
"status": "complete",
"output": { ... },
"confidence": 0.85,
"next_agent": "planner"
}
Multi-Agent Patterns
Pattern 1: Pipeline
Agents work in sequence, each adding value:
Researcher → Planner → Writer → Editor → Publisher
Example: Content Creation Pipeline
Agent 1 (Researcher):
"Research the latest trends in [industry] for 2026.
Provide: 5 key trends with supporting data.
Output format: Structured brief"
Agent 2 (Planner):
"Based on this research: [Agent 1 output]
Create a content calendar for the next month.
Include: Topics, formats, target audience for each.
Output format: Calendar table"
Agent 3 (Writer):
"Using this calendar: [Agent 2 output]
Write the first post: [specific topic]
Include: Introduction, 3 main points, conclusion.
Output format: Blog post draft"
Agent 4 (Editor):
"Edit this draft: [Agent 3 output]
Check for: Accuracy, clarity, engagement, SEO.
Output format: Revised draft with change notes"
Agent 5 (Publisher):
"Format this final draft: [Agent 4 output]
Prepare for publication: Meta tags, featured image suggestion, social snippets.
Output format: Publication package"
Pattern 2: Debate
Multiple agents argue different perspectives, then synthesize:
Agent A: Argue FOR [position]
Agent B: Argue AGAINST [position]
Synthesizer: Create balanced analysis from both arguments
Example: Strategic Decision
Agent 1 (Proponent):
"Argue FOR expanding into the European market.
Provide: Benefits, opportunities, success factors.
Be persuasive and data-driven."
Agent 2 (Opponent):
"Argue AGAINST expanding into the European market.
Provide: Risks, challenges, potential failures.
Be realistic and evidence-based."
Agent 3 (Synthesizer):
"Based on these arguments:
FOR: [Agent 1 output]
AGAINST: [Agent 2 output]
Create a balanced strategic analysis:
1. Summarize key points from both sides
2. Identify areas of agreement/disagreement
3. Assess risk-reward balance
4. Provide conditional recommendation
5. List conditions that would change the recommendation"
Pattern 3: Voting
Multiple agents independently solve a problem, majority wins:
Agent 1: Solve [problem] → Answer A
Agent 2: Solve [problem] → Answer B
Agent 3: Solve [problem] → Answer A
Majority Vote: Answer A (2 out of 3)
Example: High-Stakes Decision
Problem: Should we acquire Company X?
Agent 1 (Financial Analyst):
Analyze from financial perspective.
Recommendation: [Buy/Don't Buy] with reasoning.
Agent 2 (Strategic Analyst):
Analyze from strategic fit perspective.
Recommendation: [Buy/Don't Buy] with reasoning.
Agent 3 (Risk Analyst):
Analyze from risk perspective.
Recommendation: [Buy/Don't Buy] with reasoning.
Meta-Agent (Decision Maker):
Review all three analyses.
If unanimous → Final decision
If split → Identify key disagreements and escalate
Pattern 4: Ensemble
Multiple agents work on same task, results are averaged or combined:
Agent 1: Write headline option 1
Agent 2: Write headline option 2
Agent 3: Write headline option 3
Curator: Select best elements from each, create final version
Managing Shared State
Shared Memory Structure:
{
"project_id": "content-creation-001",
"current_step": "writing",
"state": {
"research": { ... },
"outline": { ... },
"drafts": [...],
"edits": [...]
},
"agents": {
"researcher": { "status": "complete", "output": {...} },
"writer": { "status": "in-progress", "output": null },
"editor": { "status": "waiting", "output": null }
}
}
State Management Rules:
- Each agent reads only what it needs
- Each agent writes only its designated output
- State transitions are explicit and logged
- Conflicts are resolved by priority rules
Common Multi-Agent Mistakes
- Mistake: Too many agents — Fix: Each agent should have a clear, distinct purpose.
- Mistake: Agents that depend on each other running in parallel — Fix: Map dependencies first.
- Mistake: No central coordination — Fix: Use a meta-agent or orchestrator.
- Mistake: Inconsistent output formats — Fix: Define standard interfaces.
- Mistake: Not handling agent failures — Fix: Plan for each agent to fail gracefully.
Professional Tips & Tricks
- Start with 2-3 agents, add more only as needed.
- Use a meta-agent to coordinate and handle errors.
- Log all agent interactions for debugging.
- Test with known inputs first to verify agent behavior.
Key Takeaways
- Multi-agent systems assign specialized roles to different prompt instances.
- Pipeline, debate, voting, and ensemble are common patterns.
- Shared state management is critical for coordination.
- Each agent should have clear inputs, outputs, and responsibilities.
- Start simple, add complexity only as needed.
Next up: Real-world applications and case studies.
# Multi-Agent Orchestration Patterns
## Agent Role Templates
### Researcher Agent
"You are a research specialist. Your task:
- Gather comprehensive information on [topic]
- Verify facts and cite sources
- Identify key insights and trends
- Output: Structured research brief"
### Writer Agent
"You are a content writer. Your task:
- Create [content type] based on provided brief
- Follow brand guidelines and tone
- Include engaging hooks and clear structure
- Output: Complete draft"
### Editor Agent
"You are an editor. Your task:
- Review content for accuracy, clarity, engagement
- Check grammar, style, and consistency
- Suggest specific improvements
- Output: Revised version with change notes"
## Pipeline Pattern
Researcher → Planner → Writer → Editor → Publisher
## Debate Pattern
Agent A: Argue FOR
Agent B: Argue AGAINST
Synthesizer: Balanced analysis
## Voting Pattern
Agent 1: Solve → Answer A
Agent 2: Solve → Answer B
Agent 3: Solve → Answer A
Majority: Answer A (2/3)
## Shared State Structure
{
"project_id": "unique-id",
"current_step": "step-name",
"state": { ... },
"agents": {
"agent-name": {
"status": "complete|in-progress|waiting",
"output": { ... }
}
}
}Lesson Code (Python)
# Multi-Agent Orchestration Patterns
## Agent Role Templates
### Researcher Agent
"You are a research specialist. Your task:
- Gather comprehensive information on [topic]
- Verify facts and cite sources
- Identify key insights and trends
- Output: Structured research brief"
### Writer Agent
"You are a content writer. Your task:
- Create [content type] based on provided brief
- Follow brand guidelines and tone
- Include engaging hooks and clear structure
- Output: Complete draft"
### Editor Agent
"You are an editor. Your task:
- Review content for accuracy, clarity, engagement
- Check grammar, style, and consistency
- Suggest specific improvements
- Output: Revised version with change notes"
## Pipeline Pattern
Researcher → Planner → Writer → Editor → Publisher
## Debate Pattern
Agent A: Argue FOR
Agent B: Argue AGAINST
Synthesizer: Balanced analysis
## Voting Pattern
Agent 1: Solve → Answer A
Agent 2: Solve → Answer B
Agent 3: Solve → Answer A
Majority: Answer A (2/3)
## Shared State Structure
{
"project_id": "unique-id",
"current_step": "step-name",
"state": { ... },
"agents": {
"agent-name": {
"status": "complete|in-progress|waiting",
"output": { ... }
}
}
}Console Output
Multi-Agent Orchestration Patterns
## Agent Role Templates
### Researcher Agent
"You are a research specialist. Your task:
- Gather comprehensive information on [topic]
- Verify facts and cite sources
- Identify key insights and trends
- Output: Structured research brief"
### Writer Agent
"You are a content writer. Your task:
- Create [content type] based on provided brief
- Follow brand guidelines and tone
- Include engaging hooks and clear structure
- Output: Complete draft"
### Editor Agent
"You are an editor. Your task:
- Review content for accuracy, clarity, engagement
- Check grammar, style, and consistency
- Suggest specific improvements
- Output: Revised version with change notes"
## Pipeline Pattern
Researcher → Planner → Writer → Editor → Publisher
## Debate Pattern
Agent A: Argue FOR
Agent B: Argue AGAINST
Synthesizer: Balanced analysis
## Voting Pattern
Agent 1: Solve → Answer A
Agent 2: Solve → Answer B
Agent 3: Solve → Answer A
Majority: Answer A (2/3)
## Shared State Structure
{
"project_id": "unique-id",
"current_step": "step-name",
"state": { ... },
"agents": {
"agent-name": {
"status": "complete|in-progress|waiting",
"output": { ... }
}
}
}Code Visualization Tips
- Draw architecture diagrams for each multi-agent pattern.
- Create a flowchart showing agent communication and state flow.
- Map out a complete multi-agent workflow with error handling.
Professional Tips & Tricks
- Start with 2-3 agents, add more only as needed.
- Use a meta-agent to coordinate and handle errors.
- Log all agent interactions for debugging.
Python Code Judge & Practice Arena
LeetCode StyleRun real Python 3.12 WebAssembly code directly in your browser against automated test suites.
Multi-Agent System Design
Test Your Knowledge
Instant feedbackQuick Check: Multi-Agent Orchestration
Up next · Continue learning
Real-World Applications & Case Studies
Apply everything you've learned to real-world scenarios: content creation, customer service, data analysis, and more.