Skip to content

Guide fenced heartbeat receipts to the next host Turn - #9313

Open
huangruiteng wants to merge 1 commit into
mainfrom
codex/c1-fenced-recovery-guidance-20261123
Open

huangruiteng wants to merge 1 commit into
mainfrom
codex/c1-fenced-recovery-guidance-20261123

Conversation

@huangruiteng

Copy link
Copy Markdown
Collaborator

Why

When a prepared heartbeat Turn loses its task lease generation, the CLI refuses to resume that Turn. The old receipt-conflict guidance still asked the caller to re-enter the same Turn, which returned the same conflict even after removing the explicit Todo selector.

What changed

  • The quota CLI directs a fenced Turn to the next real host Turn for the existing execution-loss closeout without quota spend. Other binding conflicts still offer the same-Turn re-entry route. CLI guidance
  • The File and SQLite regressions enter the original Turn after a real claim changes its generation. They verify the original settlement identity, unchanged stored state, and the fresh host Turn's existing preview and closeout flow. Regression

Validation

  • The two new assertions failed on the pinned base at the guidance check.
  • Execution-loss closeout and bound-wait suites passed all 25 tests on the proposed head.
  • Ruff, the CLI output-budget smoke, and exact-scope change-quality verification passed.
  • The standard premerge gate passed with 6 direct and 18 selected checks.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

动机 / Motivation

使用 heartbeat 接续工作的 Agent,在重试已取得执行租约的 Turn 时可能遇到租约换代。 旧 CLI 在拒绝换代后的重入时仍建议重试同一个 Turn。即使去掉 Todo 选择器,Agent 也会再次收到同一拒绝。

在 File 和 SQLite 上先取得有效租约并留存准入回执,再让同一执行者重新取得不同代的租约,最后去掉 Todo 选择器重入原 Turn。 候选版在原 Turn 上保留拒绝和原始回执,并引导 Agent 等候下一次宿主触发。新 Turn 能投影原 Turn 的收尾,完成后原 Todo 可以继续。 范围是 CLI 拒绝时的接续指导。原租约规则、写回、扣额、宿主调度和持久化格式沿用现有契约。

改动思路 / Approach

Python 只改现有错误投影。由 TypeScript 的原始回执以及租约 owner 判定准入和收尾。 保留一处错误投影,修正已知死循环的引导,并以独立 File/SQLite 场景测试另一类冲突。 按现有恢复规范验证从原准入到下一轮重新推进,检查了原回执、实际预览和提交,也测试了仍应在原轮处理的其他冲突。

具体改动 / Changes

两个文件合计 +19/−5。生产代码替换一段错误指引,测试扩展原来 File 与 SQLite 的接续用例。下列两项均覆盖到了真实 CLI。执行丢失收尾契约

  • 换代后不重开原执行(implemented)。原回执和租约代仍拒绝恢复旧执行。
  • 新轮次行政收尾与零扣额(implemented)。新宿主轮次仍能指向行政收尾,通过当前控制写入者校验后预览、提交并回读零扣额。

关键代码讲解

对主干的风险 / Risks

最可能误伤的是把其他绑定冲突也解释成等待新轮次。两端都以实际 File/SQLite CLI 选错另一个 Todo,再去掉选择器。原 Turn 用同一回执恢复。候选的普通 JSON 和 Codex 捕获输出均保留换代拒绝与新指引。新宿主 Turn 的收尾预览不改原记录,提交后回读零扣额,重复提交没有重复追加。

另一执行者接手的路径也做了对照。两个版本在原 Turn 都会显示通用运行标记,同时缺少执行准备凭据。新 Turn 仍要求控制写入权限,错误凭据在预览被拒绝。这条相邻诊断缺口已存在于基线,当前改动只覆盖明确发出身份冲突的分支。

语义与 CI 对齐

复用 heartbeat_receipt_identity_conflict 和原行政收尾契约。改变的是匹配情形的恢复文本。base/head 各 8 个独立 CLI 实例通过。候选源码 36 项现有测试通过,标准 premerge 6 个直接和 18 个选中检查通过。 验证使用受控时钟和独立本地数据,远端 CI 未查询。

我的整体评价 / Verdict

APPROVE。候选避免了原执行者拿到新一代租约后,按旧提示反复进入已经拒绝的 Turn。实测在下一宿主轮提供的授权路径可完成原收尾,之后新轮次能继续工作。纠正选择器仍留在原轮。验证使用源码 CLI 和隔离的真实 File、SQLite provider,测试时钟用于跨过到期点。真实 Codex 调度器的时间间隔和模型是否采纳文字未作实测。

英文简短结论

English verdict: APPROVE — 6c6ac0ebc7e5 directs the fenced replay to the next host Turn and preserves same-Turn selector recovery. File and SQLite checks verified idempotent closeout with no quota debit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants