AgentSkillsCN

Multi-Agent Orchestration

跨框架的多代理系统工作流模式。指引至RAG实现。

SKILL.md
--- frontmatter
name: Multi-Agent Orchestration
description: Workflow patterns for multi-agent systems across frameworks. Directs to RAG for implementation.

Multi-Agent Orchestration Workflow

Pattern Selection

PatternWhen to UseComplexityRAG Query
DelegationRoute to specialists by task typeLow"agent delegation routing"
SequentialPipeline with handoffsLow"sequential agent pipeline"
ParallelIndependent concurrent tasksMedium"parallel agent execution"
HierarchicalManager coordinates workersMedium"hierarchical agent manager"
MeshPeer-to-peer collaborationHigh"agent mesh communication"

Framework-Specific Patterns

ADK Multi-Agent

Uses sub_agents for delegation. RAG Query: mcp__agentic-rag__query_sdk("sub_agents delegation", sdk="adk", mode="build")

Key: Agent description drives routing decisions.

LangGraph Multi-Agent

Uses graph nodes for each agent, conditional edges for routing. RAG Query: mcp__agentic-rag__query_sdk("multi-agent graph", sdk="langgraph", mode="build")

Key: State must flow between agent nodes.

CrewAI Multi-Agent

Uses Crew with agents and tasks. RAG Query: mcp__agentic-rag__query_sdk("crew agents tasks", sdk="crewai", mode="build")

Key: Process type (sequential vs hierarchical) changes everything.

OpenAI Multi-Agent

Uses handoffs between agents. RAG Query: mcp__agentic-rag__query_sdk("agent handoff", sdk="openai", mode="build")

Key: Handoff descriptions determine routing.

Routing Strategy Decision

StrategyBest ForTradeoffRAG Query
KeywordSimple, predictable tasksBrittle"keyword routing"
LLM-basedComplex, nuanced routingSlower, costlier"llm routing classification"
SemanticSimilar intent detectionNeeds embeddings"semantic routing embedding"
Rule-basedDeterministic, auditableManual maintenance"rule based routing"

Critical Gotchas

These cause multi-agent failures:

  1. Vague descriptions - Agents won't be routed correctly if descriptions are generic
  2. Missing state passing - Context lost between agents
  3. Circular delegation - Agent A → B → A infinite loop
  4. No termination condition - Loops forever
  5. Sequential when could parallel - Unnecessary latency
  6. No error handling - One agent failure crashes system

State Sharing Patterns

PatternWhen to UseRAG Query
Shared dict/TypedDictSimple, synchronous"shared state dict"
Message historyConversational"message passing agents"
External storePersistence needed"agent state persistence"
Event busDecoupled agents"event driven agents"

Workflow: Building Multi-Agent System

Step 1: Define Agent Responsibilities

Each agent needs:

  • Clear, specific role
  • Well-defined capabilities
  • Distinct from other agents

Step 2: Choose Orchestration Pattern

Use table above to select pattern based on your workflow.

Step 3: Design Routing Logic

RAG Query: mcp__agentic-rag__search("[routing strategy] [framework]", mode="build")

Step 4: Implement State Sharing

RAG Query: mcp__agentic-rag__search("state sharing [framework]", mode="build")

Step 5: Add Termination Conditions

  • Max iterations
  • Goal achievement check
  • Timeout

Step 6: Error Handling

  • Fallback agents
  • Retry logic
  • Graceful degradation

Common Error Patterns

SymptomLikely CauseFix
Wrong agent calledVague descriptionMake descriptions specific
Infinite loopNo terminationAdd max iterations, goal check
Context lostNo state passingImplement state sharing
Slow responseSequential unnecessaryUse parallel where possible
One failure crashes allNo error handlingAdd try/catch, fallbacks

Performance Optimization

IssueSolutionRAG Query
LatencyParallel where possible"parallel agent optimization"
Token usageShorter agent contexts"agent context optimization"
Routing errorsBetter descriptions"agent description best practices"
State bloatPrune old messages"state management cleanup"