D1 · Agentic Architecture › Cluster 4 · Multi-Agent

4.6 · Parallel vs. Sequential Execution

Independent → parallel · dependent → sequential

CONCEPT Dependency decides the shape

Whether sub-agents run at the same time or one-after-another is dictated by dependency, not preference. If a sub-task needs another's output, it must wait — that's sequential. If sub-tasks are independent, run them in parallel to cut wall-clock time. Sequential agents add latency additively; parallel agents overlap, so the total is roughly the slowest one.

CaseRun howWall-clockExample
Independent sub-tasksParallel (fan-out)≈ max(sub-tasks)Research 8 companies at once
Dependent sub-tasksSequential (pipeline)≈ sum(sub-tasks)research → outline → draft → edit
🔑 Parallelise independent agents to cut wall-clock. You can't parallelise a dependency — if step B needs step A's output, B waits for A regardless.

CONCEPT The latency math

Say three sub-tasks take 4s, 6s, and 5s.

Parallel only helps if the sub-tasks are truly independent. If B depends on A, you're forced into A-then-B and pay 4 + 6 no matter what. Token cost is the same either way (same work) — parallelism buys time, not tokens.

⚠️ Parallel fan-out saves wall-clock but not money: you still run every sub-agent, so total tokens are unchanged. Choose parallel for latency, not to reduce cost.

DIAGRAM Both shapes side by side

flowchart TB subgraph SEQ["Sequential (dependent) — Σ ≈ 15s"] direction LR A1["A · 4s"] --> B1["B · 6s"] --> C1["C · 5s"] --> D1(["done ~15s"]) end subgraph PAR["Parallel (independent) — max ≈ 6s"] direction TB S(["start"]) --> A2["A · 4s"] S --> B2["B · 6s"] S --> C2["C · 5s"] A2 --> M(["merge ~6s"]) B2 --> M C2 --> M end classDef p fill:#e2d4f0,stroke:#764ba2,color:#3d1a5b; classDef g fill:#d4edda,stroke:#28a745,color:#155724; class A1,B1,C1,A2,B2,C2 p; class D1,M g;

CODE Fan-out independent sub-agents concurrently

Independent specialist calls run in threads; wall-clock collapses to the slowest one.

from concurrent.futures import ThreadPoolExecutor

def research(company):
    r = client.messages.create(
        model="claude-sonnet-4-6", max_tokens=1024,
        system="You are a research specialist.",
        messages=[{"role": "user", "content": f"Profile: {company}"}],
    )
    return company, "".join(b.text for b in r.content if b.type == "text")

companies = ["Acme", "Globex", "Initech", "Umbrella"]   # independent → parallel

# Parallel: wall-clock ≈ the single slowest call, not the sum.
with ThreadPoolExecutor(max_workers=len(companies)) as pool:
    findings = dict(pool.map(research, companies))

# Sequential would be: for c in companies: research(c)  → latency adds up.
# A DEPENDENT step (needs all findings) must wait — run it after the fan-out.
summary = client.messages.create(
    model="claude-opus-4-8", max_tokens=2048,
    messages=[{"role": "user",
               "content": f"Synthesize these profiles:\n{findings}"}],   # depends on all → sequential
)

TRADE-OFFS Parallel vs. sequential

✅ Parallel (independent)

  • Cuts wall-clock to ≈ the slowest sub-task
  • Great for wide, independent fan-out
  • Same token cost, far less waiting

⚠️ Sequential (dependent)

  • Latency is additive — sums up across stages
  • Required when a stage needs a prior output
  • Simpler to reason about and trace

EXAM TRAPS

Trap: "Parallelise everything for speed." → Only independent sub-tasks parallelise. A dependent step must wait for its input; parallelism can't beat a data dependency.
Trap: Thinking parallel fan-out saves money. → It saves wall-clock, not tokens. You still run every sub-agent; cost is unchanged.
Trap: Forgetting sequential latency is additive. → A 4-stage pipeline pays the sum of all stages. If the stages were independent, fan-out would collapse that to the slowest one.

PRACTICE

Q1 · Three sub-tasks take 3s, 8s, 4s and are independent. Parallel wall-clock?

≈ 8s — the slowest one. Sequential would be 3 + 8 + 4 = 15s. Independence lets them overlap.

Q2 · A pipeline is research → outline → draft. Can you parallelise it to go faster?

No — each stage depends on the previous one's output, so it must run sequentially. Latency stays additive; there's no independence to exploit.

Q3 · A manager wants parallel fan-out "to lower our bill." Right reason?

No. Fan-out reduces latency, not token cost — the same sub-agents run either way. Use it to cut wall-clock, not spend.