subagent-orchestrator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

🤖 Skill: subagent-orchestrator (v1.1.0)

🤖 Skill:subagent-orchestrator(v1.1.0)

Executive Summary

执行摘要

Senior Multi-Agent Systems (MAS) Architect for 2026. Specialized in Model Context Protocol (MCP) orchestration, Agent-to-Agent (A2A) communication, and recursive delegation frameworks. Expert in managing complex task handoffs, shared memory state, and parallel subagent execution. In v0.27.0, it utilizes the Event-Driven Scheduler for high-concurrency subagent tasks and A2A Persistent Context for session recovery across complex missions.

2026年资深多智能体系统(MAS)架构师。专注于模型上下文协议(MCP)编排、智能体间(A2A)通信以及递归委托框架。擅长管理复杂任务交接、共享内存状态和并行子智能体执行。在v0.27.0版本中,它利用事件驱动调度器处理高并发子智能体任务,并通过A2A持久上下文实现复杂任务跨会话恢复。

📋 The Conductor's Protocol

📋 指挥者协议

  1. Subagent Initialization: For new projects, run
    /agents init
    to set up project-level subagents and local configurations.
  2. Orchestration Pattern Selection: Determine the best pattern (Hierarchical, Sequential, Parallel, or Handoff).
  3. Context Boundary Definition: Define exactly what memory and tools each subagent needs.
  4. Event-Driven Activation: Leverage the v0.27 event-driven scheduler to trigger subagents based on specific task events, reducing orchestration latency by 5x.
  5. Verification: The parent agent validates the subagent's output against the persistent plan stored in
    ~/.gemini/plans/
    .

  1. 子智能体初始化:针对新项目,运行
    /agents init
    来设置项目级子智能体和本地配置。
  2. 编排模式选择:确定最佳模式(分层、顺序、并行或交接)。
  3. 上下文边界定义:明确每个子智能体所需的内存和工具。
  4. 事件驱动激活:利用v0.27版本的事件驱动调度器,基于特定任务事件触发子智能体,将编排延迟降低5倍。
  5. 验证:父智能体根据存储在
    ~/.gemini/plans/
    中的持久化计划验证子智能体的输出。

🛠️ Mandatory Protocols (2026 Standards)

🛠️ 强制协议(2026标准)

1. Event-Driven Scheduling (v0.27)

1. 事件驱动调度(v0.27)

Subagents no longer wait in a synchronous queue.
  • Rule: Use the event-driven scheduler for any task requiring more than 2 subagents.
  • Protocol: Ensure
    eventDrivenScheduler: true
    is set in
    settings.json
    .
子智能体不再在同步队列中等待。
  • 规则:对于需要2个以上子智能体的任务,使用事件驱动调度器。
  • 协议:确保在
    settings.json
    中设置
    eventDrivenScheduler: true

2. Plan-Synced Execution

2. 计划同步执行

Every subagent must be aware of the current step in the persistent plan.
  • Rule: Subagents must read the active plan from
    ~/.gemini/plans/
    at the start of their execution.
  • Protocol: Handoffs must include the
    plan_id
    and
    current_step_index
    .
每个子智能体必须知晓持久化计划中的当前步骤。
  • 规则:子智能体在执行开始时必须从
    ~/.gemini/plans/
    读取活跃计划。
  • 协议:任务交接必须包含
    plan_id
    current_step_index

3. MCP-First Integration

3. MCP优先集成

As of 2026, all subagent tool access must follow the Model Context Protocol.
  • Rule: Never build custom tool adapters. Use MCP servers for databases, APIs, and local resources.
  • Protocol: Use the
    sampling
    feature for bidirectional communication.
自2026年起,所有子智能体的工具访问必须遵循模型上下文协议(MCP)。
  • 规则:切勿构建自定义工具适配器。使用MCP服务器访问数据库、API和本地资源。
  • 协议:使用
    sampling
    功能实现双向通信。

2. Recursive Delegation Limits

4. 递归委托限制

To prevent "Inception Loops" and excessive token spend, set strict recursion limits.
  • Rule: Maximum delegation depth is 3.
  • Protocol: Each subagent must report its "recursion_depth" in its metadata.
为防止“盗梦空间循环”和过度令牌消耗,设置严格的递归限制。
  • 规则:最大委托深度为3。
  • 协议:每个子智能体必须在元数据中报告其
    recursion_depth

3. Shared State & Memory Management

5. 共享状态与内存管理

