$npx -y skills add DevelopersGlobal/ai-agent-skills --skill multi-agent-orchestrationDesigns and coordinates multi-agent pipelines where specialized agents collaborate to complete complex tasks. Includes communication protocols, failure handling, and state management.
| 1 | ## Overview |
| 2 | |
| 3 | Single agents are limited by context window, specialization depth, and parallelism. Multi-agent systems overcome these limits by routing subtasks to specialized agents. But multi-agent systems introduce new failure modes: lost context, conflicting decisions, infinite loops, and cascading failures. |
| 4 | |
| 5 | This skill provides the architecture and coordination patterns to build multi-agent systems that are reliable, observable, and maintainable. |
| 6 | |
| 7 | ## When to Use |
| 8 | |
| 9 | - The task requires more context than a single agent can handle |
| 10 | - Different subtasks require different specializations (research, coding, review, security) |
| 11 | - Subtasks can be parallelized for speed |
| 12 | - The workflow is long-running and requires checkpointing |
| 13 | - Different tasks require different levels of human oversight |
| 14 | |
| 15 | ## Process |
| 16 | |
| 17 | ### Step 1: Design the Agent Network |
| 18 | |
| 19 | 1. **Define agent responsibilities**: Each agent should have a single, well-defined job. Name them by role: `researcher`, `coder`, `reviewer`, `security-auditor`, `tester`. |
| 20 | 2. **Define communication topology**: Who can talk to whom? |
| 21 | - **Pipeline**: Agent A → Agent B → Agent C (sequential) |
| 22 | - **Supervisor**: Orchestrator dispatches to specialists (hub-and-spoke) |
| 23 | - **Peer**: Agents collaborate as equals (mesh) |
| 24 | 3. **Define data contracts**: What does each agent receive? What does it output? Use structured formats (JSON schemas) for inter-agent communication. |
| 25 | 4. **Define the orchestration logic**: Who decides which agent acts next? |
| 26 | |
| 27 | **Verify:** You can draw the agent network on a whiteboard with clear roles and data flow. |
| 28 | |
| 29 | ### Step 2: Implement Context Management |
| 30 | |
| 31 | 5. Each agent should receive **only the context it needs** — not the full conversation history. |
| 32 | 6. Use a shared state store (database, key-value store) for information that multiple agents need. |
| 33 | 7. Pass **summaries**, not full transcripts, when context must traverse agent boundaries. |
| 34 | 8. Include a **task ID** in every message for tracing. |
| 35 | |
| 36 | **Verify:** No agent receives more context than it requires for its specific task. |
| 37 | |
| 38 | ### Step 3: Design for Failure |
| 39 | |
| 40 | 9. **Every agent call can fail** — plan for it: |
| 41 | - Timeout with a defined maximum duration |
| 42 | - Retry with exponential backoff (max 3 retries) |
| 43 | - Fallback behavior when retries are exhausted |
| 44 | 10. **Prevent infinite loops**: Track call depth. If depth > N (e.g., 10), surface to human review. |
| 45 | 11. **Checkpointing**: For long workflows, save state after each major step so the workflow can be resumed after failure. |
| 46 | 12. **Dead letter queue**: Failed tasks that exhaust retries go to a queue for human inspection. |
| 47 | |
| 48 | **Verify:** Failure scenarios are defined for every agent-to-agent call. |
| 49 | |
| 50 | ### Step 4: Human-in-the-Loop Checkpoints |
| 51 | |
| 52 | 13. Define which decisions require human approval: |
| 53 | - Irreversible actions (data deletion, financial transactions, external communications) |
| 54 | - High-uncertainty states (agents disagree, confidence below threshold) |
| 55 | - Sensitive operations (PII access, privileged system access) |
| 56 | 14. Design the human review interface: What information does the reviewer need? What actions can they take? |
| 57 | |
| 58 | **Verify:** At least one human-in-the-loop checkpoint exists for high-risk operations. |
| 59 | |
| 60 | ### Step 5: Observability |
| 61 | |
| 62 | 15. Log every agent invocation: inputs, outputs, duration, token usage, errors. |
| 63 | 16. Implement distributed tracing across the agent network (trace ID propagated through all calls). |
| 64 | 17. Dashboard: agent activity, success/failure rates, latency, token consumption. |
| 65 | 18. Alerts: agent down, retry rate spike, context overflow, unexpected output patterns. |
| 66 | |
| 67 | **Verify:** You can trace any specific task's full execution path across all agents from logs alone. |
| 68 | |
| 69 | ## Common Rationalizations (and Rebuttals) |
| 70 | |
| 71 | | Excuse | Rebuttal | |
| 72 | |--------|----------| |
| 73 | | "One agent is simpler" | Until it hits context limits, fails silently, or produces wrong results. Multi-agent is the right tool for complex tasks. | |
| 74 | | "We'll add observability later" | Multi-agent systems without observability are black boxes. Debug them in production — I dare you. | |
| 75 | | "Agents are smart, they'll figure it out" | Agents are tools. They need clear roles, contracts, and failure boundaries. | |
| 76 | | "The happy path works fine" | Multi-agent systems fail in complex ways. Design for failure from day one. | |
| 77 | |
| 78 | ## Red Flags |
| 79 | |
| 80 | - Agents pass full conversation history to other agents (context bloat) |
| 81 | - No timeout defined for any agent call |
| 82 | - Agents can call each other recursively without depth limits |
| 83 | - No human approval required for irreversible actions |
| 84 | - No distributed tracing across agent boundaries |
| 85 | - Agents making conflicting state changes with no conflict resolution |
| 86 | |
| 87 | ## Verification |
| 88 | |
| 89 | - [ ] Agent network desi |