Lesson 5 of 6·10 min read

Designing Multi-Agent Systems

When a task is too complex for a single agent, distribute the work across specialized agents. Multi-agent systems combine the strengths of different agents — similar to a team with different roles.

When Multi-Agent?

ScenarioSingle AgentMulti-Agent
Answering FAQOverkill
Writing + reviewing code⚠️✅ (Writer + Reviewer)
Research + analysis + report✅ (Specialized agents)
Complex workflow with approval✅ (Worker + Supervisor)

Communication Patterns

1. Hierarchical (Boss → Worker)

An orchestrator agent delegates tasks to specialized worker agents.

CEO Agent
├── Research Agent → Collect data
├── Analysis Agent → Evaluate data
└── Writer Agent → Create report

Advantages: Clear control, easy debugging Disadvantages: Bottleneck at orchestrator, single point of failure

2. Peer-to-Peer (Agent ↔ Agent)

Agents communicate directly with each other without central control.

Advantages: Decentralized, scalable Disadvantages: Harder to debug, consensus finding complex

3. Pipeline (Agent → Agent → Agent)

Agents work sequentially — one agent's output is the next agent's input.

Advantages: Easy to understand, reproducible Disadvantages: No parallelization, errors propagate

Delegation Patterns

Task Decomposition

The orchestrator breaks the task into subtasks and assigns them to specialists.

Skill-Based Routing

Requests are routed to the appropriate agent based on skill profiles.

Consensus / Voting

Multiple agents work on the same task. The final answer is determined by voting or merging — improves quality for critical decisions.

Design Principles

  1. Specialization: Each agent has a clearly defined role and competency
  2. Loose Coupling: Agents communicate via defined interfaces, not internal states
  3. Fail-Safe: When an agent fails, the system must degrade gracefully
  4. Observability: Every agent interaction is logged and traceable
  5. Bounded Autonomy: Clear boundaries for each agent — what can it do, what can't it?

Message Format

interface AgentMessage {
  from: string        // Sender agent
  to: string          // Receiver agent
  type: 'task' | 'result' | 'question' | 'escalation'
  content: string     // Content
  context: object     // Relevant context
  priority: number    // Urgency
}

Practical tip: Start with the hierarchical pattern — one orchestrator + 2 workers. Only consider more complex topologies once you've mastered communication.