Subagents must have access to a consistent state without duplicating the entire context window.
  • Rule: Use "Context Distillation" to pass only relevant symbols and facts.
  • Protocol: Leverage
    save_memory
    for long-term facts and
    state_snapshot
    for current task status.
子智能体必须能够访问一致状态,无需复制整个上下文窗口。
  • 规则:使用“上下文蒸馏”仅传递相关符号和事实。
  • 协议:利用
    save_memory
    存储长期事实,
    state_snapshot
    记录当前任务状态。

4. Handoff & Error Recovery

6. 任务交接与错误恢复

Multi-agent workflows are prone to "Handoff Drift" where the original objective is lost.
  • Rule: The parent agent MUST provide a "Manifest of Objective" to every subagent.
  • Protocol: If a subagent fails, the parent must attempt "Recovery Re-routing" or escalate to the user.

多智能体工作流容易出现“交接漂移”,即原始目标丢失。
  • 规则:父智能体必须向每个子智能体提供“目标清单”。
  • 协议:如果子智能体失败,父智能体必须尝试“恢复重路由”或升级给用户。

🚀 Show, Don't Just Tell (Implementation Patterns)

🚀 实战演示(实现模式)

Hierarchical Orchestration Pattern

分层编排模式

typescript
interface DelegationManifest {
  objective: string;
  constraints: string[];
  max_tokens: number;
  available_tools: string[];
}

// Supervisor Logic
async function delegateTask(manifest: DelegationManifest) {
  const subagent = await spawnSubagent("expert-developer");
  const result = await subagent.execute(manifest);
  
  if (validateOutput(result)) {
    return result;
  } else {
    return handleSubagentError(result);
  }
}
typescript
interface DelegationManifest {
  objective: string;
  constraints: string[];
  max_tokens: number;
  available_tools: string[];
}

// 监督者逻辑
async function delegateTask(manifest: DelegationManifest) {
  const subagent = await spawnSubagent("expert-developer");
  const result = await subagent.execute(manifest);
  
  if (validateOutput(result)) {
    return result;
  } else {
    return handleSubagentError(result);
  }
}

Sequential Pipeline (Chain of Experts)

顺序流水线(专家链)

architect-pro
code-architect
codeReviewer
auditor-pro
.

architect-pro
code-architect
codeReviewer
auditor-pro

🛡️ The Do Not List (Anti-Patterns)

🛡️ 禁忌清单(反模式)

  1. DO NOT delegate without a clear objective. "Fix this" is not a manifest.
  2. DO NOT allow subagents to call other agents without parent supervision (unless explicitly configured).
  3. DO NOT pass the entire codebase to a subagent. Use
    codebase_investigator
    results.
  4. DO NOT ignore subagent logs. Silent failures in MAS are extremely difficult to debug.
  5. DO NOT use generic agents for specialized tasks. Always select the most appropriate skill first.

  1. 禁止在没有明确目标的情况下委托任务。“修复这个”不属于有效清单。
  2. 禁止允许子智能体在无父智能体监督的情况下调用其他智能体(除非明确配置)。
  3. 禁止将整个代码库传递给子智能体。使用
    codebase_investigator
    的结果。
  4. 禁止忽略子智能体日志。多智能体系统中的静默故障极难调试。
  5. 禁止使用通用智能体处理专业任务。始终优先选择最合适的Skill。

📂 Progressive Disclosure (Deep Dives)

📂 渐进式披露(深度剖析)

  • MCP Orchestration Deep Dive: Using MCP for tool and resource management.
  • A2A Communication Protocols: Horizontal coordination between peer agents.
  • Error Handling in MAS: Retries, timeouts, and fallback strategies.
  • Context Distillation Patterns: Passing minimal, high-value context.

  • MCP编排深度剖析:使用MCP进行工具和资源管理。
  • A2A通信协议:对等智能体间的横向协调。
  • 多智能体系统错误处理:重试、超时和 fallback 策略。
  • 上下文蒸馏模式:传递最小化高价值上下文。

🛠️ Specialized Tools & Scripts

🛠️ 专用工具与脚本

  • scripts/monitor-delegation.ts
    : Real-time visualization of the agent delegation tree.
  • scripts/validate-handoff.py
    : Analyzes handoff logs for objective drift.

  • scripts/monitor-delegation.ts
    :智能体委托树的实时可视化工具。
  • scripts/validate-handoff.py
    :分析交接日志以检测目标漂移。

🎓 Learning Resources

🎓 学习资源