home / skills / openclaw / skills / agent-orchestrator

agent-orchestrator skill

/skills/aatmaan1/agent-orchestrator

This skill orchestrates tasks by decomposing them into subtasks, spawning sub-agents, and consolidating results for autonomous multi-agent workflows.

npx playbooks add skill openclaw/skills --skill agent-orchestrator

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

Files (4)
SKILL.md
5.7 KB
---
name: agent-orchestrator
description: |
  Meta-agent skill for orchestrating complex tasks through autonomous sub-agents. Decomposes macro tasks into subtasks, spawns specialized sub-agents with dynamically generated SKILL.md files, coordinates file-based communication, consolidates results, and dissolves agents upon completion.

  MANDATORY TRIGGERS: orchestrate, multi-agent, decompose task, spawn agents, sub-agents, parallel agents, agent coordination, task breakdown, meta-agent, agent factory, delegate tasks
---

# Agent Orchestrator

Orchestrate complex tasks by decomposing them into subtasks, spawning autonomous sub-agents, and consolidating their work.

## Core Workflow

### Phase 1: Task Decomposition

Analyze the macro task and break it into independent, parallelizable subtasks:

```
1. Identify the end goal and success criteria
2. List all major components/deliverables required
3. Determine dependencies between components
4. Group independent work into parallel subtasks
5. Create a dependency graph for sequential work
```

**Decomposition Principles:**
- Each subtask should be completable in isolation
- Minimize inter-agent dependencies
- Prefer broader, autonomous tasks over narrow, interdependent ones
- Include clear success criteria for each subtask

### Phase 2: Agent Generation

For each subtask, create a sub-agent workspace:

```bash
python3 scripts/create_agent.py <agent-name> --workspace <path>
```

This creates:
```
<workspace>/<agent-name>/
├── SKILL.md          # Generated skill file for the agent
├── inbox/            # Receives input files and instructions
├── outbox/           # Delivers completed work
├── workspace/        # Agent's working area
└── status.json       # Agent state tracking
```

**Generate SKILL.md dynamically** with:
- Agent's specific role and objective
- Tools and capabilities needed
- Input/output specifications
- Success criteria
- Communication protocol

See [references/sub-agent-templates.md](references/sub-agent-templates.md) for pre-built templates.

### Phase 3: Agent Dispatch

Initialize each agent by:

1. Writing task instructions to `inbox/instructions.md`
2. Copying required input files to `inbox/`
3. Setting `status.json` to `{"state": "pending", "started": null}`
4. Spawning the agent using the Task tool:

```python
# Spawn agent with its generated skill
Task(
    description=f"{agent_name}: {brief_description}",
    prompt=f"""
    Read the skill at {agent_path}/SKILL.md and follow its instructions.
    Your workspace is {agent_path}/workspace/
    Read your task from {agent_path}/inbox/instructions.md
    Write all outputs to {agent_path}/outbox/
    Update {agent_path}/status.json when complete.
    """,
    subagent_type="general-purpose"
)
```

### Phase 4: Monitoring (Checkpoint-based)

For fully autonomous agents, minimal monitoring is needed:

```python
# Check agent completion
def check_agent_status(agent_path):
    status = read_json(f"{agent_path}/status.json")
    return status.get("state") == "completed"
```

Periodically check `status.json` for each agent. Agents update this file upon completion.

### Phase 5: Consolidation

Once all agents complete:

1. **Collect outputs** from each agent's `outbox/`
2. **Validate deliverables** against success criteria
3. **Merge/integrate** outputs as needed
4. **Resolve conflicts** if multiple agents touched shared concerns
5. **Generate summary** of all work completed

```python
# Consolidation pattern
for agent in agents:
    outputs = glob(f"{agent.path}/outbox/*")
    validate_outputs(outputs, agent.success_criteria)
    consolidated_results.extend(outputs)
```

### Phase 6: Dissolution & Summary

After consolidation:

1. **Archive agent workspaces** (optional)
2. **Clean up temporary files**
3. **Generate final summary**:
   - What was accomplished per agent
   - Any issues encountered
   - Final deliverables location
   - Time/resource metrics

