Skip to content

fix(agent-runtime): avoid blocking read-only Stop on abort RPCs - #1980

Merged
vastsa merged 2 commits into
vastsa:mainfrom
FuYukiH:fix/read-only-stop-settlement
Oct 29, 2026
Merged

vastsa merged 2 commits into
vastsa:mainfrom
FuYukiH:fix/read-only-stop-settlement

Conversation

@FuYukiH

@FuYukiH FuYukiH commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

A Stop can abandon a Read, Glob or Grep execution, but the executor then waits for tools.abort from the same Host. If that acknowledgement is held, runtime.abort() remains pending and the session cannot accept the next prompt.

Apply the existing read-only local-abandon policy to the cancellation acknowledgement too. The typed abort request is still sent and its late rejection is observed. Calls with side effects retain the existing Host settlement requirements.

The regression holds both tools.execute and tools.abort responses. The original sidecar artifact times out on agent.abort; the fixed artifact stops and sends a new user prompt to the provider while those responses remain held. A Write control case remains running until execution and cancellation have both settled. Unit tests also reject the abandoned requests after the following turn, verifying that they cannot emit another result or change that turn.

Validation on Windows x64, Node 24.14.0, Pi 1.4.0:

  • Full agent-runtime suite: 1,577 passed, 1 POSIX-path test skipped on Windows.
  • node scripts/e2e-read-only-stop.mjs: all four scenarios passed using the production sidecar bundle and real localhost HTTP provider requests. Host responses are controlled fixtures; this does not claim native filesystem-worker cancellation.
  • Shared/runtime and Desktop builds, Desktop typecheck, Biome lint, style-token checks, policy sync, docs checks and PR-base check passed.

Candidate: 5244493c8fe1471b42fa9c182fd1e36851da49d3; base: 78e128ac9c93cbf975319078c39589701c1422c7. The stop contract and E2E-010 are updated.

Read, Glob and Grep already abandon their execution wait on Stop, but then
await tools.abort from the same host. An unresponsive acknowledgement keeps
runtime.abort pending and prevents the next prompt from starting.

Apply the existing read-only local-stop policy to that acknowledgement as
well. Mutating and external tool calls retain host settlement ownership.
Cover held responses, follow-up prompts and late failures through real
Agent loops and the production sidecar bundle.

@muzimu217 muzimu217 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.

This is the right split: a read-only tool cannot leave the workspace in a state that needs confirming, so a Stop should not hold the session open waiting for an acknowledgement the Host may never send, while a pending mutation keeps waiting because cancelling it is what makes the write safe. The tests cover the three read-only tools with the acknowledgement held and accept another prompt, which is exactly the user-visible symptom, and the late transport failure case is the one that would otherwise turn into an unhandled rejection.

One question about the tail of the story: when the Host eventually answers the abandoned tools.abort — or worse, delivers the read's result after the turn already settled — where does that response go? If the runtime drops results for a turn it no longer owns, this is complete; if a late tools.execute result can still land in the projection, it would appear as a row after the turn ended. The test asserting a late failure is handled suggests the path is considered, but the success case is the one that would show up in the transcript.

Not a blocker: the lockup this fixes is worse than a stray late row, and the read-only boundary is drawn in the right place.

@muzimu217 muzimu217 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.

This is the right split: a read-only tool cannot leave the workspace in a state that needs confirming, so a Stop should not hold the session open waiting for an acknowledgement the Host may never send, while a pending mutation keeps waiting because cancelling it is what makes the write safe. The tests cover the three read-only tools with the acknowledgement held and accept another prompt, which is exactly the user-visible symptom, and the late transport failure case is the one that would otherwise turn into an unhandled rejection.

One question about the tail of the story: when the Host eventually answers the abandoned tools.abort — or worse, delivers the read's result after the turn already settled — where does that response go? If the runtime drops results for a turn it no longer owns, this is complete; if a late tools.execute result can still land in the projection, it would appear as a row after the turn ended. The test asserting a late failure is handled suggests the path is considered, but the success case is the one that would show up in the transcript.

Not a blocker: the lockup this fixes is worse than a stray late row, and the read-only boundary is drawn in the right place.

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Independently reproduced on current main: rebuilt the production sidecar with baseline runtime.ts and held tools.execute plus tools.abort; agent.abort times out. Restored candidate, rebuilt, and all four real sidecar/localhost-provider scenarios pass (Read, Glob, Grep accept follow-up while acknowledgements remain held; Write waits for execution and cancellation). Full runtime suite passes: 115 files, 1577 tests. Targeted runtime/stop suites also pass 372/372. Production diff only removes acknowledgement waiting for the existing Read/Glob/Grep local-abandon boundary; late rejection is observed and Promise.race cannot resume on late success. No mutating/MCP/plugin settlement change. Specs and E2E documentation align.

Non-destructively integrated latest main; tested head 7d13df8 and PR integration have identical tree 874db66dc4dd0d6af2bfd2daadf77c01400e83fa. Diff check clean. Local locked dependency installation was necessary because primary has Pi 1.3.0 instead of required 1.4.0; primary environment unchanged. Coverage is production Node sidecar with controlled Host RPC and real localhost provider, not native filesystem worker cancellation or interactive Electron. Fresh remote CI is still running; merge awaits its success.

@vastsa
vastsa merged commit c0a9345 into vastsa:main Oct 29, 2026
6 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