Skip to content

fix(agent): clarify background Shell refs and running Cell cancellation - #6939

Merged
M4n5ter merged 3 commits into
apache:rust-previewfrom
sunrioa:codex/fix-shell-stop-guidance
Nov 16, 2026
Merged

M4n5ter merged 3 commits into
apache:rust-previewfrom
sunrioa:codex/fix-shell-stop-guidance

Conversation

@sunrioa

@sunrioa sunrioa commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Summary

A foreground Shell command can still be running when Code Mode returns a Cell ID. If the model passes that ID to ProcessStop, it receives an invalid-reference error and the command can keep running.

Expose cancel_with in running Cell responses so the model can pass the Cell ID and terminate: true directly to wait. Document the managed ref returned by background Shell and explain both cancellation paths when ProcessStop rejects a reference.

Verification

  • All 4 maka-tools unit tests passed, and the affected Rust files passed formatting checks.
  • In a temporary ordinary Session with a scripted loopback provider, cancelled a foreground command with wait, checked the guidance for a Cell ID passed to ProcessStop, and stopped a background command with its returned ref. The Host confirmed cleanup and the Session finished.
  • Three codemode_reopen tests passed, including JavaScript recovery and its new assertion on the cancellation arguments seen by the model. The Python cold-restart case timed out waiting for draftReady on both this branch and clean rust-preview at e52c87cc3.

AI use

  • Generative tooling made a substantive contribution

OpenAI Codex prepared the tool guidance, running Cell response change, and regression coverage.

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
中文

前台 Shell 命令仍在运行时,Code Mode 会返回 Cell ID。模型有时会将它传给 ProcessStop。工具随后报引用无效,命令可能仍在运行。

本次在运行中的 Cell 响应里提供 cancel_with,模型可直接将 Cell ID 和 terminate: true 传给 wait。后台命令可用 Shell 返回的 ref 调用 ProcessStop。引用无效时,错误消息会说明两种用法。

4 项工具单测通过。用本地模型桩在临时普通 Session 里验证了前台取消、误传 Cell ID 时的提示和后台停止,Host 确认清理,会话正常结束。CLI 回归通过 3 项,其中包括 JavaScript 恢复以及模型收到取消参数的断言。Python 冷启动恢复用例在本分支和干净的 rust-preview@e52c87cc3 上都等待 draftReady 超时。

@Astro-Han Astro-Han left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reviewed all five changed files at e507b77810ab458d39502993fc2cb9dcf0a04184. I found no verified P0–P2 issue in this change.

The production change adds cancellation instructions, rather than a new cancellation mechanism. In plugins/agent/tools/src/cell/session.rs:1058, only the model-facing running summary gains cancel_with: {cell_id, terminate: true}; the typed observation retained in CellReply is still serialized before that summary is constructed. The supplied arguments match WaitInput in plugins/agent/tools/src/cell.rs:229. I followed the existing wait route through observe and observe_cell: it reads the Cell from the current session's persistence before requesting cancellation, and a cancellation request does not itself mark cleanup complete. The process-control change still rejects a malformed managed process reference before reading or stopping a process; its new error explains the separate Cell cancellation route.

I also checked the tool-catalog descriptions and the changes in products/maka/cli/tests/codemode_reopen.rs: the decoder accepts older running summaries without this optional field, rejects cancellation arguments pointing to another Cell, and the JavaScript restart scenario now asserts the arguments actually seen by the provider. No database migration or transport-schema change is introduced. A static merge with rust-preview@5d3711abdac95982c56ab3978ce727dd1fd90754 succeeds.

Validation limits: this is source and integration-path review. This machine has no Rust toolchain; I did not run the Rust suites, a real foreground/background process cancellation, or Host restart recovery. The four tool tests, three reopening tests, and loopback-provider cancellation exercise in the PR description are the author's results. I have not independently reproduced the reported Python cold-restart timeout or its baseline control. CI follow-up: run 43736836081 completed successfully for the same PR head. I checked the original native job logs: macOS desktop 33/33 and Windows desktop 31/31 passed, both checking out the CI merge commit e80f46b01f1de2280c6b53d952120fa0e24e81de. This hosted result does not add a local foreground/background cancellation or restart exercise to the review above.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

Keep process resource ref validation and tool descriptions independent of Code Mode, clarify Cell cancellation in both JS and Python Code Mode definitions, and drop the redundant cancel_with payload from running Cell summaries.

Generated-by: Antigravity
@M4n5ter M4n5ter changed the title fix(agent): expose cancellation arguments for running Shell calls fix(agent): clarify background Shell refs and running Cell cancellation Nov 16, 2026
@M4n5ter
M4n5ter merged commit 9f66a32 into apache:rust-preview Nov 16, 2026
9 checks passed
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.

3 participants