Agent Orchestrator Template
A framework for main agents that coordinate specialized sub-agents instead of trying to execute every part of a task alone.
Core Philosophy
The main agent is an orchestrator, not a dump pipe.
Its job is to:
- 1. Classify the request
- Decide whether to keep it local or dispatch it
- Send a bounded task contract to the right sub-agent
- Coordinate parallel work only when safe
- Verify outputs before presenting one clean answer
Sub-agents execute scoped work. The main agent owns correctness.
OpenClaw Local Compatibility
This skill is written to fit the current local OpenClaw profile instead of overriding it.
Respect these existing limits:
- - Allowed sub-agents:
codex, invest, content, knowledge, INLINECODE4 - ACP dispatch: enabled
- Default ACP agent: INLINECODE5
- Maximum concurrent sub-agents: INLINECODE6
Do 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.
OpenClaw Routing Map
Use these mappings before introducing any custom routing logic:
| Task Type + Domain | OpenClaw Agent | Notes |
|---|
| INLINECODE12 | INLINECODE13 | Use for bounded codebase investigation and root-cause analysis. |
| INLINECODE14 |
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. |
Orchestration Lifecycle
CODEBLOCK0
Task Model
This template uses two routing dimensions.
1. Task Type
Task type describes what kind of work is being requested:
- -
explore — investigate, inspect, analyze, answer bounded questions - INLINECODE33 — write or modify code/content/configuration
- INLINECODE34 — test, validate, review, compare, check constraints
- INLINECODE35 — perform external actions, archive, publish, update systems
2. Domain
Domain describes what area the task belongs to:
- - INLINECODE36
- INLINECODE37
- INLINECODE38
- INLINECODE39
- INLINECODE40
The orchestrator should classify both. "Fix this bug" is not only code; it is usually implement + code, and may need explore + code first.
Local vs Delegated Execution
Do not spawn by default. Spawn when delegation materially improves quality, speed, or isolation.
Keep It Local When
- - The task is a simple direct question
- The work is blocking the next immediate step
- The task is too coupled to current reasoning context
- Dispatch overhead is higher than doing it directly
- The user explicitly wants the current agent to do it
Delegate When
- - The work is bounded and well-defined
- The task can run in parallel with other work
- A sub-agent is a better fit for the task type
- A scoped implementation can be isolated safely
- Verification can remain with the main agent
No-Spawn Rules
Check these before any routing logic.
Typical no-spawn rules:
- - "What is X" or simple factual questions -> answer directly
- "你自己来" / "你直接做" -> keep local
- Tight blocking work needed for the next action -> keep local
- Highly coupled edits with unclear boundaries -> keep local first
Dispatch Rules
Rule 1: Route by task type first
Choose the right execution pattern before choosing a domain.
Examples:
- -
explore + code -> INLINECODE45 - INLINECODE46 -> INLINECODE47
- INLINECODE48 ->
main first - INLINECODE50 -> INLINECODE51
Rule 2: Always send a task contract
Never dispatch vague instructions like "go handle this".
Every delegated task should include:
- - goal
- expected output
- owned files or owned scope
- forbidden files or forbidden scope
- blocking vs sidecar status
- verification method
See references/task-contract-template.md.
Rule 3: Parallelize only when safe
Parallel work is useful only when tasks do not collide.
Good candidates:
- - multiple read-only exploration tasks
- implementation tasks with disjoint write scopes
- verification running while non-overlapping implementation continues
- at most
2 concurrent sub-agents in the current OpenClaw profile
Bad candidates:
- - two agents editing the same files
- tasks whose outputs must be known before the next step
- work that depends on hidden shared context
See references/parallel-dispatch-rules.md.
Status Model
Track delegated work explicitly.
Recommended statuses:
- - INLINECODE53
- INLINECODE54
- INLINECODE55
- INLINECODE56
- INLINECODE57
- INLINECODE58
This makes recovery decisions concrete. A blocked task is different from a completed task with review gaps.
Acceptance Workflow
Sub-agent output is not complete until the main agent verifies it.
Verify:
- 1. Was the right skill or workflow used?
- Did the agent stay inside its task boundary?
- Is the output materially complete?
- Did it produce the expected artifact or result?
- Is there any conflict with other agent outputs?
- Has the claimed verification actually been run?
See references/acceptance-patterns.md.
Recovery Workflow
When delegated work fails:
- 1. Diagnose the exact failure point
- Decide whether the main agent can fill the gap
- Re-route only if another agent is a better fit
- Update routing rules if the misroute was systematic
- Keep ownership of the final answer
INLINECODE59 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.
Recommended References
OpenClaw Starter Pattern
For the current local OpenClaw setup, use this compact decision sequence:
CODEBLOCK1
Key Reminders
- 1. Route by task type before domain, then map to an allowed OpenClaw agent id
- Keep blocking or tightly coupled work local
- Dispatch bounded tasks, not vague requests
- Never exceed the local sub-agent concurrency limit of INLINECODE72
- Verify sub-agent claims independently
- Synthesize one final answer instead of forwarding fragments
技能名称: Agent Orchestrator Template
详细描述:
Agent Orchestrator 模板
一种用于主智能体的框架,使其协调专门的子智能体,而不是独自尝试执行任务的每个部分。
核心理念
主智能体是编排者,而非倾倒管道。
其职责是:
- 1. 对请求进行分类
- 决定是本地处理还是分派出去
- 将范围明确的任务契约发送给正确的子智能体
- 仅在安全时协调并行工作
- 在呈现一个清晰的答案前验证输出
子智能体执行范围限定的工作。主智能体负责正确性。
OpenClaw 本地兼容性
此技能的编写旨在适应当前的本地 OpenClaw 配置文件,而非覆盖它。
请尊重这些现有限制:
- * 允许的子智能体:codex、invest、content、knowledge、community
- ACP 分派:已启用
- 默认 ACP 智能体:codex
- 最大并发子智能体数量:2
不要发明本地 OpenClaw 配置尚未允许的智能体 ID。如果任务未明确映射到允许的智能体之一,则保持本地处理。
如果你需要的智能体种类超过本地的五种,请在路由配置层面扩展注册表,而不是修改此技能描述。路由模式中现在支持的 agents 块允许你声明智能体元数据(id、description、capabilities),并通过 preferredagent/fallbackagent 引用这些 ID。references/openclaw-playbook.md 中的当前 OpenClaw 配置文件是一个可运行的示例,但你可以在 examples/custom-agent-registry.yaml 中注册额外的智能体(如 ops-specialist、researcher 等),而无需触及本地工作区约束。
OpenClaw 路由映射
在引入任何自定义路由逻辑之前,请使用以下映射:
| 任务类型 + 领域 | OpenClaw 智能体 | 备注 |
|---|
| explore + code | codex | 用于范围限定的代码库调查和根因分析。 |
| implement + code |
codex | 默认编码路径。主智能体仍负责验收。 |
| verify + code | 首先 main,仅在需要时使用 codex | 保持最终验证在本地,除非范围限定的审查者传递有用。 |
| operate + knowledge | knowledge | 归档、笔记组织、知识库更新。 |
| explore + knowledge | knowledge | 搜索、检索、笔记检查、存档查找。 |
| implement + content | content | 起草、重写、标题/大纲/内容生成。 |
| operate + community | community | 发帖、回复、互动、社区侧操作。 |
| explore + invest | invest | 市场/股票/基本面分析。 |
| operate + invest | invest | 观察列表、模拟交易、结构化金融工作流。 |
| 模糊或紧密耦合的工作 | main | 保持本地处理,直到边界明确。 |
编排生命周期
text
- 1. 接收任务
- 检查禁止生成规则
- 分类任务类型和领域
- 决定本地执行还是委派执行
- 编写任务契约
- 分派一个或多个子智能体
- 跟踪状态
- 验证输出
- 解决差距或冲突
- 综合最终答案
任务模型
此模板使用两个路由维度。
1. 任务类型
任务类型描述了请求的是何种工作:
- * explore — 调查、检查、分析、回答范围明确的问题
- implement — 编写或修改代码/内容/配置
- verify — 测试、验证、审查、比较、检查约束
- operate — 执行外部操作、归档、发布、更新系统
2. 领域
领域描述了任务属于哪个领域:
- * code
- knowledge
- content
- community
- invest
编排者应对两者进行分类。“修复这个 bug”不仅仅是 code;它通常是 implement + code,并且可能首先需要 explore + code。
本地执行 vs 委派执行
默认情况下不要生成子智能体。仅在委派能实质性地提升质量、速度或隔离性时才生成。
保持本地执行的情况
- * 任务是简单的直接问题
- 工作阻塞了下一个立即步骤
- 任务与当前推理上下文耦合过紧
- 分派开销高于直接执行
- 用户明确希望当前智能体执行
委派执行的情况
- * 工作是范围限定且定义明确的
- 任务可以与其他工作并行运行
- 子智能体更适合该任务类型
- 范围限定的实现可以安全隔离
- 验证可以保留给主智能体
禁止生成规则
在任何路由逻辑之前检查这些规则。
典型的禁止生成规则:
- * “什么是 X”或简单的事实性问题 -> 直接回答
- “你自己来” / “你直接做” -> 保持本地
- 下一个操作所需的紧密阻塞工作 -> 保持本地
- 边界不明确的高度耦合编辑 -> 首先保持本地
分派规则
规则 1:首先按任务类型路由
在选择领域之前,先选择正确的执行模式。
示例:
- * explore + code -> codex
- implement + code -> codex
- verify + code -> 首先 main
- operate + knowledge -> knowledge
规则 2:始终发送任务契约
切勿分派模糊的指令,如“去处理这个”。
每个委派的任务都应包括:
- * 目标
- 预期输出
- 拥有的文件或拥有的范围
- 禁止的文件或禁止的范围
- 阻塞状态 vs 边车状态
- 验证方法
参见 references/task-contract-template.md。
规则 3:仅在安全时并行化
仅当任务不冲突时,并行工作才有用。
好的候选:
- * 多个只读探索任务
- 具有不相交写入范围的实现任务
- 验证与非重叠的实现同时运行
- 在当前 OpenClaw 配置中最多 2 个并发子智能体
不好的候选:
- * 两个智能体编辑相同的文件
- 其输出必须在下一步之前已知的任务
- 依赖于隐藏共享上下文的工作
参见 references/parallel-dispatch-rules.md。
状态模型
显式跟踪委派的工作。
推荐的状态:
- * pending
- inprogress
- blocked
- needsreview
- completed
- abandoned
这使得恢复决策具体化。阻塞的任务不同于已完成但存在审查差距的任务。
验收工作流
在主智能体验证之前,子智能体的输出不算完成。
验证:
- 1. 是否使用了正确的技能或工作流?
- 智能体是否停留在其任务边界内?
- 输出在实质上是否完整?
- 是否产生了预期的工件或结果?
- 是否与其他智能体的输出存在冲突?
- 声称的验证是否实际运行过?
参见 references/acceptance-patterns.md。
恢复工作流
当委派的工作失败时:
- 1. 诊断确切的失败点
- 决定主智能体是否可以填补空白
- 仅当另一个智能体更合适时才重新路由
- 如果错误路由是系统性的,则更新路由规则
- 保持对最终答案的所有权
resume-orchestration.py 在持久化状态文件上运行,并重放正在进行中的工作。它重用现有的 dispatchid/bundledir,轮询适配器,并完成标记为 dispatched 或 running 的任务,而不分派新的包。在调用恢复脚本之前,使用 scripts/state-store.py update-resume 检查或修复恢复元数据,包括 maxattempts、retryablefailurecodes 和 nextretry_after。
为了操作员可见性,watch-state.py 打印每个任务当前状态的快照,包括 status、attemptcount、lastdispatch_status 和计划的重试时间戳,而不重放钩子日志。
推荐参考