Skip to content

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

Open
sunrioa wants to merge 2 commits into
apache:rust-previewfrom
sunrioa:codex/fix-agent-finish-cell-notices
Open

sunrioa wants to merge 2 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.

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.
  • The maka-agent-facts and maka-agent-state suites passed all 40 tests. The Agent Engine compile check and cargo fmt --all -- --check also passed.
  • 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.

Verification is scoped to the checks above. The full workspace test suite is pending.

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。修复后通过,并验证了仍在运行的后台任务会继续阻止轮次结束。
  • maka-agent-facts 和 maka-agent-state 共 40 项测试通过。Agent Engine 编译检查和 cargo fmt --all -- --check 也通过。
  • 回放了故障轮次的 1,496 条事件。修复后轮次可以结束,三条待交付的通知完整保留。另在数据库副本上确认,重建后完成状态和三条通知记录均保留。

本次验证覆盖上述检查,全仓测试尚待运行。

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

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.

1 participant