AgentSkillsCN

Multi-Agent Collaboration

在设计代理协调、实施上下文交接、减少上下文开销、创建多代理工作流、优化代理通信、实施渐进式披露、选择架构模式(分层 vs 群体)或调试代理上下文问题时,应使用此技能。提供最先进的多代理系统模式,实现78%以上的上下文减少,同时保持分析质量。

SKILL.md
--- frontmatter
name: Multi-Agent Collaboration
description: >
  This skill should be used when designing agent coordination, implementing
  context handoffs, reducing context overhead, creating multi-agent workflows,
  optimizing agent communication, implementing progressive disclosure,
  selecting architectural patterns (hierarchical vs swarm), or debugging
  agent context issues. Provides SOTA patterns for multi-agent systems
  achieving 78%+ context reduction while maintaining analysis quality.

Multi-Agent Collaboration

Overview

State-of-the-art patterns for context-efficient multi-agent systems. These patterns enable complex agent workflows while minimizing token overhead through strategic context engineering.

Research Foundation

  • Google ADK: Context compilation pipelines and session management
  • Anthropic: Multi-agent coordination and handoff protocols
  • Progressive Disclosure: Agent-readable semantic interfaces
  • LangGraph/CrewAI/AutoGen: Framework-specific orchestration patterns

Pattern Selection Framework

PatternUse WhenTrade-offs
HierarchicalClear decomposition, audit trailsCentral bottleneck, sequential latency
SwarmParallel exploration, diverse perspectivesCoordination overhead, emergent behavior
ReActDynamic adaptation, tool-heavy workflowsMyopic decisions, may meander
Plan-ExecuteClear sequence, predictability neededLess adaptive, requires replanning
ReflectionQuality refinement, self-correctionAdded latency, may reinforce errors
HybridMultiple coordination needsImplementation complexity

For detailed YAML definitions and examples of each pattern, see references/patterns.md.

The Four Laws of Context Management

Law 1: Selective Projection

Pass only fields each agent needs, not full data structures.

yaml
# BAD: Full snapshot everywhere
snapshot: {...20KB...}

# GOOD: Selective projection
context:
  mode: deep
  claims_analyzed: 15
  high_risk_count: 4

Law 2: Tiered Context Fidelity

Define explicit tiers based on agent role:

TierDescriptionExample Agent
FULLComplete dataInitial analyzer
SELECTIVERelevant subsetDomain workers
FILTEREDCriteria-matchedValidators
MINIMALMode + countsStrategy/routing
METADATAScope stats onlyReport synthesis

Law 3: Reference vs Embedding

For large data, pass reference instead of full structure:

yaml
# Embedding (expensive)
raw_findings: [{...}, {...}, ...]  # 40+ items

# Reference (efficient)
findings_summary:
  total: 45
  by_severity: {CRITICAL: 3, HIGH: 12}
  # Agent fetches specific findings on-demand

Law 4: Lazy Loading

Load data on-demand, not upfront:

yaml
initial_context:
  scope: {item_count: 45}
  available_data:
    - name: findings
      fetch: "request by severity or ID"

For implementation details and patterns, see references/context-engineering.md.

Standard Handoff Protocol

yaml
handoff:
  from_agent: context-analyzer
  to_agent: attack-strategist
  context_level: MINIMAL

  payload:
    mode: deep
    analysis_summary:
      claim_count: 15
      high_risk_count: 4
      patterns: [pattern_1, pattern_2]

  expected_output:
    format: yaml
    schema: strategy_v1

Severity-Based Batching

Reduce validation operations by routing based on priority:

yaml
batching:
  CRITICAL: [all_validators]      # 4 agents
  HIGH: [checker, verifier]       # 2 agents
  MEDIUM: [checker]               # 1 agent
  LOW/INFO: []                    # Skip

# Result: 60-70% fewer operations

Anti-Patterns to Avoid

  1. Snapshot Broadcasting - Passing full context to every agent
  2. Defensive Over-inclusion - "Maybe they need this" mentality
  3. Grounding Everything - Validating low-priority items
  4. Embedding Large Lists - Full arrays when counts suffice
  5. Repeated Context - Same data passed multiple times in chain
  6. Verbose Outputs - Over-explaining when concise suffices

Progressive Disclosure for Agents

Three-Level Loading

yaml
level_1_always_loaded:
  - skill_name
  - skill_description
  tokens: ~100

level_2_on_trigger:
  - main_skill_body
  - core_patterns
  - quick_reference_tables
  tokens: ~2000

level_3_on_demand:
  - detailed_references
  - extended_examples
  - implementation_guides
  tokens: as_needed

Guardrails and Validation

Output Validation Pattern

yaml
validation:
  hook: post_tool_use
  on_invalid:
    action: block_and_retry
    max_retries: 2
  on_valid:
    action: continue

Context Tier Enforcement

Document what each agent does NOT receive:

yaml
agent_context:
  receives:
    - analysis_summary
    - assigned_vectors

  not_provided:  # CRITICAL: Explicit exclusions
    - full_snapshot
    - other_agents_data
    - conversational_arc

Metrics

Track these to validate optimization:

MetricTarget
Total context passed< 100KB
Redundancy ratio< 0.1
Validation efficiency> 3:1 findings/operations
Tier compliance100%

Additional Resources

  • references/context-engineering.md - Detailed context management patterns
  • references/patterns.md - Architectural patterns with YAML definitions
  • references/examples.md - Red-agent implementation examples