Overview
Level 3: Advanced · Module 16: Agent Frameworks and Multi-Agent Systems · 25 min read · Core Track
Last updated: November 2026
Multi-agent architectures—where multiple autonomous LLM instances collaborate, delegate, and critique each other—have captured enormous industry attention. Frameworks like LangGraph, the OpenAI Agents SDK, and Anthropic's multi-agent patterns allow engineers to construct specialized teams of agents communicating via Agent-to-Agent (A2A) protocols.
However, the mark of a senior or staff AI engineer is not knowing how to build a 5-agent swarm, but knowing when NOT to use multi-agent systems.
In this lesson, you will master the architecture of structured Agent-to-Agent communication protocols, and examine the rigorous decision framework that separates justified multi-agent architectures from costly, over-engineered anti-patterns.
1. Agent-to-Agent (A2A) Protocols
When agents delegate tasks to other agents, treating the handover as an unstructured, conversational chat message invites hallucination and data leakage. Production A2A communication requires a Structured Handover Contract:
┌─────────────────────────┐
│ Triage Router Agent │
└────────────┬────────────┘
│ Handoff Payload (JSON Schema)
▼
┌─────────────────────────┐
│ Specialist Sub-Agent │
│ (e.g., SQL Data Agent)│
└────────────┬────────────┘
│ Structured Result Artifact
▼
┌─────────────────────────┐
│ Synthesis Evaluator │
└─────────────────────────┘Anatomy of a Production A2A Message Frame
- Source & Target Identifiers: Explicit agent IDs (e.g.,
router$\rightarrow$sql_generator). - Context Scope: Pruned memory subset strictly necessary for the sub-task (preventing context bloat).
- Execution Guardrails: Max token budget, timeout, and allowed tool whitelist.
- Artifact Schema: Strict JSON schema defining the required return payload.
2. When NOT to Use Multi-Agent Systems
In technical system design interviews and architectural review boards, the most common trap candidates fall into is proposing a multi-agent system for a problem that is better solved by a deterministic algorithm or a single-turn prompt.
Engineering Decision Ladder:
Can this be solved with deterministic code (RegEx, SQL, AST parser)?
├── YES ──► Write deterministic code. (0 token cost, <2ms latency, 100% reliable)
└── NO
Can this be solved with a single well-structured prompt & Zod schema?
├── YES ──► Single LLM call with structured output.
└── NO
Can this be solved with a linear DAG or state machine (LangChain chain)?
├── YES ──► Deterministic pipeline.
└── NO ──► ONLY NOW consider a Multi-Agent System!The Real Costs of Multi-Agent Systems
- Latency Explosion: A 3-agent chain where each agent takes 2 turns involves $3 \times 2 = 6$ sequential LLM API calls. At 2 seconds per call, user latency balloons to 12 to 18 seconds.
- Compounding Probability of Failure: If each LLM step has a 95% accuracy rate: $$\text{Accuracy across 6 steps} = 0.95^6 = 73.5%$$ More than 1 out of 4 requests will fail or hallucinate!
- Cost Multiplication: Every agent turn re-sends prompt context, multiplying token bills by $3\times$ to $8\times$.
- Debugging Nightmares: Non-deterministic loops where Agent A and Agent B get into circular argumentation are notoriously difficult to reproduce and test in CI/CD.
The Comparison Matrix
| Problem Scenario | Recommended Architecture | Why Multi-Agent is an Anti-Pattern |
|---|---|---|
| Extracting address from receipt | Single LLM with Pydantic / Zod | Agents add latency and loop risks for a deterministic extraction task. |
| Customer Support FAQ Search | Hybrid RAG + Metadata Filter | RAG retrieves ground truth in 80ms; agents take 5 seconds. |
| Multi-turn Form Wizard | Deterministic State Machine (XState) | Hardcoded form flows must follow rigid business rules, not stochastic LLM choices. |
| Deep Research & Competitive Audit | Multi-Agent System Justified | Requires parallel web scraping, synthesizing contradictory claims, and multi-round critique. |
| Autonomous Repository Refactoring | Multi-Agent System Justified | Requires separate specialized personas: file lister, test runner, code writer, and git committer. |
Key Takeaways for Frontend Engineers
- Start with the Simplest Architecture: Default to single prompts with schema validation. Escalate to linear chains before ever proposing a multi-agent swarm.
- Enforce Hard Step Bounds: If you do build multi-agent handoffs, impose strict step limits (e.g.
maxSteps: 3) on sub-agents to avoid infinite loops and runaway billing. - Isolate Sub-Agent Context: Never pass the entire global conversation history into child workers. Prune the payload to the exact task specification.