Get the FREE Ultimate OpenClaw Setup Guide →

agent-orchestration

npx machina-cli add skill shahtuyakov/claude-setup/agent-orchestration --openclaw
Files (1)
SKILL.md
7.0 KB

Agent Orchestration Skill

Overview

This skill provides patterns for orchestrating multi-agent workflows using the Hub Architecture. In this pattern:

  • Subagents cannot directly spawn other subagents
  • The main conversation acts as a hub that routes requests between agents
  • Agents communicate via structured delegation requests

Delegation Request Protocol

Single Agent Request

When an agent needs help from one other agent:

{
  "delegation_request": {
    "agent": "database",
    "reason": "Need users schema before implementing auth",
    "prompt": "Create users table with id, email, password_hash, created_at",
    "blocking": true
  }
}
FieldDescription
agentTarget agent: database, backend, frontend, ios, devops, designer
reasonWhy this delegation is needed
promptSpecific instructions for the target agent
blockingIf true, wait for completion before continuing

Multi-Agent Request

When orchestrating multiple agents (typically from architect):

{
  "delegation_request": {
    "type": "sequential",
    "agents": [
      {
        "agent": "database",
        "task_id": "auth-001",
        "prompt": "Create users and sessions tables",
        "depends_on": null
      },
      {
        "agent": "backend",
        "task_id": "auth-001",
        "prompt": "Implement auth endpoints",
        "depends_on": "database"
      },
      {
        "agent": "frontend",
        "task_id": "auth-001",
        "prompt": "Create login/register forms",
        "depends_on": "backend"
      },
      {
        "agent": "ios",
        "task_id": "auth-001",
        "prompt": "Create auth screens",
        "depends_on": "backend"
      }
    ],
    "parallel_groups": [
      ["frontend", "ios"]
    ],
    "context_file": ".agents/architect/current-plan.md",
    "return_to": "architect"
  }
}
FieldDescription
typesequential, parallel, or mixed
agentsArray of agent tasks
depends_onAgent that must complete first (null = no dependency)
parallel_groupsArrays of agents that can run concurrently
context_fileShared context file for all agents (JSON format: .agents/architect/current-plan.json)
return_toAgent to receive aggregated results

Hub Processing

When the hub receives a delegation request:

Step 1: Parse Request

Extract the delegation_request JSON from the agent's response.

Step 2: Build Execution Graph

database (no deps) ──┐
                     ├──► backend ──┬──► frontend
                     │              │
                     │              └──► ios (parallel with frontend)
                     │
designer (no deps) ──┘

Step 3: Execute in Order

  1. Run agents with no dependencies first
  2. Pass results to dependent agents
  3. Run parallel groups concurrently
  4. Collect all results

Step 4: Spawn Agents

Task(
  subagent_type="database",
  prompt="Task auth-001: Create users and sessions tables.

Read: .agents/architect/current-plan.json

Return summary under 500 tokens including:
- Tables/schemas created
- Key decisions
- Notes for dependent agents"
)

Step 5: Pass Context Forward

Task(
  subagent_type="backend",
  prompt="Task auth-001: Implement auth endpoints.

Read: .agents/architect/current-plan.json

Previous agent results:
- database: Created users(id, email, password_hash) and sessions(id, user_id, token) tables

Return summary under 500 tokens."
)

Step 6: Handle Parallel Execution

When agents can run in parallel, spawn them in the same message:

// Both run concurrently
Task(subagent_type="frontend", prompt="...")
Task(subagent_type="ios", prompt="...")

Step 7: Aggregate Results

{
  "hub_results": {
    "task_id": "auth-001",
    "completed_agents": [
      {
        "agent": "database",
        "status": "completed",
        "summary": "Created users and sessions tables",
        "files": ["prisma/schema.prisma"]
      },
      {
        "agent": "backend",
        "status": "completed",
        "summary": "Created POST /auth/login, /auth/register, /auth/logout",
        "files": ["src/routes/auth.ts"]
      }
    ],
    "failed_agents": [],
    "total_files_modified": 5
  }
}

Step 8: Return to Requesting Agent

