|
| 1 | +--- |
| 2 | +name: agent-orchestration |
| 3 | +description: Proactively orchestrate running AI agents — scan statuses, assess progress, send next instructions, and coordinate multi-agent workflows. Use when users ask to manage agents, orchestrate work across agents, or check on agent progress. |
| 4 | +--- |
| 5 | + |
| 6 | +# Agent Orchestration |
| 7 | + |
| 8 | +Act as a **lead orchestrator** for running AI agents. Proactively scan, assess, decide, and instruct in a continuous loop. Ask the user for direction only when you lack context to decide. |
| 9 | + |
| 10 | +## Hard Rules |
| 11 | + |
| 12 | +- Always `agent list --json` before acting — never fabricate agent names or statuses. |
| 13 | +- Every instruction sent to an agent must be **self-contained and specific** — the target agent has no awareness of this orchestration layer. Never send vague messages like "continue". |
| 14 | +- **Escalate to user** when: you can't diagnose an agent's error, a decision needs product/business judgment, agents have conflicting outputs, or an agent stays stuck after corrective attempts. Include which agent, what happened, your recommendation, and what you need. |
| 15 | + |
| 16 | +## CLI Reference |
| 17 | + |
| 18 | +Base: `npx ai-devkit@latest agent <command>` |
| 19 | + |
| 20 | +| Command | Usage | Key Flags | |
| 21 | +|---------|-------|-----------| |
| 22 | +| `list` | `agent list --json` | `--json` (always use) | |
| 23 | +| `detail` | `agent detail --id <name> --json` | `--tail <n>` (last N msgs, default 20), `--full`, `--verbose` (include tool calls) | |
| 24 | +| `send` | `agent send "<message>" --id <name>` | | |
| 25 | + |
| 26 | +Key fields in list output: `name`, `type` (claude/codex/gemini_cli/other), `status` (running/waiting/idle/unknown), `summary`, `pid`, `projectPath`, `lastActive`. |
| 27 | + |
| 28 | +Detail output adds: `conversation[]` with `{role, content, timestamp}` entries. |
| 29 | + |
| 30 | +## Orchestration Loop |
| 31 | + |
| 32 | +Run continuously until all agents are done or the user says stop. After each pass, give the user a brief status update. |
| 33 | + |
| 34 | +### 1. Scan |
| 35 | + |
| 36 | +Run `agent list --json`. Prioritize by status: **waiting > idle > unknown > running**. |
| 37 | + |
| 38 | +- **Waiting** — needs your instruction now. |
| 39 | +- **Idle** — finished or stalled, investigate. |
| 40 | +- **Unknown** — anomalous state, investigate. |
| 41 | +- **Running** — skip unless long-running or blocking another agent. |
| 42 | + |
| 43 | +If all agents are running, inform the user and wait for them to request the next check. |
| 44 | + |
| 45 | +### 2. Assess |
| 46 | + |
| 47 | +For each non-running agent needing attention: |
| 48 | +- Run `agent detail --id <name> --json --tail 10`. |
| 49 | +- Determine: what it finished, what it's asking, whether it's stuck. |
| 50 | + |
| 51 | +### 3. Decide and Act |
| 52 | + |
| 53 | +| Situation | Action | |
| 54 | +|-----------|--------| |
| 55 | +| Finished task | Send next task via `agent send`, or note complete and move on | |
| 56 | +| Waiting for approval | Review its output, send approval or change requests via `agent send` | |
| 57 | +| Waiting for clarification | Answer its question via `agent send`, or escalate to user | |
| 58 | +| Stuck or looping | Send corrective instruction or new approach via `agent send` | |
| 59 | +| Idle, no pending work | Assign new work via `agent send`, or leave idle | |
| 60 | +| Output needed by another agent | Extract relevant output, include it in `agent send` to the dependent agent | |
| 61 | +| Insufficient context | Ask user for direction | |
| 62 | + |
| 63 | +## Multi-Agent Coordination |
| 64 | + |
| 65 | +When agents work on related tasks: |
| 66 | + |
| 67 | +- **Dependencies** — track which agents block others. Don't unblock a dependent until the upstream confirms completion. |
| 68 | +- **Information relay** — include upstream output directly in the instruction to the downstream agent. |
| 69 | +- **Conflict prevention** — if agents may edit the same files, sequence their work or assign non-overlapping scopes. |
0 commit comments