| name | aiase-multi-agent |
| description | Multi-agent patterns and team design — Orchestrator/Supervisor/Pipeline/Debate topologies, GAN-inspired Planner-Generator-Evaluator model, agent team coordination (Claude Code v2.1.32+), Skill vs. Sub-Agent decision framework, and the 4-layer agentic stack (L1 Skill → L2 MCP → L3 A2A → L4 CLI). Load when the user asks about multi-agent systems, agent teams, MCP, A2A protocol, or orchestration. |
Multi-Agent Patterns & Team Design
From AIASE 2026 (NCKU), Weeks 5–7. Patterns for building reliable multi-agent systems.
Skill vs. Sub-Agent Decision
"Does this operation need to decide what happens next?"
| Dimension | Skill | Sub-Agent |
|---|
| Nature | Deterministic tool/function | Autonomous reasoning agent |
| Control | Caller orchestrates | Self-directed agentic loop |
| Decision-making | None — pure execution | Yes — plan → act → observe |
| Verification | High (deterministic) | Low (probabilistic) |
| Cost | Low | High (7–15× multiplier) |
Rule: Use skills by default. Escalate to sub-agents only when true autonomy is required. Give each sub-agent a frozen, explicit task specification (like a work order).
Four Agent Topologies
Orchestrator-Subagent
[User Goal]
↓
[Orchestrator] ← Decomposes task
/ \
[Agent A] [Agent B] ← Each handles one specialization
When: Task decomposes cleanly; subagents are independent.
Supervisor (Dynamic Router)
Supervisor holds global state, routes to workers based on current situation.
When: Task is ambiguous or conditions change during execution.
Pipeline
Input → Extract → Clean → Analyze → Synthesize → Output
When: Clear sequential dependencies; each stage is atomic.
Debate Pattern
Two agents argue opposing positions; judge/mediator synthesizes.
When: High-stakes decisions; red-teaming code or designs; conflict resolution.
GAN-Inspired Three-Agent Model (W6)
| Role | Analogy | Responsibility |
|---|
| Planner | PM | Converts vague requirements into complete specs |
| Generator | Engineer | Implements incrementally via sprint cycles |
| Evaluator | QA | External testing (Playwright, curl, etc.) |
Key insight: Self-evaluation fails. Separate executor from evaluator — the same agent cannot reliably judge its own output.
Sprint Contract: Pre-development alignment on acceptance criteria prevents rework waste.
Agent Teams (Claude Code v2.1.32+)
Compared to legacy sub-agents:
| Feature | Legacy Sub-agents | Agent Teams |
|---|
| Communication | Unidirectional (→ Team Lead only) | Peer-to-peer via mailbox |
| Task list | Centralized | Shared with dependency tracking |
| Conflict resolution | Through Team Lead | Teammates resolve directly |
| File conflicts | Race condition risk | File lock mechanism |
Requires: Claude Code v2.1.32+, Opus 4.6+ model.
The 4-Layer Agentic Stack (OS Analogy, W7)
| Layer | OS Concept | Agent Implementation | Trust |
|---|
| L1: Intra-Process | Library call | Skill / Extension | Same process |
| L2: Vertical IPC | System call / RPC | MCP (Model Context Protocol) | Tool provider authorized |
| L3: Horizontal IPC | Network service | A2A Protocol (Agent-to-Agent) | Cross-org boundary |
| L4: Runtime | Shell process | CLI Agent (Pi, Claude CLI) | External orchestrator |
Decision Tree: Which Layer?
- "Package repeating workflows as reusable capability" → L1: Skill
- "Call external systems (DB, SaaS, API)" → L2: MCP
- "Independent agents collaborate across org boundaries" → L3: A2A
- "Shell-compose agent as Unix tool" → L4: CLI
Recommended Role Selection (agency-agents library)
| Role | Domain | Function |
|---|
| Agents Orchestrator | Specialized | Task dispatch, sprint planning, inter-agent coordination |
| Backend Architect | Engineering | API design, schema generation, OpenAPI specs |
| Security Engineer | Engineering | Threat modeling, security requirement implementation |
| DB Optimizer | Engineering | Schema design, indexing, performance tuning |
| MCP Builder | Specialized | MCP tool definition, whitelist management |
| API Tester | Testing | Security-focused test automation, regression |
| Reality Checker | Testing | Quality gate — validates spec and security compliance |
"A Reality Checker (quality gate) is often more valuable than adding more implementer agents."
Cost Implications
- Multi-agent systems cost 7–15× more than single-agent
- Only justified when: tasks are independent/parallel AND result value far exceeds cost
- Avoid when: shared context is required OR many inter-agent dependencies exist
Incremental Build Order
Always build single-agent first; never start with multi-agent. The 6-week progression (single tool → 3 tools → ReAct → memory → reflection → multi-agent) is documented in [[aiase-agent-fundamentals]] § Incremental Build Order. The multi-agent-specific rule: only decompose to multi-agent after a single reliable agent already exists.
Context Window Management in Multi-Agent
Each agent's context suffers the same 40% quality cliff and "Loss in the Middle" degradation as a single agent — but multiplied across the team. The full management playbook is in [[aiase-rpi]] § Context Window Management. The multi-agent-specific rule: sub-agents handle exploration; return only conclusions to the orchestrator's context.
See also: [[aiase-harness]] for harness structure, [[aiase-token-economics]] for cost implications, [[aiase-rpi]] for how to plan multi-agent work.