Task(
  subagent_type="architect",
  prompt="Hub completed delegation for task auth-001.

Results:
[hub_results JSON]

All agents completed successfully. Continue with synthesis."
)

Handling Nested Delegations

Agents may return their own delegation requests:

backend returns:
{
  "work_completed": "Implemented auth endpoints",
  "delegation_request": {
    "agent": "database",
    "reason": "Need to add email_verified column",
    "prompt": "Add email_verified boolean to users table"
  }
}

The hub should:

  1. Note the work completed
  2. Process the nested delegation
  3. Return combined results

Error Handling

Agent Failure

{
  "hub_results": {
    "completed_agents": [...],
    "failed_agents": [
      {
        "agent": "frontend",
        "status": "failed",
        "error": "Could not find component structure",
        "suggestion": "Run designer agent first"
      }
    ]
  }
}

Dependency Failure

If a dependency fails, mark dependent agents as blocked:

{
  "blocked_agents": [
    {
      "agent": "backend",
      "blocked_by": "database",
      "reason": "Database agent failed to create schema"
    }
  ]
}

Workflow Examples

Full Stack Feature

Architect → Hub:
  delegation_request:
    designer → database → backend → [frontend, ios] → devops

Hub executes:
  1. designer: Create tokens
  2. database: Create schema
  3. backend: Create API
  4. frontend + ios: Create UI (parallel)
  5. devops: Setup deployment
  6. Return to architect

Quick Fix

Backend → Hub:
  delegation_request:
    agent: database
    prompt: "Add index on users.email"

Hub executes:
  1. database: Add index
  2. Return to backend

Cross-Platform UI

Designer → Hub:
  delegation_request:
    parallel_groups: [[frontend, ios]]
    prompt: "Apply new button styles"

Hub executes:
  1. frontend + ios (parallel): Update buttons
  2. Return to designer

Best Practices

  1. Keep prompts specific - Include exact requirements, not vague goals
  2. Include context files - Always reference shared plan documents
  3. Limit delegation depth - Avoid deep nesting (max 2 levels)
  4. Use parallel when possible - Frontend/iOS can often run together
  5. Handle failures gracefully - Always check for failed agents
  6. Aggregate meaningfully - Combine results into actionable summaries

Source

git clone https://github.com/shahtuyakov/claude-setup/blob/main/skills/agent-orchestration/SKILL.mdView on GitHub

Overview

This skill defines hub-based patterns to orchestrate multi-agent workflows. It enforces that subagents cannot spawn other subagents and uses a central hub to route structured delegation requests and aggregate results.

How This Skill Works

Agents send structured delegation requests to a central hub. The hub parses the request, builds an execution graph with sequential and parallel task groups, spawns subagents as needed, and aggregates results to return to the requester.

When to Use It

  • You need to delegate work from one agent to another via a centralized hub
  • Coordinating multi-step workflows with clear dependencies (sequential/parallel)
  • Aggregating results from multiple agents into a single summary for a caller
  • Enforcing hub-based routing instead of direct subagent spawning
  • Using a shared context file (e.g., .agents/architect/current-plan.json) to guide agents

Quick Start

  1. Step 1: Send a structured delegation_request to the hub to start orchestration
  2. Step 2: Hub parses the request and builds an execution graph with sequential and/or parallel groups
  3. Step 3: Hub spawns subagents as needed, collects results, and returns the aggregated summary to the requester

Best Practices

  • Use the delegation_request protocol with explicit fields (agent, prompt, type, depends_on, etc.)
  • Define dependencies and parallel groups clearly to avoid deadlocks
  • Store shared context in a known location (context_file) accessible to all agents
  • Prefer synchronous (blocking) requests when immediate results are needed
  • Log hub routing steps and results for traceability and auditing

Example Use Cases

  • Architect orchestrates database, backend, frontend, and iOS tasks to implement a new auth flow
  • Sequential plan: create schema, implement endpoints, then build UI, with each step depending on the previous
  • Frontend and iOS components built in parallel within a parallel_group
  • Central plan stored at .agents/architect/current-plan.md and results aggregated back to architect
  • Subagents spawn only through the hub, not directly by other subagents

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers