diff --git a/docs/design/v2.8-executor-prompt-design.md b/docs/design/v2.8-executor-prompt-design.md index a906766..e469cbe 100644 --- a/docs/design/v2.8-executor-prompt-design.md +++ b/docs/design/v2.8-executor-prompt-design.md @@ -48,6 +48,53 @@ └─────────────────────────────────────────────────────────┘ ``` +### 注入机制说明 + +| 层 | 谁生成 | 怎么注入到 Agent | 代码位置 | +|----|--------|-----------------|----------| +| L1(SOUL/IDENTITY/MEMORY) | OpenClaw Agent 配置 | OpenClaw Gateway 自动加载 Agent workspace 文件 | `~/.openclaw/agents/{agent_id}/workspace/` | +| L2a(executor.md) | moziplus 模板文件 | BootstrapBuilder `_load_template("executor.md")` | `bootstrap.py` | +| L2b(项目背景) | BootstrapBuilder 代码 | `build()` → `_format_project_context()` | `bootstrap.py` | +| L2c(任务上下文) | BootstrapBuilder 代码 | `build()` → `_format_task_context()` | `bootstrap.py` | +| L2d(前序信息) | BootstrapBuilder 代码 | `build()` → `_format_depends_on()` | `bootstrap.py` | +| L2e(Guardrail 规则) | Daemon 从配置加载 | `build(guardrail_rules=...)` | `spawner.py` → `bootstrap.py` | +| L2f(审查协议) | Daemon 从配置加载 | `build(review_protocols=...)` | `spawner.py` → `bootstrap.py` | +| L2g(经验注入) | experiences 表 | `build(experiences=...)` | `spawner.py` → `bootstrap.py` | +| L3(Skill descriptions) | Skill 目录 | `build(skill_descriptions=...)` | `spawner.py` → `bootstrap.py` | +| L3b(知识注入) | v2.9 新增,grep wiki index.md | `build(wiki_knowledge=...)` | `spawner.py` → `bootstrap.py` | +| API 命令 | `_build_api_section()` 代码 | 拼在 bootstrap 后面 | `spawner.py` | + +**完整调用链**: + +``` +ticker.py _dispatch_pending() + │ + └── dispatcher.py dispatch(task) + │ + ├── router.py route(task) → 决定 agent_id + │ + └── spawner.py build_spawn_message(task, agent_id) + │ + ├── bootstrap_builder.build_for_task(task, role="executor") + │ └── build(role, task_context, ...) + │ ├── L2a: _load_template("executor.md") ← 新建这个文件 + │ ├── L2b~L2g: 各层自动拼装 + │ └── L3: _format_skills() + │ + ├── _build_api_section(project_id, task_id, agent_id) + │ └── 具体 curl 命令(动态参数) + │ + └── 返回完整 message 文本 + │ + spawner.spawn_full_agent(agent_id, message) + │ + └── openclaw agent --agent {agent_id} --message "{message}" + │ + └── OpenClaw Gateway 把 message 发到 Agent session + │ + └── Agent 在 session 里看到完整 prompt +``` + --- ## 三、executor.md 完整内容