Week 15 • Day 1Week 15

Day 1:When Single-Agent Beats Multi-Agent & Topology Mathematics

Battle-tested daily lesson note • 100% runnable code, interview Q&A, test suite & interactive quiz

Day 1: When Single-Agent Beats Multi-Agent & Topology Mathematics

1. First-Principles Rule: Don't Default to Multi-Agent!

In production AI Engineering, the biggest mistake junior engineers make is splitting a task across 5 conversational agents when 1 well-prompted agent with 6 clean tools would solve it with 3x lower latency and 4x higher reliability.

Compounding Handoff Error Law

If each agent-to-agent handoff has an independent probability pp of preserving all critical context and selecting the right next step (e.g., p=0.92p = 0.92), then across HH sequential handoffs: P(End-to-End Success)=pHP(\text{End-to-End Success}) = p^H For H=6H = 6 handoffs at p=0.92p = 0.92: P(Success)=0.926≈60.6%P(\text{Success}) = 0.92^6 \approx 60.6\%


2. Multi-Agent Topologies & Coordination Overhead

  1. Single Agent + Semantic Tool Router: H=1H = 1, zero inter-agent serialization overhead. Best when tools <15< 15 (after routing) and instructions fit cleanly in one system prompt.
  2. Supervisor-Worker (Star Topology): Central Supervisor delegates sub-tasks to KK domain specialists (DB, K8s, Net) and synthesizes results. Communication edges scale linearly: E=KE = K.
  3. Sequential DAG Pipeline: Deterministic stage-by-stage handoff (A1→A2→⋯→AKA_1 \to A_2 \to \dots \to A_K). Zero routing ambiguity, high serial latency Ltotal=∑i=1KLiL_{\text{total}} = \sum_{i=1}^K L_i.
  4. Full Mesh / Swarm: Any agent can message any other agent. Potential communication edges scale quadratically: Emesh=K(K−1)2E_{\text{mesh}} = \frac{K(K - 1)}{2} Without strict hop caps, Full Mesh topologies suffer from infinite conversational ping-pong.

In Simple English: Why More Agents Often Means LOWER Reliability (pHp^H Math)

Before building a flashy 8-agent swarm, check the math formula P(Success)=pHP(\text{Success}) = p^H:

  • Suppose each agent handoff works 92% of the time (p=0.92p = 0.92) — sounds super high, right?
  • Pass a task sequentially through H=6H = 6 agent hops (Planner -> Researcher -> Coder -> Tester -> Reviewer -> Publisher): 0.92×0.92×0.92×0.92×0.92×0.92=60.6%0.92 \times 0.92 \times 0.92 \times 0.92 \times 0.92 \times 0.92 = \mathbf{60.6\%} Nearly 4 out of 10 runs fail somewhere along the chain!
  • Also notice Mesh Communication E=K(K−1)2E = \frac{K(K-1)}{2}: 6 talking agents need 15 chat channels, whereas a Supervisor-Worker tree needs only 6 clean channels!
  • Staff Engineer Rule: Start with 1 well-equipped agent. Split into multiple agents ONLY when context pollution, conflicting tool permissions, or parallel speedups clearly justify the handoff tax!