AgentSkillsCN

Multi-Agent Orchestration

协调多个 AI 代理,共同完成复杂任务——分解、委派与综合。

SKILL.md
--- frontmatter
name: "Multi-Agent Orchestration"
description: "Coordinate multiple AI agents for complex tasks — decomposition, delegation, and synthesis"
applyTo: "**/*agent*,**/*orchestrat*,**/*multi*,**/*workflow*,**/*subagent*"

Multi-Agent Orchestration Skill

Decompose complex problems into agent-appropriate subtasks, delegate effectively, and synthesize results.

⚠️ Rapid Evolution Domain

Multi-agent patterns are evolving rapidly. This skill captures stable patterns while acknowledging the field is in flux.

Refresh triggers:

  • New orchestration frameworks (LangGraph, AutoGen, CrewAI releases)
  • Claude/GPT native multi-agent features
  • VS Code Copilot agent architecture changes

Last validated: February 2026


Core Concepts

When to Use Multi-Agent

ScenarioSingle AgentMulti-Agent
Simple code edit❌ Overkill
Multi-file refactor✅ (if capable model)⚠️ Consider
Research + implement⚠️ Long context✅ Decompose
Cross-domain task❌ Context overload✅ Specialists
Parallel independent work❌ Sequential✅ Parallel agents

Agent Roles

RoleResponsibilityExample
OrchestratorDecompose, delegate, synthesizeMain chat session
SpecialistDeep expertise in one domainSecurity reviewer agent
WorkerExecute well-defined subtask"Find all usages of X"
CriticValidate, review, improveCode review agent

Decomposition Patterns

1. Horizontal Decomposition (Parallel)

Split task into independent subtasks that can run simultaneously.

code
┌─────────────────┐
│  Orchestrator   │
└───────┬─────────┘
        │ decompose
   ┌────┴────┬────────┐
   ▼         ▼        ▼
┌─────┐  ┌─────┐  ┌─────┐
│ A1  │  │ A2  │  │ A3  │   (parallel)
└──┬──┘  └──┬──┘  └──┬──┘
   └────────┼────────┘
            ▼
      synthesize

When to use:

  • Tasks have no dependencies
  • Results can be merged mechanically
  • Time is critical

Example: "Search for security issues in auth, api, and database modules"

2. Vertical Decomposition (Pipeline)

Chain agents where each builds on previous output.

code
┌─────────────────┐
│  Orchestrator   │
└───────┬─────────┘
        ▼
    ┌───────┐
    │  A1   │ → research
    └───┬───┘
        ▼
    ┌───────┐
    │  A2   │ → analyze
    └───┬───┘
        ▼
    ┌───────┐
    │  A3   │ → implement
    └───────┘

When to use:

  • Each step needs output from previous
  • Context builds incrementally
  • Quality gates between steps

Example: "Research best practices → Design API → Implement → Review"

3. Hierarchical Decomposition (Tree)

Orchestrator delegates to sub-orchestrators who manage workers.

code
┌─────────────────┐
│   Root Orch     │
└───────┬─────────┘
   ┌────┴────┐
   ▼         ▼
┌─────┐   ┌─────┐
│SubO1│   │SubO2│    (sub-orchestrators)
└──┬──┘   └──┬──┘
 ┌─┴─┐    ┌──┴──┐
 ▼   ▼    ▼     ▼
┌─┐ ┌─┐  ┌─┐   ┌─┐
│W│ │W│  │W│   │W│   (workers)
└─┘ └─┘  └─┘   └─┘

When to use:

  • Very complex tasks
  • Different domains within task
  • Scale beyond single orchestrator's context

Delegation Best Practices

Crafting Agent Instructions

When delegating to a subagent, specify:

ElementPurposeExample
ContextWhat they need to know"Working on Alex VS Code extension"
ScopeClear boundaries"Only look in /src/services"
OutputExpected format"Return JSON with findings"
ConstraintsWhat NOT to do"Don't modify files, only report"

