home / skills / yuniorglez / gemini-elite-core / subagent-orchestrator

subagent-orchestrator skill

/skills/subagent-orchestrator

This skill orchestrates subagents using MCP-based patterns to optimize multi-agent tasks with recursive delegation and shared memory.

npx playbooks add skill yuniorglez/gemini-elite-core --skill subagent-orchestrator

Review the files below or copy the command above to add this skill to your agents.

Files (5)
SKILL.md
5.4 KB
---
name: subagent-orchestrator
description: 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 for high-autonomy engineering missions.
---

# 🤖 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.

---

## 📋 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/`.

---

## 🛠️ Mandatory Protocols (2026 Standards)

### 1. Event-Driven Scheduling (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. Plan-Synced Execution
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`.

### 3. MCP-First Integration
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.

### 2. Recursive Delegation Limits
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. Shared State & Memory Management
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.

### 4. Handoff & Error Recovery
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);
  }
}
```

### Sequential Pipeline (Chain of Experts)
`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.

---

## 📂 Progressive Disclosure (Deep Dives)

- **[MCP Orchestration Deep Dive](./references/mcp-orchestration.md)**: Using MCP for tool and resource management.
- **[A2A Communication Protocols](./references/a2a-protocols.md)**: Horizontal coordination between peer agents.
- **[Error Handling in MAS](./references/error-handling.md)**: Retries, timeouts, and fallback strategies.
- **[Context Distillation Patterns](./references/context-distillation.md)**: Passing minimal, high-value context.

---

## 🛠️ 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.

---

## 🎓 Learning Resources
- [Anthropic MCP Documentation](https://modelcontextprotocol.io/)
- [Multi-Agent Systems Design Patterns](https://example.com/mas-patterns)
- [Agentic Workflow Optimization 2026](https://example.com/agent-flows)

---
*Updated: January 27, 2026 - 10:00*

Overview

This skill is a senior Multi-Agent Systems (MAS) orchestrator focused on Model Context Protocol (MCP) orchestration, Agent-to-Agent (A2A) communication, and recursive delegation frameworks. It provides patterns and enforcement rules for safe, high-concurrency subagent execution, shared memory state, and reliable handoffs. The goal is to convert CLI-driven workflows into robust autonomous agent missions with recoverable state and low-latency task activation.

How this skill works

The orchestrator initializes project-level subagents and selects an orchestration pattern (hierarchical, sequential, parallel, or handoff). It uses an event-driven scheduler to trigger subagents based on task events and enforces MCP-first tool access for consistent integrations. The parent agent maintains a persistent plan, validates subagent output, and handles recovery, recursion limits, and context distillation for efficient state sharing.

When to use it

  • Coordinating multiple specialized subagents on engineering or automation missions
  • Executing workflows that require parallel or event-driven task activation
  • Enforcing consistent tool access and context boundaries across agents
  • Preventing recursion explosions and ensuring recoverable session state
  • Implementing strict handoffs and audit-ready delegation manifests

Best practices

  • Always supply a concise Delegation Manifest with objective, constraints, and available tools
  • Enable eventDrivenScheduler for tasks involving more than two subagents
  • Use MCP servers for databases, APIs, and local resources instead of custom adapters
  • Distill context: pass only relevant symbols and facts, use state_snapshot for transient state and save_memory for long-term facts
  • Limit recursion depth to 3 and include recursion_depth in subagent metadata
  • Log every handoff and validate outputs against the persistent plan stored in the plan directory

Example use cases

  • Large-scale code generation pipeline: supervisor spawns code-architect, reviewer, and auditor subagents in a sequential chain
  • Parallel data enrichment: event-driven subagents fetch, normalize, and enrich records concurrently with context distillation
  • Incident response orchestration: hierarchical pattern where a supervisor delegates containment, triage, and reporting tasks to specialized agents
  • Long-running research mission: A2A persistent context enables session recovery and escalates to user on handoff failures
  • Automated validation: validate-handoff.py analyzes drift and triggers recovery re-routing when objectives diverge

FAQ

How do I prevent subagent recursion from exceeding budget?

Set a recursion_depth limit of 3 in manifest metadata and reject delegation requests that would exceed it; track token usage per subagent.

What should every handoff include?

A Delegation Manifest with objective, constraints, plan_id, current_step_index, available_tools, and max_tokens; include a Manifest of Objective for drift protection.