Repository navigation
Use the remaining native preparation time for readiness - #9008
Conversation
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI (runtime_reported, max)
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
Codex App heartbeat 或 SSH Goal 的操作者等待 LoopX 为选中的 Todo 取得执行凭据。原实现把 8 秒切成两个固定的 4 秒。claim 很快完成时,稍慢的 ready 检查仍转入回执恢复。 候选提交让 ready 检查使用当前期限的剩余时间。超时仍能按原 claim、lease 和 Turn 继续恢复。此次独立核验覆盖本地原生 Hook 和两种实际后端。安装环境、远程 SSH 的延迟及模型收益留待对应验收。
改动思路 / Approach
现有 Python Hook 执行器负责子进程等待。claim 保留一半上限,ready 复用同一 monotonic deadline。超时沿当前 CLI 的原回执继续。 完整改动两处,集中在原执行函数和同一原生 contract 测试。Todo 选择、lease 绑定与结算身份由现有 owner 提供。 以同一执行预算内是否拿到原 ready 凭据做对照。超时后核验旧路径能否真正恢复当前任务。
具体改动 / Changes
精确 head 0fdde2fd56bf7c5f38a2b9cac35f441f829f5751,diff base 7bc56e74687a93ff4d5bcccb532c454bf2379c29,2 个文件 +29/-2。逐项复核 unused-claim-time、original-readback、scope-isolation。验收约定
关键代码讲解
- 执行器校验捕获的 claim 参数后设置原总期限,保留 claim 的半额上限。源码
- ready 使用剩余 monotonic 时间,期限耗尽时直接返回恢复路径。源码
- 原生 Hook 继续核对同一 claim 和 lease,并把保存的 ready 或回执返回给调用方。源码
- 无剩余时间的测试证明 ready 子进程不会启动。源码
对主干的风险 / Risks
在 File 和 SQLite 上给真实 ready 子进程的启动注入 4.25 秒延迟。基线分别约 4.39 和 4.38 秒进入恢复,候选约 5.31 和 5.17 秒返回原 Turn 的 ready。更晚的最新主干与同一补丁组合也通过。9 秒注入触发两次同源恢复,仍各只有一次 claim、零新增扣费。
语义与 CI 对齐
超时后用原凭据继续到 Todo checkpoint。原有和捕获后新增的其他 Todo 均保持原值。精确 head 的 247 项针对性验证通过,显式关闭 Context Delivery 的路径仍有覆盖。生产宿主的并发延迟、远程 SSH 耗时及 CI 状态未在本次结论中核实。
我的整体评价 / Verdict
同意这一精确提交。两种后端均复现了原固定切片的提前恢复。候选在原时间窗内交付同一 Turn,超时后也能用原 claim 恢复并留下实际工作检查点。
English verdict: APPROVE. Both providers use the remaining original deadline, return the original ready capture, and recover on expiration without another claim or debit. Exact-head source tests pass. Production host timing remains unmeasured.
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
0fdde2f to
791c090
Compare
huangruiteng
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · GPT-5 · OpenAI · self_reported
审批结论 / Approval conclusion
动机 / Motivation
Native Host 原先把约四秒 claim 和四秒 readiness 拆成两个固定预算;claim 很快结束时,剩余时间被丢弃,4.25 秒的合法 readiness 因而进入恢复。候选保留原有八秒总上限,只让 readiness 使用同一 deadline 的剩余时间。
affected_caller_or_operator: Codex App and SSH Goal Hosts executing native claim-then-ready preparation.before_after_scenario: A 4.25-second readiness delay returned recovery under fixed waits; the candidate uses the claim's remaining time and returns the same-Turn ready capture within the original eight-second deadline.observable_outcome: A fast claim leaves more than four seconds for readiness; an elapsed deadline skips the second call and routes to existing recovery.non_goals: Does not increase the total eight-second wait, change claim authority, or replace receipt-based recovery.
改动思路 / Approach
reason: The change is a local policy refinement in the owner of phase ordering and timeout. current_pr_boundary: Transfer unused claim time to readiness; total and recovery semantics stay fixed.
同一个 execute_codex_execution_preparation 在 claim 前建立 monotonic deadline。claim 仍最多使用一半;之后只有在 deadline 尚未到期时才执行 readiness,并把剩余值传给同一个 _run_json。
具体改动 / Changes
关键代码讲解
execute_codex_execution_preparation在 claim 前记录 deadline,claim 后计算remaining。- readiness 使用
remaining;小于等于零时抛出TimeoutError,不启动第二个 subprocess。 - 可见 ready 仍必须满足同一 Goal、Todo、Turn、claim 与 capture 条件,不因等待方式改变而放宽。
- timeout 分配和 postcondition 在同一函数中紧邻,后续维护者能直接看到预算与授权检查的关系。
对主干的风险 / Risks
最强反例是总等待被悄悄延长,或在 deadline 之后仍启动 readiness。一个共享 deadline 与 remaining <= 0 分支分别约束两者;expired-deadline 测试验证第二次 runner 不运行。13 个 preparation 测试和 quick premerge 通过,仅保留已有 maintainability advisory。
我的整体评价 / Verdict
该修复只重新分配已有的总预算,没有增加外部等待、重试或新的 authority。它减少无意义的 recovery 回合,同时保留旧 recover path,因此长程 continuation 与失败处理都更稳定。
English verdict: APPROVE for 791c090. Readiness can use unused claim time within the original total deadline, and no ready check begins after expiration.
Problem
The native Host waits up to four seconds for a Todo claim and four more for the same-Turn ready decision. A fast claim can leave most of its time unused while a ready decision that needs slightly longer falls into readback.
Change
Reserve half of the existing eight-second wait for readiness. After the claim, give the ready check the time remaining on the same monotonic deadline. Once the deadline has elapsed, the Hook uses its existing receipt-based recovery path.
Validation
Verification after synchronizing main
The revalidated branch includes main
7bc56e74687awith #9004 and #9000. The 125 targeted native-preparation, CLI routing and MCP cases passed, along with Ruff and the quick premerge canary.