Template for Subagent Prompt

code
**Task:** [One-sentence objective]

**Context:**
- Project: [name/type]
- Relevant files: [list]
- What's already done: [state]

**Scope:**
- DO: [specific actions]
- DON'T: [boundaries]

**Expected Output:**
[Format and content expectations]

**Success Criteria:**
[How you'll know it's done right]

Synthesis Patterns

Merging Agent Outputs

PatternWhenHow
ConcatenateIndependent resultsSimple append
DeduplicateOverlapping searchesHash/compare
VoteMultiple opinionsMajority wins
SynthesizeDiverse perspectivesLLM summary
ValidateCritical decisionsCritic agent reviews

Conflict Resolution

When agents disagree:

  1. Identify conflict type

    • Factual (check sources)
    • Opinion (escalate to user)
    • Interpretation (provide both views)
  2. Resolution strategies

    • Ask clarifying questions
    • Request evidence from agents
    • Escalate to more capable model
    • Present options to user

VS Code Copilot Patterns

Using runSubagent Effectively

The runSubagent tool enables orchestration within VS Code:

typescript
// Good: Clear task with expected output
await runSubagent({
  prompt: `Search the codebase for all error handling patterns.
           Return a JSON array of: {file, line, pattern, quality}`,
  description: "Find error patterns"
});

// Bad: Vague delegation
await runSubagent({
  prompt: "Look for problems in the code",  // Too vague
  description: "Find issues"
});

When to Use Subagent vs Direct

ScenarioApproach
Simple searchDirect grep_search
Complex multi-step searchrunSubagent
Single file editDirect replace_string_in_file
Multi-file coordinated changeConsider subagent for planning
Research + implementationSubagent for research, direct for implementation

Common Anti-Patterns

❌ Over-Orchestration

Problem: Using multiple agents for simple tasks Symptom: Slower, more expensive, no quality gain Fix: Trust capable models for multi-step tasks up to complexity threshold

❌ Insufficient Context

Problem: Agents lack needed information Symptom: Repeated clarification requests, wrong assumptions Fix: Front-load context in delegation prompt

❌ No Synthesis Strategy

Problem: Raw agent outputs dumped on user Symptom: User must manually integrate results Fix: Plan synthesis before decomposition

❌ Circular Dependencies

Problem: Agent A needs B's output, B needs A's output Symptom: Deadlock or infinite loops Fix: Identify and break cycles in task graph


Framework Landscape (2026)

FrameworkStrengthUse Case
LangGraphState machines, cyclesComplex workflows
AutoGenConversation patternsResearch, debate
CrewAIRole-based teamsBusiness processes
VS Code AgentsIDE integrationCode tasks
Semantic Kernel.NET nativeEnterprise C#

Alex-Specific Patterns

Heir Orchestration

Master Alex can coordinate heirs for cross-platform tasks:

code
Master Alex (orchestrator)
├── VS Code Heir → code analysis
├── M365 Heir → document synthesis
└── Global Knowledge → pattern matching

Skill Selection as Orchestration

When Alex runs Skill Selection Optimization (SSO), it's a form of self-orchestration:

  1. Survey available skills (agents)
  2. Match to task requirements
  3. Load relevant skills
  4. Execute with combined expertise

Implementation Checklist

When designing multi-agent workflows:

  • Can a single capable model handle this?
  • Are subtasks truly independent (or pipelined)?
  • Is context sufficient for each agent?
  • Is output format clearly specified?
  • Is synthesis strategy defined?
  • Are failure modes handled?
  • Is the orchestration overhead justified?

Related Skills

  • skill-selection-optimization — Pre-task skill loading
  • prompt-engineering — Crafting effective agent prompts
  • appropriate-reliance — Knowing when to trust agent output
  • root-cause-analysis — Debugging multi-agent failures

Multi-agent orchestration is powerful but not always necessary. Start simple, add agents when complexity demands it.