Repository navigation
Reject external Turn retries when the captured work changes - #8828
Conversation
Signed-off-by: LoopX Agent <[email protected]>
Signed-off-by: LoopX Agent <[email protected]>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent / gpt-6.1-sol / OpenAI / runtime_reported / reasoning effort max
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
复审提交 184edcc,目标主干 8ade78c。涉及用外部 stdio Host 重试失败 Turn 的操作者,以及在模型调用前重新检查同一工作范围的原生 Codex 调用方。原 Turn 首次失败后,同一 Todo 被改写正文、写入范围或能力。基线仍用原捕获派发第二次,并写回扣额。候选先核对当前约束与原捕获,变更后无新派发和扣额。File 和 SQLite 上用同一 CLI 夹具各跑六种情况。原工作及仅进度备注更新仍重试成功,原摘要和一笔扣额保持。验证用本地隔离 File/SQLite、可控 Host 及独立安装的 Core wheel。真实 Codex App 及原生 Windows 未验。
改动思路 / Approach
TypeScript 共用既有完整来源,把验证过的正文与写入范围、能力绑定到原 Todo。已有宿主 launch owner 在实际 stdio 派发前重查,journal 按原身份记录结果。本 PR 收口外部 stdio 的原工作核验与确定拒绝读回,并让已有原生启动路径复用相同工作比较。Host 启动继续依实际权限。改变前的捕获仍能按原身份读取。记录拒绝用原 journal,复用完成结果时继续走原回执。
具体改动 / Changes
验收依据 docs/reference/protocols/turn-envelope-v0.md,固定修订 8ade78c。current-work-at-launch、external-known-non-dispatch、same-capture-once 均经本地真实入口证实。原恢复协议
关键代码讲解
- selectedWorkLaunchBasis 把已验证的正文摘要、Todo ID、必需写入范围与能力合成一份比较依据。_complete_plan_source_fields 从现有 owner 的投影取可用依据,保留历史 reader。仅改进度备注的 File 和 SQLite 外部重试都通过。工作摘要 · 方案元数据
- current_turn_host_launch_decision 先检查可运行资格,再按原依据比较;stdio 共享进程 supervisor 把 guard 持到 spawn。_host_result_stage 写原 context 中明确未派发的合同拒绝。两后端中正文、所需写入范围和已可用的必需能力改变时,返回 current_turn_work_changed 且调用计数仍为 1,扣额为 0。缺失必需能力先得到 goal_launch_not_allowed 与持久化 contract_rejected。补齐能力后仍重新比较工作,得出 current_turn_work_changed。启动校验 · 原尝试记录
对主干的风险 / Risks
两版本各 12 个实测用例保留原 capture,回放无新增 Host、写回和扣额。普通旧工作重试成功且一槽。原生 Codex CLI 的缺能力拒绝仍可留下 in_progress。基线和候选两后端均复现,补齐能力后仍报原尝试结果未知。此处沿 #8266 的原发现跟进。真实原生任务的 Stop 仍由现有机制在模型返回后检查。原生缺能力现有发现 · 模型后 Stop 所在入口
语义与 CI 对齐
原源码套件 120 项通过、1 项失败。原失败用例在两个版本都注入未被 managed task 调用的 start_turn,返回 committed。将同一测试的注入点绑定实际 start_native_task_turn,两端都验证 Stop 阻止写回和扣额。另通过 396 项 DSH、65 项 TS、10 项独立 Core wheel 用例及 typecheck、RFC diff。用户侧原状态与历史保留。
我的整体评价 / Verdict
批准当前切片。stdio 启动前能区分确定拒绝和已派发的未知,原工作未变的路径仍按原身份完成一次。基线已有的 native Codex 缺能力读回问题保留在 #8266。本次安装验证使用隔离 Core,真实 App 采用和 Windows 仍待验。
English verdict: APPROVE. External stdio rejects stale captured work before dispatch, and unchanged original work still settles once.
Motivation / 动机
An external stdio adapter could resume a failed Turn after the selected Todo changed. File and SQLite reproduced the same behavior on main: the retry received the original task body, ran the Host a second time, and settled one debit. Native Codex on the C1 candidate already checks whether the admitted work still matches the live Todo.
Changes / 改动
Verification / 验证
current_turn_work_changed, the Host call count stays at one, and the debit count stays zero. With the same task, the original capture resumes and the total debit stays one. Replay keeps the existing effects.C1 integration reference: #8266.