fix(web): treat duplicate rectification tool calls as idempotent

Aborting the turn on a second identical public tool-call failed staging
after evidence and compare had already succeeded. Skip the duplicate
receipt instead and let maxSteps bound real loops.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-08-25 11:46:20 +08:00
parent 994b34a339
commit 01ac4b9b56
4 changed files with 131 additions and 18 deletions
+19 -3
View File
@@ -5531,6 +5531,22 @@
- 复发自:无
- 修复版本:未修复
## BUG-372 | 生时纠正同一轮重复工具调用把已成功写入打成失败
- 状态:resolved
- 首次发现:2026-08-25
- 最近更新:2026-08-25
- 影响面:`POST /api/rectification/agent``runV9AgentTurn` 观察器、公开 NDJSON
- 用户现象:同一轮已读盘、写入证据、跑完诊断和候选比较后,流以 `run.failed` / `repeated_tool_call` 结束,文案「本轮没有完成,状态已记录。」,没有助手叙述。公开事件里每个工具只出现一次 started/completed。
- 触发条件:`action=message` 的自由文本经历回合;模型在 `rectification-compare-candidates`(或同类只含 caseId 的公开工具)完成后,又发出一次相同工具名与相同参数的 `tool-call`
- 根因:BUG-368 P0-3 把「相同工具参数」做成观察器硬上限 1,第二次相同 `toolName + args` 在发布 `tool.activity` started 之前抛错。该码不在自动重试集合,`recoverable=false`。证据与比较已经落库,只是本轮被标失败且跳过 dossier 叙述器。`rectification-set-focus` 已从 Agent 工具列表移除,这条防线不再对应真实循环。
- 修复:相同公开工具调用视为幂等,跳过重复的 started/phase 收据,不 abort、不 `attempt.reset`。真循环仍由 `maxSteps` 与超时约束。无模型正文时走既有服务器叙述。不改已哈希 Skill `10.0.11`
- 验证:`frontend/tests/rectification-v9-agent.test.ts` 锁定重复 read-case 完成叙述且无 `run.failed``frontend/tests/rectification-v9-stream.test.ts` 锁定重复 set-focus 继续出回答、诊断后重复 compare 走叙述且无 `attempt.reset`
- 防复发:禁止对第二次相同公开 `tool-call``repeated_tool_call` 或失败整轮。禁止把幂等工具调用放进自动重试。禁止用观察器 abort 代替 `maxSteps` / timeout。
- 相关记录:BUG-368、BUG-367
- 复发自:BUG-368(去掉模型驱动 set-focus 后,仍用 abort-on-second-identical-call 防循环,误杀正常比较重发)
- 修复版本:待发布
## BUG-371 | staging publish 的 next build 找不到 createServerSupabaseClient
- 状态:resolved
@@ -5588,10 +5604,10 @@
- 用户现象:用户说「2020年4月开始实习、6月转正、10月离职」后,界面先刷出残缺英文(`Let me``_probe``_gain`)。`rectification-set-focus` 连续失败后整轮重跑,已成功的证据再提交一次,只落地实习、另外两条被引文拒。随后聊天里出现一条用户从未输入的「2002 年发生什么了」。
- 触发条件:自由文本经历回合;Agent 在调用工具前输出规划文本;`set-focus` 因重复探针或零信息增益被拒;失败运行的推荐问题被写进历史。
- 根因:三组独立回归。(1) 禁止 `thinking.delta` 后,把每个 step 的 `text-delta` 都公开成 `answer.delta`,工具前规划变成用户正文;再对碎片做英文过滤,句子被剪成残片。(2) `compare-candidates` 已算出下一问,仍让模型自己调 `set-focus`;确定性校验失败后 `attempt.reset` 重放已成功的 Evidence 写入。(3) 未完成运行的 suggestion / 角色映射把「2002 年发生什么了」写成 user 消息。2002 不是引擎从 2020 算出来的。
- 修复:按 step 缓冲,只发布无工具且 `stop`/`length` 的终端文本;`reasoning-delta` 不下发。Agent 工具列表去掉 `set-focus`,由 compare/read-case 在服务端持久化 `open_question``duplicate_focus` 等域错误不整轮重试,相同工具参数最多一次。用户消息记录 `origin`/`clientActionId`/`content_hash`。Evidence quote 用源消息 offset,按条返回 created/already_exists/quote_mismatch。推荐问题只在 `run.completed` 后解析,纠正 UI 仍无 suggestion chip。不改已哈希 Skill `10.0.11`
- 修复:按 step 缓冲,只发布无工具且 `stop`/`length` 的终端文本;`reasoning-delta` 不下发。Agent 工具列表去掉 `set-focus`,由 compare/read-case 在服务端持久化 `open_question``duplicate_focus` 等域错误不整轮重试。同一流里相同公开工具参数视为幂等,不得 abort 整轮;循环由 `maxSteps` / timeout 约束。用户消息记录 `origin`/`clientActionId`/`content_hash`。Evidence quote 用源消息 offset,按条返回 created/already_exists/quote_mismatch。推荐问题只在 `run.completed` 后解析,纠正 UI 仍无 suggestion chip。不改已哈希 Skill `10.0.11`
- 验证:`frontend/tests/rectification-step-answer.test.ts``frontend/tests/rectification-v9-stream.test.ts``frontend/tests/rectification-server-focus.test.ts``frontend/tests/rectification-evidence-quote.test.ts``frontend/tests/rectification-agentic-entry.test.ts``frontend/tests/rectification-v10-tool-contract.test.ts`
- 防复发:禁止把含工具调用的 step 的 `text-delta` 发给浏览器。禁止把 `thinking.delta` 改名为 `answer.delta`。禁止模型驱动 `set-focus`。禁止对 `duplicate_focus` / `quote_mismatch` / `zero_information_gain``attempt.reset`。禁止未完成运行解析或自动提交 suggestion。禁止模型改写 Evidence quote。
- 相关记录:BUG-345、BUG-354、BUG-357、BUG-367
- 防复发:禁止把含工具调用的 step 的 `text-delta` 发给浏览器。禁止把 `thinking.delta` 改名为 `answer.delta`。禁止模型驱动 `set-focus`。禁止对 `duplicate_focus` / `quote_mismatch` / `zero_information_gain``attempt.reset`。禁止对第二次相同公开工具调用 abort 整轮(见 BUG-372)。禁止未完成运行解析或自动提交 suggestion。禁止模型改写 Evidence quote。
- 相关记录:BUG-345、BUG-354、BUG-357、BUG-367、BUG-372
- 复发自:BUG-367(关掉公开 `thinking.delta` 后,中间 step 的 `text-delta` 被整段当成回答)
- 修复版本:fe87a9ecdb71eae4eb79664664cc20c534177c19