Skip to content

fix(agent): finish turns with undelivered Code Mode notifications - #6907

Merged
M4n5ter merged 6 commits into
apache:rust-previewfrom
sunrioa:codex/fix-agent-finish-cell-notices
Nov 15, 2026
Merged

M4n5ter merged 6 commits into
apache:rust-previewfrom
sunrioa:codex/fix-agent-finish-cell-notices

Conversation

@sunrioa

@sunrioa sunrioa commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A successful FinishTurn stops the Agent from starting another model step. If a Code Mode cell finishes during shutdown, its final notification can still be queued for the next model step. The completion check treated that notification as unfinished work, so the run stayed active after the cell had settled.

This happened during a proactive discovery run. DiscoveryComplete saved the report, but the scheduler was still waiting for the worker to finish. The report never reached the Bot, and subsequent investigations could not start.

This change lets a run finish with undelivered notifications preserved in its records. The Agent still waits for the cells and their child tools to settle and accepts the final cell results before completing the run. Completed runs with retained notifications also remain eligible for session retirement and history forks.

Verification

  • The regression test reproduced run has pending Cell obligations before the fix. It now passes and verifies that an active cell still blocks completion.
  • All 66 focused facts, state, engine and selected native tests passed. A native regression covers final cell acceptance, completion, projection rebuild and history fork with retained notifications; it reproduced the fork rejection before the fix.
  • Replayed 1,496 events from the affected run. The patched Agent accepted completion with all three queued notifications intact. A separate check on a database copy confirmed that completion and the notification records survived a rebuild.

All selected local CI workers passed at 6a6b42f9: tooling, root, bridge, packaging, product, native-ubuntu, native-macos and native-windows. Linux root archive replay passed 833 tests with 6 existing skips. Windows GUI tests ran in the logged-in console session, including all 29 desktop interaction tests.

The branch is synchronized with rust-preview through 17613b5e (#6921). Two native fixtures now use the current tool-closure and WebStatus contracts, and the missing generic Input translation is registered so contracts type-checking passes.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

OpenAI Codex assisted with root cause analysis, implementation, and regression testing. The commit includes Generated-by: OpenAI Codex.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No
简体中文

摘要

FinishTurn 成功后,Agent 会停止发起新的模型请求。如果 Code Mode 后台任务在收尾时结束,它的最终通知仍可能进入队列,等待下一次模型请求。旧的结束校验把这条通知当成未完成的工作,导致后台任务已经收尾,整轮运行却仍处于活跃状态。

实际遇到这个问题的是一轮主动发现。DiscoveryComplete 已保存报告,但调度器仍在等待 Worker 结束,导致报告无法交给 Bot,后续调查也无法启动。

修复后,未交付的通知会保留在本轮记录中,轮次可以正常结束。Agent 仍会等待后台任务及其子工具完成收尾,并接收后台任务的最终结果。保留通知的已完成轮次也可以正常退休和作为历史分叉来源。

验证

  • 回归测试在修复前复现了 run has pending Cell obligations。修复后通过,并验证了仍在运行的后台任务会继续阻止轮次结束。
  • facts、state、engine 及选中的 native 回归共 66 项测试通过。新增 native 行为测试覆盖最终结果接收、轮次完成、投影重建和保留通知后的历史分叉,修复前复现了分叉拒绝。
  • 回放了故障轮次的 1,496 条事件。修复后轮次可以结束,三条待交付的通知完整保留。另在数据库副本上确认,重建后完成状态和三条通知记录均保留。

6a6b42f9 上本地选中的 tooling、root、bridge、packaging、product、native-ubuntu、native-macos、native-windows 全部通过。Linux root 归档回放通过 833 项,另有 6 项原有跳过;Windows GUI 测试在已登录 console 会话运行,29 项桌面交互全部通过。

已同步 rust-preview 至 17613b5e(#6921)。两处 native fixture 已更新到当前的工具结束协议和 WebStatus 契约,另补齐了通用 Input 翻译,使 contracts 类型检查通过。

AI 使用

OpenAI Codex 协助了根因分析、修复实现和回归测试。提交包含 Generated-by: OpenAI Codex。

After a successful FinishTurn, keep Cell notifications in history without treating them as pending delivery. Continue requiring Cell execution, child effects and final result acceptance to settle before the Run can close.

Generated-by: OpenAI Codex
Allow completed runs to retain cell notifications without blocking history forks. Cover engine completion, projection rebuild and fork selection, and align native CI fixtures with the tool closure and WebStatus contracts.

Generated-by: OpenAI Codex
@github-actions github-actions Bot added the effort/M Under 500 readable lines label Nov 15, 2026
@M4n5ter
M4n5ter merged commit 63ddb57 into apache:rust-preview Nov 15, 2026
30 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants