From 723c2508a2036be0d393ea893d385656a3284b87 Mon Sep 17 00:00:00 2001 From: weichen Date: Thu, 1 Oct 2026 15:53:54 +0000 Subject: [PATCH 01/10] Record the task card for feature-agent-harness-p4 --- .task/feature-agent-harness-p4.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .task/feature-agent-harness-p4.md diff --git a/.task/feature-agent-harness-p4.md b/.task/feature-agent-harness-p4.md new file mode 100644 index 00000000..2b082877 --- /dev/null +++ b/.task/feature-agent-harness-p4.md @@ -0,0 +1,25 @@ +# feature/agent-harness-p4 任务卡 + +任务主记录:;状态:进行中;owner:weichen + +## 基线与授权 + +- 权威仓:ssh://git@git-ssh.u1680832.nyat.app:31411/weichen/Agent-System-Dev.git;目标分支:main;R0(initial_base_sha)= 959179f88fafa06daeab121929112069d34e8419 +- 工作区:/home/weichen/projects/Agent-System-Dev-wt-feature-agent-harness-p4(worktree);分支:feature/agent-harness-p4 +- 授权与交付终点:<本次允许的动作与终点;未授权事项写明> + +## 目标与非目标 + +<预期结果、受影响入口/模块/契约;明确不做什么。> + +## 同步记录 + +| 节点 | sync_base_sha | tested_head_sha | checked_at | +|---|---|---|---| +| 启动 | 959179f88fafa06daeab121929112069d34e8419 | 959179f88fafa06daeab121929112069d34e8419 | 2026-10-01T15:53:54Z | + +## 结果与验证(完成后填写) + +- 结果: +- 验证: +- 影响与剩余项: -- 2.54.0 From 191d2de809478e160d762b62ff1405d17a27aad9 Mon Sep 17 00:00:00 2001 From: weichen Date: Thu, 1 Oct 2026 15:54:37 +0000 Subject: [PATCH 02/10] Record P4 authorization and workflow rulings Why: The task card is the authorization record for intent-to-workflow work, and the routing, retry, and script rulings have to be fixed before code changes. Evidence: precheck READY at 959179f88f; core/baseline.md and workflows/delivery.md section 1 were read. Impact: No product code. Six pull requests are the delivery end, and merging them is not authorized. Refs: feature/agent-harness-p4 Co-authored-by: Cursor --- .task/feature-agent-harness-p4.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.task/feature-agent-harness-p4.md b/.task/feature-agent-harness-p4.md index 2b082877..fb349f42 100644 --- a/.task/feature-agent-harness-p4.md +++ b/.task/feature-agent-harness-p4.md @@ -6,11 +6,14 @@ - 权威仓:ssh://git@git-ssh.u1680832.nyat.app:31411/weichen/Agent-System-Dev.git;目标分支:main;R0(initial_base_sha)= 959179f88fafa06daeab121929112069d34e8419 - 工作区:/home/weichen/projects/Agent-System-Dev-wt-feature-agent-harness-p4(worktree);分支:feature/agent-harness-p4 -- 授权与交付终点:<本次允许的动作与终点;未授权事项写明> +- 授权与交付终点:实现 P4 意图到工作流。允许改 Core、Backend、Frontend、UI、Documents,并在各自 `feature/agent-harness-p4` 上提 PR;Dev 仓推进 `modules/core`、`modules/backend`、`modules/frontend`、`modules/ui`、`modules/documents` 与 `plugins/example` 并提 PR。终点是六个 PR 已开、不合入。未授权:合入 main、改 agent-native、改 agent-squad 契约、动 `dev` 服务。 +- 启动自检(2026-10-01T15:52Z):`make precheck` verdict READY。head=959179f88f,origin/main 同步,树干净。必读 core/baseline.md、workflows/delivery.md §1 已读。 +- 裁定:路由先命令总线,再绑定工作流,最后才是普通回合。工作流启动时拷贝一份定义,插件卸载不影响已经在跑的工作流。声明式工作流最多 20 步;模型生成的最多 8 步,不能含 `script`,执行前必须用户确认。critic 每步最多重试 3 次、缺省 1 次,整个工作流最多重试 6 次。脚本最多回调 50 次,单行不超过 1MB,超时缺省 600s、最长 1800s(墙钟,含等待 HITL 和子代理)。脚本与 `run_python` 相同,以当前用户身份运行,工作目录为会话沙箱,没有网络或文件系统隔离。回调一律经过 `runCtx.ExecuteTool`,不能调用 `run_python`、`run_shell`、`run_workflow` 和派发类工具。模型写的脚本运行前必须确认;插件自带的脚本不需要。开关 `runtime.workflowScripts` 缺省关闭。critic 无法解析按不通过处理。小队入口不提供 `run_workflow`。 ## 目标与非目标 -<预期结果、受影响入口/模块/契约;明确不做什么。> +- 目标:`WorkflowDef` 有执行器。意图命中后接到绑定的工作流。critic 按步骤打回,每步和整条工作流都有上限。同时支持模型生成步骤和沙箱脚本两种动态工作流。 +- 非目标:不新增工作流界面和事件。Frontend 与 UI 只同步契约。不改内核与小队仓契约。不合入 main。 ## 同步记录 -- 2.54.0 From ef590bd0c34c33262cd857c790e443adcfe81f7f Mon Sep 17 00:00:00 2001 From: weichen Date: Thu, 1 Oct 2026 16:22:14 +0000 Subject: [PATCH 03/10] Add example brief and script workflows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: The example plugin needs a bound intent and a plugin-shipped script so the three P4 paths can be checked against a real plugin. Evidence: TestRepoExamplePluginLoads accepts the plugin, asks 主题是什么?, and keeps the topic slot. Impact: demo.brief starts the five-step workflow. demo.script stays unbound and needs runtime.workflowScripts. Refs: feature/agent-harness-p4 Co-authored-by: Cursor --- plugins/example/intents/demo.json | 15 ++++++ plugins/example/plugin.json | 4 ++ plugins/example/workflows/demo-brief.json | 57 ++++++++++++++++++++++ plugins/example/workflows/demo-script.json | 13 +++++ plugins/example/workflows/scripts/demo.py | 6 +++ 5 files changed, 95 insertions(+) create mode 100644 plugins/example/workflows/demo-brief.json create mode 100644 plugins/example/workflows/demo-script.json create mode 100644 plugins/example/workflows/scripts/demo.py diff --git a/plugins/example/intents/demo.json b/plugins/example/intents/demo.json index 370d3852..eccf1cc7 100644 --- a/plugins/example/intents/demo.json +++ b/plugins/example/intents/demo.json @@ -6,5 +6,20 @@ "description": "示例意图:命中『示例/演示』关键词(slots 声明即 HITL 该问什么;本示例无必填槽位)", "matcher": { "includes_any": ["示例", "演示"] }, "slots": [] + }, + { + "id": "demo.brief", + "domain": "demo", + "version": 1, + "description": "写一份简报。必填槽位 topic,没写就问「主题是什么?」。", + "matcher": { "includes_any": ["简报"] }, + "slots": [ + { + "key": "topic", + "required": true, + "pattern": "主题[::]\\s*(\\S+)", + "question": "主题是什么?" + } + ] } ] diff --git a/plugins/example/plugin.json b/plugins/example/plugin.json index 6b040d15..df19a2f1 100644 --- a/plugins/example/plugin.json +++ b/plugins/example/plugin.json @@ -32,6 +32,10 @@ ], "commands": [ "demo" + ], + "workflows": [ + "demo-brief", + "demo-script" ] } } diff --git a/plugins/example/workflows/demo-brief.json b/plugins/example/workflows/demo-brief.json new file mode 100644 index 00000000..acdb61d1 --- /dev/null +++ b/plugins/example/workflows/demo-brief.json @@ -0,0 +1,57 @@ +{ + "id": "demo.brief", + "title": "示例简报", + "description": "命中 demo.brief 后:选篇幅、起草、落成工件、发一张结果卡,再请用户确认。", + "intentId": "demo.brief", + "steps": [ + { + "id": "length", + "title": "篇幅", + "kind": "hitl", + "hitl": { + "question": "要多长?", + "kind": "choice", + "allowFreeInput": false, + "choices": [ + {"id": "short", "label": "短", "description": "一段", "impact": "只写一段"}, + {"id": "long", "label": "长", "description": "几段", "impact": "会写得更长"} + ] + } + }, + { + "id": "draft", + "title": "起草", + "kind": "prompt", + "agent": "research", + "prompt": "写一份关于「{{slots.topic}}」的简报,篇幅:{{steps.length.output}}。", + "critic": {"criteria": "必须提到主题,并且是一段能读完的简报", "maxRetries": 1} + }, + { + "id": "save", + "title": "成稿", + "kind": "artifact", + "artifact": "demo-brief.md", + "prompt": "{{steps.draft.output}}" + }, + { + "id": "note", + "title": "收件", + "kind": "card", + "card": {"kind": "result", "title": "简报好了", "tone": "ok"} + }, + { + "id": "confirm", + "title": "确认", + "kind": "hitl", + "hitl": { + "question": "这份简报可以用吗?", + "kind": "confirm", + "allowFreeInput": false, + "choices": [ + {"id": "yes", "label": "可以用", "description": "结束", "impact": "不会再改"}, + {"id": "no", "label": "先不用", "description": "结束", "impact": "不会再改"} + ] + } + } + ] +} diff --git a/plugins/example/workflows/demo-script.json b/plugins/example/workflows/demo-script.json new file mode 100644 index 00000000..1dba4a73 --- /dev/null +++ b/plugins/example/workflows/demo-script.json @@ -0,0 +1,13 @@ +{ + "id": "demo.script", + "title": "示例脚本", + "description": "插件自带脚本。需要打开 runtime.workflowScripts。不绑定意图,用 run_workflow 启动。", + "steps": [ + { + "id": "run", + "title": "跑脚本", + "kind": "script", + "script": "workflows/scripts/demo.py" + } + ] +} diff --git a/plugins/example/workflows/scripts/demo.py b/plugins/example/workflows/scripts/demo.py new file mode 100644 index 00000000..ce23392f --- /dev/null +++ b/plugins/example/workflows/scripts/demo.py @@ -0,0 +1,6 @@ +import agentwf as wf + +now = wf.tool("time_now", {}) +answer = wf.ask("要记下来吗?", [{"id": "yes", "label": "记下", "impact": "会写入一份备忘"}]) +wf.artifact("demo-script.md", "时间 " + now + "\n选择 " + answer) +wf.step("run", "跑脚本", "done") -- 2.54.0 From 54f5a33454b9720ffa33a4f18af1308a65b0dc9c Mon Sep 17 00:00:00 2001 From: weichen Date: Thu, 1 Oct 2026 16:24:37 +0000 Subject: [PATCH 04/10] Pin the P4 workflow modules Why: Dev has to record the Core, Backend, Frontend, UI, and Documents commits that implement intent-to-workflow. Evidence: make test passed, including boundary lint, core, backend, frontend vitest, UI tsc and vitest, and agent-command. Impact: agent-native stays at a34689c. The example plugin is already on this branch. Refs: feature/agent-harness-p4 Co-authored-by: Cursor --- modules/backend | 2 +- modules/core | 2 +- modules/documents | 2 +- modules/frontend | 2 +- modules/ui | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/backend b/modules/backend index 46ce1b2c..10186ab9 160000 --- a/modules/backend +++ b/modules/backend @@ -1 +1 @@ -Subproject commit 46ce1b2c8e11bbaf17dc6937d2f7365296390444 +Subproject commit 10186ab916e3eb0f306a831102766ab6d7bcba98 diff --git a/modules/core b/modules/core index 9b8cf79c..f93f473a 160000 --- a/modules/core +++ b/modules/core @@ -1 +1 @@ -Subproject commit 9b8cf79c96668628926d32046cd650f0cfbd285b +Subproject commit f93f473a0ea898785921e3c4fb16114549fd2783 diff --git a/modules/documents b/modules/documents index a3f0b807..974db6a0 160000 --- a/modules/documents +++ b/modules/documents @@ -1 +1 @@ -Subproject commit a3f0b80759fa01094cb9ee26b2a17dba831317e2 +Subproject commit 974db6a011f04ed7eb229f2807c5dc79813ffd58 diff --git a/modules/frontend b/modules/frontend index f718095d..7d796ee5 160000 --- a/modules/frontend +++ b/modules/frontend @@ -1 +1 @@ -Subproject commit f718095d783d7e13c445a490c52551b29a3f93a8 +Subproject commit 7d796ee5070c0729d2a96ba03183799c9bb04b60 diff --git a/modules/ui b/modules/ui index bd3baff9..22666a08 160000 --- a/modules/ui +++ b/modules/ui @@ -1 +1 @@ -Subproject commit bd3baff9ea43c05597dcc92ce4c17b5a9fd255ac +Subproject commit 22666a0835e1992bc8ade80d9e3b074d9e9e5d4c -- 2.54.0 From 4836fee08f49a171cc85497868ab3317071ea7ea Mon Sep 17 00:00:00 2001 From: weichen Date: Thu, 1 Oct 2026 16:25:04 +0000 Subject: [PATCH 05/10] Require a marker so the example critic can reject once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: The live check needs the first draft to miss a line the critic can name, then the retry can add it. Evidence: The prompt does not mention the marker. maxRetries stays 1. Impact: demo.brief drafts are rejected until they contain 核对标记:P4. Refs: feature/agent-harness-p4 Co-authored-by: Cursor --- plugins/example/workflows/demo-brief.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/example/workflows/demo-brief.json b/plugins/example/workflows/demo-brief.json index acdb61d1..f7c62945 100644 --- a/plugins/example/workflows/demo-brief.json +++ b/plugins/example/workflows/demo-brief.json @@ -24,7 +24,7 @@ "kind": "prompt", "agent": "research", "prompt": "写一份关于「{{slots.topic}}」的简报,篇幅:{{steps.length.output}}。", - "critic": {"criteria": "必须提到主题,并且是一段能读完的简报", "maxRetries": 1} + "critic": {"criteria": "必须包含单独一行「核对标记:P4」。没有这一行就不通过,nextAction 请要求补上这一行。", "maxRetries": 1} }, { "id": "save", -- 2.54.0 From f125ebd68d528293cca9629772f1b63398cf049b Mon Sep 17 00:00:00 2001 From: weichen Date: Thu, 1 Oct 2026 16:28:18 +0000 Subject: [PATCH 06/10] Pin the critic model fix Why: The step critic has to call the configured model, and Dev should record that backend commit. Evidence: go test ./internal/runtime/ -run TestJudgeUsesConfiguredModel passed in the backend repo. Impact: Only the backend pointer moves. Refs: feature/agent-harness-p4 Co-authored-by: Cursor --- modules/backend | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backend b/modules/backend index 10186ab9..6026e248 160000 --- a/modules/backend +++ b/modules/backend @@ -1 +1 @@ -Subproject commit 10186ab916e3eb0f306a831102766ab6d7bcba98 +Subproject commit 6026e248a6d8b81572da12f6f9a5e7ef264053e9 -- 2.54.0 From 9de01d69e616d5eec8916dc81757b43ed508b691 Mon Sep 17 00:00:00 2001 From: weichen Date: Thu, 1 Oct 2026 16:32:09 +0000 Subject: [PATCH 07/10] Pin the planner and critic prompt fix Why: Dev should record the backend commit that makes planning return JSON and makes the critic reject a missing line. Evidence: go test ./internal/runtime/ ./internal/prompts/ passed on that commit. Impact: Only the backend pointer moves. Refs: feature/agent-harness-p4 Co-authored-by: Cursor --- modules/backend | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backend b/modules/backend index 6026e248..7112ace3 160000 --- a/modules/backend +++ b/modules/backend @@ -1 +1 @@ -Subproject commit 6026e248a6d8b81572da12f6f9a5e7ef264053e9 +Subproject commit 7112ace34ffa0805e7a3c2aded32a9746067271e -- 2.54.0 From 5f872f3b7f165c2a6cbef09bbcaa711f5bdf723c Mon Sep 17 00:00:00 2001 From: weichen Date: Thu, 1 Oct 2026 16:36:59 +0000 Subject: [PATCH 08/10] Pin the script copy fix for tool-started workflows Why: Dev should record the backend commit that runs a registered script from the launch of that call. Evidence: go test ./internal/runtime/ -run TestRegisteredWorkflowUsesItsOwnScriptCopy passed. Impact: Only the backend pointer moves. Refs: feature/agent-harness-p4 Co-authored-by: Cursor --- modules/backend | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backend b/modules/backend index 7112ace3..4b4be2be 160000 --- a/modules/backend +++ b/modules/backend @@ -1 +1 @@ -Subproject commit 7112ace34ffa0805e7a3c2aded32a9746067271e +Subproject commit 4b4be2be259639b0e192aedc72921289de2d0ed3 -- 2.54.0 From 0cdc2d2405ab0351c5b2eb489f9487430c8475fc Mon Sep 17 00:00:00 2001 From: weichen Date: Thu, 1 Oct 2026 16:38:23 +0000 Subject: [PATCH 09/10] Record the sync checkpoint --- .task/feature-agent-harness-p4.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.task/feature-agent-harness-p4.md b/.task/feature-agent-harness-p4.md index fb349f42..fc2d9c80 100644 --- a/.task/feature-agent-harness-p4.md +++ b/.task/feature-agent-harness-p4.md @@ -26,3 +26,4 @@ - 结果: - 验证: - 影响与剩余项: +| 同步前验收 | 959179f88fafa06daeab121929112069d34e8419 | 5f872f3b7f165c2a6cbef09bbcaa711f5bdf723c | 2026-10-01T16:38:23Z | -- 2.54.0 From cd984219da215db5978e7916c0439df74ce7b5aa Mon Sep 17 00:00:00 2001 From: weichen Date: Thu, 1 Oct 2026 16:38:51 +0000 Subject: [PATCH 10/10] Record P4 test evidence and the live workflow check Why: Acceptance needs the precheck, task-sync, and make test evidence on the card, plus what the three live conversations actually did. Evidence: make test passed at 5f872f3. The sync row is in the table. The p4 service produced the slot question, one critic rejection, a confirmed plan, and the plugin script artifact. Impact: Documentation only. The six pull requests stay unmerged. Refs: feature/agent-harness-p4 Co-authored-by: Cursor --- .task/feature-agent-harness-p4.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.task/feature-agent-harness-p4.md b/.task/feature-agent-harness-p4.md index fc2d9c80..174efb3a 100644 --- a/.task/feature-agent-harness-p4.md +++ b/.task/feature-agent-harness-p4.md @@ -20,10 +20,10 @@ | 节点 | sync_base_sha | tested_head_sha | checked_at | |---|---|---|---| | 启动 | 959179f88fafa06daeab121929112069d34e8419 | 959179f88fafa06daeab121929112069d34e8419 | 2026-10-01T15:53:54Z | +| 同步前验收 | 959179f88fafa06daeab121929112069d34e8419 | 5f872f3b7f165c2a6cbef09bbcaa711f5bdf723c | 2026-10-01T16:38:23Z | ## 结果与验证(完成后填写) -- 结果: -- 验证: -- 影响与剩余项: -| 同步前验收 | 959179f88fafa06daeab121929112069d34e8419 | 5f872f3b7f165c2a6cbef09bbcaa711f5bdf723c | 2026-10-01T16:38:23Z | +- 结果:Core `f93f473` 给步骤加上 Agent、Script、Critic,kind 增加 script。Backend `4b4be2b` 注册工作流、按意图启动、执行六类步骤、确认后跑模型规划、以及 fd 3/fd 4 脚本宿主。Frontend `7d796ee` 与 UI `22666a0` 只同步了契约。Documents `974db6a` 写入 P4 裁定。Dev `5f872f3` 推进这五个模块,并给示例插件加上 `demo.brief` 与 `demo.script`。 +- 验证:启动时 `make precheck` 为 READY,head `959179f88f`(2026-10-01T15:52Z)。`make task-sync` 记录 sync_base `959179f88f`、tested_head `5f872f3`、checked_at 2026-10-01T16:38:23Z。随后在该 head 上 `make test` 通过:边界检查、core、backend、frontend vitest 53、UI tsc 与 vitest 71、agent-command。三处 agent-native 仍是 `a34689c`。p4 服务(127.0.0.1:8929,数据从 dev 备份,未改 dev)核对了三项:会话 `cnv_e3f0cf85f48d` 中「写一份简报」先问「主题是什么?」,critic 打回一次并留下丢弃理由,重跑后完成,工件 `art_76f9b51b4e27`,收件箱有「简报好了」。会话 `cnv_ccba204decb3` 中 `run_workflow` 的 goal 先请用户确认计划,确认后执行完成。打开 `runtime.workflowScripts` 后,会话 `cnv_adadae794ae2` 跑插件脚本 `demo.script`,脚本问「要记下来吗?」,确认后产出 `demo-script.md`(`art_13fe6947ef6e`)。 +- 影响与剩余项:六个 PR 不合入。核对用的 p4 服务在收尾时删除。脚本没有沙箱隔离,靠开关、确认和回调白名单。墙钟超时包含等待人工的时间。 -- 2.54.0