A framework for main agents that coordinate specialized sub-agents instead of trying to execute every part of a task alone.
The main agent is an orchestrator, not a dump pipe.
Its job is to:
Sub-agents execute scoped work. The main agent owns correctness.
This skill is written to fit the current local OpenClaw profile instead of overriding it.
Respect these existing limits:
codex, invest, content, knowledge, communitycodex2Do not invent agent ids that are not already allowed by the local OpenClaw config. If a task does not clearly map to one of the allowed agents, keep it local.
If you need more agent kinds than the local five, extend the registry at the routing config level instead of altering this skill’s description. The agents block now supported in the routing schema lets you declare agent metadata (id, description, capabilities) and refer to those ids via preferred_agent/fallback_agent. The current OpenClaw profile in references/openclaw-playbook.md is a runnable example, but you can register additional agents (ops-specialist, researcher, etc.) in examples/custom-agent-registry.yaml without touching the local workspace constraints.
Use these mappings before introducing any custom routing logic:
| Task Type + Domain | OpenClaw Agent | Notes |
|---|---|---|
| --------- | ----------- | ------ |
explore + code | codex | Use for bounded codebase investigation and root-cause analysis. |
implement + code | codex | Default coding path. Main agent still owns acceptance. |
verify + code | main first, codex only if needed | Keep final verification local unless a bounded reviewer pass is useful. |
operate + knowledge | knowledge | Archiving, note organization, knowledge-base updates. |
explore + knowledge | knowledge | Search, retrieval, note inspection, archive lookup. |
implement + content | content | Drafting, rewriting, title/outline/content generation. |
operate + community | community | Posting, replying, engagement, community-side actions. |
explore + invest | invest | Market/stock/fundamental analysis. |
operate + invest | invest | Watchlist, simulated trading, structured finance workflows. |
| ambiguous or tightly coupled work | main | Keep local until boundaries are explicit. |
1. Receive task
2. Check no-spawn rules
3. Classify task type and domain
4. Decide local vs delegated execution
5. Write task contract
6. Dispatch one or more sub-agents
7. Track status
8. Verify outputs
9. Resolve gaps or conflicts
10. Synthesize final answer
This template uses two routing dimensions.
Task type describes what kind of work is being requested:
explore — investigate, inspect, analyze, answer bounded questionsimplement — write or modify code/content/configurationverify — test, validate, review, compare, check constraintsoperate — perform external actions, archive, publish, update systemsDomain describes what area the task belongs to:
codeknowledgecontentcommunityinvestThe orchestrator should classify both. "Fix this bug" is not only code; it is usually implement + code, and may need explore + code first.
Do not spawn by default. Spawn when delegation materially improves quality, speed, or isolation.
Check these before any routing logic.
Typical no-spawn rules:
Choose the right execution pattern before choosing a domain.
Examples:
explore + code -> codeximplement + code -> codexverify + code -> main firstoperate + knowledge -> knowledgeNever dispatch vague instructions like "go handle this".
Every delegated task should include:
See references/task-contract-template.md.
Parallel work is useful only when tasks do not collide.
Good candidates:
2 concurrent sub-agents in the current OpenClaw profileBad candidates:
See references/parallel-dispatch-rules.md.
Track delegated work explicitly.
Recommended statuses:
pendingin_progressblockedneeds_reviewcompletedabandonedThis makes recovery decisions concrete. A blocked task is different from a completed task with review gaps.
Sub-agent output is not complete until the main agent verifies it.
Verify:
See references/acceptance-patterns.md.
When delegated work fails:
resume-orchestration.py runs on a persisted state file and replays in-progress work. It reuses the existing dispatch_id/bundle_dir, polls the adapters, and finalizes tasks marked dispatched or running without dispatching new bundles. Use scripts/state-store.py update-resume to inspect or repair resume metadata before calling the resume script, including max_attempts, retryable_failure_codes, and next_retry_after.
For operator visibility, watch-state.py prints a current snapshot of each task's status, attempt_count, last_dispatch_status, and scheduled retry timestamp without replaying hook logs.
For the current local OpenClaw setup, use this compact decision sequence:
1. If the task is simple, blocking, or tightly coupled -> keep it in main
2. If it is code exploration or implementation -> route to codex
3. If it is note/archive/knowledge work -> route to knowledge
4. If it is writing/drafting -> route to content
5. If it is community action -> route to community
6. If it is market/investment analysis -> route to invest
7. Never exceed 2 concurrent sub-agents
8. Main agent always verifies and synthesizes the final answer
2共 1 个版本