Multi-Agent Architectures

Compare the main ways to organize multiple agents: sequential pipelines, parallel agents, supervisor agents, hierarchical teams and peer-to-peer networks, with a simple model of time and message cost.

30 minAdvancedCode Examples

The Core Idea: The shape of a team matters. Sequential chains are simple, parallel teams are fast, a supervisor adds control, a hierarchy scales to big jobs, and peer-to-peer networks give flexibility at the price of many messages.

  1. Beginner: Sequential Agents

In a sequential architecture, agents work one after another like a production line. The output of one agent is the input of the next: research, then write, then review.

StrengthsSimple
Easy to understand and debug
Each step has a clear input and output
Few messages: one handoff between steps
WeaknessesSlow
Total time is the sum of all steps
An early mistake flows to the end
No parallelism

Use when: Each step truly needs the result of the previous one.

  1. Beginner: Parallel Agents

In a parallel architecture, independent tasks go to several agents at the same time, and their results are combined afterwards (fan-out, then fan-in).

In the code: The six subtasks take 23 seconds in sequence but only 10 seconds with three parallel workers.

Needs: Tasks that do not depend on each other, and a way to merge the results without conflicts.

  1. Medium: Supervisor Agents

A supervisor agent receives the goal, splits it into tasks, delegates them to worker agents, collects the results and synthesizes the final answer. Workers do not need to know about each other.

1
Plan: The supervisor breaks down the goal.
2
Delegate: It sends each task to the best worker.
3
Collect: Workers return results.
4
Synthesize: The supervisor checks and merges them.

Benefit: One place for control, checks and error handling.

Cost: The supervisor is a bottleneck and a single point of failure, and it adds overhead. In the code the supervisor design takes 15 seconds, 5 more than pure parallel, because of planning, delegation and synthesis.

  1. Medium: Hierarchical Agents

For very large jobs one supervisor cannot manage everything. In a hierarchy, a top-level agent manages team leads, and each lead manages its own workers. It mirrors how companies are organized.

Fair comparison: In the code the hierarchy finishes in 9 seconds, faster than the 10-second parallel design, but it used six workers instead of three, and it sends the most messages among the manager designs. More workers cost more.

When it helps
Hierarchies keep each manager's context small, because a team lead only sees its own team's work. That is the main reason to use them.

  1. Advanced: Peer-to-Peer Agents and How to Choose

In a peer-to-peer (network) design, any agent can message any other without a central manager. It is flexible and has no single bottleneck, but messages grow fast: with nn agents, one round of everyone talking to everyone is n(n−1)n(n-1) messages.

ArchitectureTime (s)MessagesBest for
Sequential235Strictly ordered steps
Parallel1012Independent tasks
Supervisor15.012Control and quality checks
Hierarchical9.016Large jobs, small contexts per manager
Peer-to-peer10.024Open-ended collaboration and debate

Choose the simplest shape that works. Sequential or supervisor designs cover most real needs. Peer-to-peer designs are the hardest to predict and debug.

  1. Visual Explanation: Five Team Shapes Compared

The figure lists the five architectures with the time and message numbers from the code, then summarizes what each trade-off buys you.

Part 1 · The Five ShapesSame six subtasks
Sequential23 s
A → B → C → D
↓
5 messages
Parallel10 s
Workers at the same time
↓
12 messages
Supervisor15 s
Manager delegates and merges
↓
12 messages
Hierarchy9 s
Manager, leads, workers
↓
16 messages
Peer-to-peer10 s
Everyone talks to everyone
↓
24 messages
Part 2 · Trade-OffsWhat you gain and pay
Speed
Parallel work
Helps independent tasks.
Control
Supervisor
Checks and error handling.
Scale
Hierarchy
Small context per manager.
Complexity
Network
Hardest to predict.
Click to see why the hierarchy is faster hereCompare ▼
The hierarchy uses six workers while the parallel design uses three. With the same number of workers the comparison would look different. Always compare designs under equal resources.

Part 1 shows time and message count per design for the same six tasks. Part 2 lists the main trade-offs. Open the bar for an important caveat about the hierarchy.

  1. Python Implementation: A Simple Model of Time and Messages

This script computes the completion time and the number of messages for the same six subtasks under five architectures: sequential, parallel, supervisor, hierarchical and peer-to-peer. It is a simplified model with fixed overheads, meant to show the trade-offs.

architecture_comparison.pyPython 3.10+ · standard library only
# Compare multi-agent architectures on the same six subtasks (durations in seconds)tasks = [4, 3, 5, 2, 6, 3]workers = 3 def makespan(durations, n_workers):    loads = [0] * n_workers    for d in durations:        loads[loads.index(min(loads))] += d              # give the task to the least busy worker    return max(loads) def sequential():    return sum(tasks), len(tasks) - 1                    # each step hands over to the next def parallel():    return makespan(tasks, workers), len(tasks) * 2      # each task: start message and result message def supervisor():    plan, delegate, synthesize = 1.0, 0.5, 1.0    time = plan + delegate * len(tasks) + makespan(tasks, workers) + synthesize    return time, len(tasks) * 2 def hierarchical():    team_a, team_b = tasks[:3], tasks[3:]    time = 1.0 + 1.0 + max(makespan(team_a, 3), makespan(team_b, 3)) + 1.0     # top planner, team lead, work, merge    return time, 2 * 2 + len(tasks) * 2 def peer_to_peer(agents=4, rounds=2):    return makespan(tasks, agents) + rounds * 1.0, agents * (agents - 1) * rounds     # everyone talks to everyone print("Architecture".ljust(14), "time (s)".ljust(10), "messages")for name, fn in [("sequential", sequential), ("parallel", parallel), ("supervisor", supervisor), ("hierarchical", hierarchical), ("peer-to-peer", peer_to_peer)]:    time, msgs = fn()    print(name.ljust(14), str(time).ljust(10), msgs)
EXPECTED OUTPUT (your numbers may differ slightly)
Architecture time (s) messages
sequential 23 5
parallel 10 12
supervisor 15.0 12
hierarchical 9.0 16
peer-to-peer 10.0 24

Sequential is slowest but sends the fewest messages. Parallel is fast. The supervisor adds control overhead. The hierarchy and peer-to-peer designs are quick but use more workers or many more messages. The numbers come from the assumptions in the code, so change them and observe.

Knowledge Check

Question 1: What is the main weakness of a supervisor design?
Question 2: Why do peer-to-peer designs get expensive quickly?

Key Points

✓Sequential designs are simple but slow, and errors flow downstream.
✓Parallel designs are fast for independent tasks but need a merge step.
✓A supervisor delegates, collects and synthesizes. It gives control at the cost of overhead.
✓Hierarchies scale to large jobs and keep each manager's context small.
✓Peer-to-peer networks are flexible but message cost grows as n(n-1).
✓Choose the simplest architecture that works, and compare designs with equal resources.

The Big Picture

Architecture in One Line

Order for dependencies, parallel for speed, a supervisor for control, a hierarchy for scale

The best team shape is the simplest one that meets your quality and speed needs.

Up Next: Once you pick a shape, something has to run it. In Multi-Agent Orchestration you will study routing, delegation, coordination and shared state.