Skip to content

Keep external and managed schedulers aligned on deferred Todo wakeups - #8135

Merged
huangruiteng merged 1 commit into
mainfrom
codex/scheduler-deferred-todo-wake
Nov 6, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/scheduler-deferred-todo-wake

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Problem and outcome

An agent deferred its own unfinished Todo until an exact time. A generic external worker could stop after three unchanged checks when the Todo had no linked Vision record. The same Todo with a linked Vision kept its observer. In addition, minute-only scheduling could overshoot a short remaining wait. A missing observer leaves the Goal active with nobody to ask for fresh admission.

Change

Use the scoped Todo resume planner to prove the pending condition before applying display limits. Both the Vision path and the agent frontier use that same TypeScript selection. The scheduler publishes the deadline to its managed Goal and external CLI projections. The CLI worker bounds its existing backoff by that deadline and requests fresh admission when it wakes. The existing successor-replan route decides whether to reopen the original Todo. Claim, spend and direct delivery still require their own authority.

Human gates, missing or conflicting proof, another agent's work, explicit stops and Turn-bound recovery retain their governing policy. The contract remains compatible with older scheduler hints.

Verification

  • Isolated File and SQLite CLI fixtures with a controlled clock, a real external worker loop and a synthetic wake handler. Beginning with a deferred Todo and no Vision record, the worker crosses its previous stop limit, makes zero premature model calls, wakes once when due, and the handler reopens the original Todo through the CLI.
  • The managed runtime and external CLI agree on the seconds remaining. Scoped selection includes a deadline beyond the displayed rows and excludes the peer's earlier deadline.
  • 415 Python scheduler, worker and recovery regressions passed.
  • TypeScript control-plane typecheck and 45 resume-planning/arbitration checks passed. External scheduler smoke passed all 12 checks. The tests substitute the clock and model invocation. They make no claim about benchmark scoring.

…ulers

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

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

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.1-sol; OpenAI; runtime_reported; reasoning_effort=max

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

把未完成任务推迟到指定时间的用户,需要原来的 Agent 到期后重新检查并恢复工作。旧实现中,没有 Vision 记录的延期 Todo 会沿普通等待路径,在三次无变化检查及最终探测后退出;Goal 仍然有效,却失去了继续检查的 worker。分钟级间隔还可能错过短于一分钟的剩余时间。

这个补丁让已证明仍在等待的本 Agent Todo 持续接受安静检查,并把剩余秒数交给既有调度器。独立对照已验证到期后只触发一次处理,原 Todo 经公开 CLI 恢复为 open。边界是恢复检查与原任务生命周期;到期不授予执行、claim 或扣额权限,也不完成整个小团队持续执行或原生宿主资格。

改动思路 / Approach

评审覆盖 base a4370d644af3932b8c6aef62f8d161aed709dfc9 到 exact head 27dfa55d6b2245dc324ab243fa549a0f0e7ddc73 的完整 12 文件 diff。共享 Todo resume planner 先对完整 scoped source 验证等待条件,再选择最早时刻;显示窗口不会成为语义选择范围。Vision 路径与没有 Vision 的 agent frontier 都复用这一个 TypeScript owner。Python 仅携带当前事实,worker 只执行调度器给出的等待上限。

架构判断是保留既有 scheduler/worker,提取同域的来源证明与选择规则,而不另建计时服务或在两个消费者复制判断。当前 PR 边界同时包含选择、秒级投影和真实 worker 消费,因此能交付有用的恢复路径。人类门禁、未知来源、其他 Agent、停止及已有 Turn 结算仍由原 owner 决定;观察者既不重新打开任务,也不绕过新的准入。

相同合成工作,每种后端 基线 当前 head
无 Vision、距到期 7,217 秒 三次无变化检查加最终探测后退出;零次 wake 六次探测;到期一次 wake
最后一段等待 未抵达到期 17 秒
原 Todo 恢复 未发生 CLI 读回同一 Todo 为 open

表中时间来自受控时钟,不是原生宿主延迟测量。模型调用被合成处理器替代;实际 CLI、TypeScript runtime、worker 与 File/SQLite authority 均有执行。

具体改动 / Changes

规格依据是变更前的 docs/reference/protocols/typed-date-resume-trigger-v0.md,spec_revision 为 a4370d644af3932b8c6aef62f8d161aed709dfc9。原文 的 Acceptance 1 沿用既有日期解析并由 resume-condition 检查覆盖;2 的等待一致性与 3 的到期 successor-replan 在本次相关用例中覆盖。Acceptance 4 的稳定收据算法未被改动,重复 tick 的 typed 检查通过,本轮未另作到期后进程重启资格。Acceptance 5 的既有前端 authoring、route/build 不是本补丁的变更范围,未据此宣称重新完成其打包资格。新协议文字说明这里经验证的外部 worker 行为,不用修改后的文字反向证明实现。