```python
python3 scripts/dissolve_agents.py --workspace <path> --archive
```

## File-Based Communication Protocol

See [references/communication-protocol.md](references/communication-protocol.md) for detailed specs.

**Quick Reference:**
- `inbox/` - Read-only for agent, written by orchestrator
- `outbox/` - Write-only for agent, read by orchestrator
- `status.json` - Agent updates state: `pending` → `running` → `completed` | `failed`

## Example: Research Report Task

```
Macro Task: "Create a comprehensive market analysis report"

Decomposition:
├── Agent: data-collector
│   └── Gather market data, competitor info, trends
├── Agent: analyst
│   └── Analyze collected data, identify patterns
├── Agent: writer
│   └── Draft report sections from analysis
└── Agent: reviewer
    └── Review, edit, and finalize report

Dependency: data-collector → analyst → writer → reviewer
```

## Sub-Agent Templates

Pre-built templates for common agent types in [references/sub-agent-templates.md](references/sub-agent-templates.md):

- **Research Agent** - Web search, data gathering
- **Code Agent** - Implementation, testing
- **Analysis Agent** - Data processing, pattern finding
- **Writer Agent** - Content creation, documentation
- **Review Agent** - Quality assurance, editing
- **Integration Agent** - Merging outputs, conflict resolution

## Best Practices

1. **Start small** - Begin with 2-3 agents, scale as patterns emerge
2. **Clear boundaries** - Each agent owns specific deliverables
3. **Explicit handoffs** - Use structured files for agent communication
4. **Fail gracefully** - Agents report failures; orchestrator handles recovery
5. **Log everything** - Status files track progress for debugging

Overview

This skill implements a meta-agent orchestrator to orchestrate complex work by decomposing macro tasks, spawning autonomous sub-agents, and consolidating results. It acts as an agent factory that delegates tasks to specialized sub-agents and manages agent coordination, lifecycle, and cleanup. Designed for multi-agent workflows, it supports parallel agents and sequential dependency graphs to deliver predictable outcomes.

How this skill works

The orchestrator analyzes a macro task and applies a task breakdown to decompose task into independent subtasks with clear success criteria. For each subtask it generates a sub-agent workspace, writes instructions and inputs, and spawns agents to run autonomously; agents communicate via file-based inbox/outbox and update a status file. The orchestrator monitors status.json checkpoints, collects and validates outputs, resolves conflicts, consolidates deliverables, and dissolves agents when done.

When to use it

  • When you need a meta-agent to orchestrate multi-agent workflows and delegate tasks across specialized sub-agents
  • When a large task can be decomposed into parallel agents to speed delivery
  • When clear agent coordination and file-based handoffs simplify integration between autonomous workers
  • When you need to run isolated, auditable agent workspaces for archival or backup
  • When you want to prototype an agent factory that spawns, monitors, and dissolves sub-agents automatically

Best practices

  • Decompose task into subtasks that are completable in isolation and include explicit success criteria
  • Prefer broader autonomous sub-agents over many tightly coupled ones to reduce inter-agent dependencies
  • Use structured file handoffs (inbox/outbox and status files) for explicit agent coordination and retries
  • Start small (2–3 agents) and iterate on templates before scaling to many parallel agents
  • Log status and artifacts for each agent to enable easy validation, conflict resolution, and audits

Example use cases

  • Research report pipeline: decompose into data-collector, analyst, writer, and reviewer agents with sequential dependencies
  • Large codebase migration: spawn code agents to refactor modules in parallel and an integration agent to merge changes
  • Market analysis: spawn parallel data-gathering agents for regions, then an analysis agent to consolidate findings
  • QA orchestration: spawn multiple test agents against different environments, then consolidate test reports
  • Content production: delegate topic research, drafting, and editing to specialized writer and reviewer sub-agents

FAQ

How does the orchestrator detect when a sub-agent is finished?

Agents update a status.json file with states like pending → running → completed; the orchestrator polls those files as checkpoints.

Can agents run in parallel and how are dependencies handled?

Yes—independent subtasks run as parallel agents; sequential dependencies are represented in a dependency graph and agents are started in the required order.