fix(agent): preserve llm_free resources under plan force

Stop plan from clobbering an existing resources workbook with an explore
skeleton. Add llm.prompt helpers and agent-plan-preserve gold.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-24 19:34:05 +08:00
1 parent d8d435fead
commit 4a2d89406b
10 files changed
+151 -28

No files matched your search

+1 -1
View File
@@ -194,7 +194,7 @@ ext/
| `## 分解` | `## decompose` |(可公开或内部)目标 → 子任务表 |
| `## 清空历史` | `## clear_history` | 若仍保留会话式辅助状态则清空;**不以隐藏 chat 袋为真相源**——真相在文档写回 |
**Skill Compilation(v2)**:Agent 的记忆不是向量袋,而是可执行 `.mq.md`。路径:`episodes/` → `experiences/` → `candidates/` → `skills/vN.mq.md` → OKF `agent-kb`(`llm_free`)。编译技能正文为合法 Marqdo(`**result = …**` + 斜体返回);金样 `tests/ext/agent-zero-llm.mq.md` 验收 policy+skill 全路径 `execution.llm_calls=0`。
**Skill Compilation(v2)**:Agent 的记忆不是向量袋,而是可执行 `.mq.md`。路径:`episodes/` → `experiences/` → `candidates/` → `skills/vN.mq.md` → OKF `agent-kb`(`llm_free`)。编译技能正文为合法 Marqdo(`**result = …**` + 斜体返回);金样 `tests/ext/agent-zero-llm.mq.md` 验收 policy+skill 全路径 `execution.llm_calls=0`。`plan` 对已存在的 `resources/<slug>.mq.md` **不覆盖**(`agent-plan-preserve`)。
**LLM 成本**:`model_turn` 走 `model.ask` / `stream`+`collect`,把 `LLMResult.tokens` 写入 episode / `execution`。
+3 -2
View File
@@ -31,7 +31,7 @@ import llm:ext/ai/llm.mq.md
| `## load_env` | `## 加载环境` | Load `.env` |
| `## create` | `## 创建` | Factory → LLM handle |
| `## fast` / `## reasoning` | `## 快速` / `## 推理` | Named handles |
| `## prompt_load` | `## 加载提示` | Load prompt artifact (`type: prompt` → body) |
| `## prompt_load` / `## prompt` / `## prompt_body` | `## 加载提示` / `## 提示` / `## 提示正文` | Prompt artifacts (`type: prompt` → body) |
| `## ask` (module) | `## 提问` | Convenience → **text** (`prompt=` or `path=`) |
| `## collect` | `## 收集` | Events → text |
| `## stream_result` | `## 流式结果` | Alias of `collect` |
@@ -54,7 +54,8 @@ import llm:ext/ai/llm.mq.md
**events = > `fast`.stream prompt=`prompt`**
**text = > llm.collect events=`events`**
**body = > llm.prompt_load path="fixtures/prompt-marqdo.md"**
**body = > llm.prompt path="fixtures/prompt-marqdo.md"**
**body2 = > llm.prompt text=`raw`**
```
### LLMResult
+5 -4
View File
@@ -31,7 +31,7 @@
| `create` 工厂;handle 带 `backend` | **done** |
| LLMResult:`text` / `model` / `finish` / `backend` / `usage` / `tokens` | **done** |
| Named models(`llm.fast` / `llm.reasoning`) | **done** |
| Prompt document:`prompt_load` + `type: prompt` 正文 | **done**(`ask path=` / `llm.ask` 无参吃当前文档仍暂缓) |
| Prompt document:`prompt` / `prompt_load` + `type: prompt` 正文 | **done**(`llm.ask` 无参吃当前入口文档仍暂缓,需 `sys.module_source`) |
| 拆 `ext/ai/llm/openai.mq.md` + `ollama` 后端 | **done** |
| tool_calls 完整 Result | 暂缓 |
| Transport → 可选 ABI 插件 | 暂缓 |
@@ -43,7 +43,7 @@
**events = > model.stream prompt=`p`**
**text = > llm.collect events=`events`**
**fast = > llm.fast**
**prompt = > llm.prompt_load path="prompts/task.md"**
**prompt = > llm.prompt path="prompts/task.md"**
```
## 4. Agent(002–004)— 已/待
@@ -55,8 +55,9 @@
| Policy Compilation → `policies/router.mq.md` | **done** |
| `run` 串联 route → execute → record → learn | **done** |
| Agent 默认走 `model.ask` + Result.usage 记成本 | **done**(`model_turn`) |
| Prompt artifact / document-as-prompt | **done**(经 llm `path=`) |
| Prompt artifact / document-as-prompt | **done**(经 llm `path=` / `prompt`) |
| 零 LLM 执行(policy+skill → `llm_calls=0`) | **done** |
| `plan` 不覆盖已有 `llm_free` resource | **done** |
| 真 MCP client / resume / Jev 接线 / 小模型 live 路由 | 暂缓 |
## 5. 联调顺序
@@ -69,5 +70,5 @@
## 6. 验收金样
- Agent:`tests/ext/agent-v2-learn.mq.md` · `agent-p4-route.mq.md` · `agent-zero-llm.mq.md` · `scripts/agent-harness.sh`
- Agent:`tests/ext/agent-v2-learn.mq.md` · `agent-p4-route.mq.md` · `agent-zero-llm.mq.md` · `agent-plan-preserve.mq.md` · `scripts/agent-harness.sh`
- LLM:`tests/ext/llm-ask-offline.mq.md` · `llm-stream-offline.mq.md` · `llm-ctor-offline.mq.md` · `llm-named-offline.mq.md`