关键代码讲解

  • selectPendingResume 先要求整个候选集合都有有效 pending 来源,再在纯时钟集合中选择最早到期项;它沿用原条件 owner 对目标、claim、时间及 monitor 生命周期的证明。
  • projectTodoResumePlanning 在显示限制之前产生可选的 automatic_resume_todo,由 agent frontier 传递。它是临时投影,不是新的任务权威或恢复收据。
  • projectSchedulerArbitration 只在无 must-attempt、无 user gate、无 spend 且未绑定待处理 Turn 的等待中携带时刻;微秒差向上取整到正整数秒。
  • completeCadenceProjection 把已验证的秒数投影到 external CLI 和 managed continuation,保留其他 frontier 的更早检查上限。
  • _run_worker_locked 等待时取原 backoff 与剩余秒数的较小值;新字段缺省时沿用旧 hint。醒来仍重新执行 quota,而不是直接执行过期合同。

代码量为 +275/-114:8 个生产文件、3 个测试文件和 1 个协议文件。相关小范围重构已应用:从 Vision 模块移走重复的 pending-source/最早时刻规则,让两个真实消费者共用它;无需保留内部旧导出 wrapper 或扩大到整个调度器迁移。

对主干的风险 / Risks

最强反例是把无来源、已完成、其他 owner 或绑定结算的等待误判为可无限观察,或者在显示截断后选错 deadline。独立 CLI 对照在两个后端验证了人类门禁、显式停止、未知依赖和 peer 不获得时钟授权;显示窗口之外的第六项使检查为 11 秒,peer 的更早 5 秒不参与。反转行序仍是 11 秒,有无 Vision 均为 7,217 秒,完成项不再带计时投影。1 微秒的剩余时间得到 1 秒,不出现零秒循环。TypeScript 负例还覆盖已有 Turn、终态、错误及不完整证明。

PASS:68 个相关 TypeScript 检查;配置内 mypy、改动 Python Ruff、control-plane typecheck;14 个真实 CLI/worker 场景每版各执行一次,以及 head 上 8 个状态反事实。到期后的合成处理器通过 todo update 清除已满足条件,并精确读回原任务。既有 frontend defer/details 仍把 resume_when 交给 Todo owner;没有新增配置或额外用户确认。未运行已安装 App、Lark 或真实模型,不能据此推导它们的资格或延迟。

FAIL 仍保留:扩大 Python 检查为 261 passed / 82 failed;这 82 个节点在不可变 base 上逐项复现,失败消息 82/82 相同。主要原因是旧夹具从 context_capture_navigation_v1 外壳取内联字段,另有既有 scheduler-ACK 断言失败,相关失败消费者及其源文件未被本 PR 改写。独立的新路径验证不把这些失败转成通过。

标准 premerge 也未通过:peer-continuation 和 heartbeat-flow 的原有失败在 base/head 都复现;保留 canary 目录深度后,dashboard status 在两版均为 25,014 字符,超过 25,000 的硬预算,较短直接调用通过不能替代该失败。原始 maintainability finding 同样保留。CQR 按失败验证记录,合并门禁继续 hold;没有放宽预算、隐藏失败或查询远端 CI。这些既有失败不构成本补丁新增的已验证代码缺陷,但需要各自 owner 修复或重新资格验证。

我的整体评价 / Verdict

在这项明确的恢复修复范围内,long_horizon 是 improved:真实 worker 不再提前退出,并在新准入下恢复原 Todo;这不是完成 R2 或证明长期吞吐。user_experience 是 improved:用户原来的延期意图不再需要到期后手工重启 worker,没有增加输入或确认轮次。视觉检查不适用,已检查现有 defer/details、Todo readback 和 scheduler 消费路径;本 PR 没有页面布局或可见文案变化。已安装宿主和 Lark 行为仍未重新验证。

机制与已复现的失去观察者问题相称,退回本补丁可整体恢复旧路径。它复用现有 resume kind、scheduler disposition 和生命周期词汇;新增的是可选投影字段,没有新增权限状态。默认行为的有意变化是:只有有完整来源证明的等待持续安静检查,并按剩余秒数约束间隔;通知偏好、执行和结算义务不随之扩大。

代码评审结论为 APPROVE;CQR/premerge 的失败是独立且仍有效的合并限制。本结论不授予合并、安装、发布或替其他 owner 关闭问题的权限。

English verdict: APPROVE — the scoped wakeup repair is supported by paired real-backend evidence; required quality holds remain.

@huangruiteng
huangruiteng merged commit 036fdbd into main Nov 6, 2026
30 of 43 checks passed
@huangruiteng
huangruiteng deleted the codex/scheduler-deferred-todo-wake branch November 6, 2026 04:31
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