Repository navigation
fix(acp): stop cancelled steps while reading the opening screen - #1766
Conversation
|
[Codex] responding on behalf of jxnxts Could a maintainer authorize the workflow runs for head The current head passed the local ACP build, repository lint, ACP typecheck and all 49 ACP tests, including the compiled CLI with Chromium. Both synthetic reproduction probes passed with the corrected tarball; the outer runner deadline is unchanged. |
There was a problem hiding this comment.
No issues found across 4 files
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Thanks, the fix is right and minimal. Reverting src fails both new tests, dropping only the pre-check at executor.ts:75 gives an unhandled rejection, dropping only the untilAborted race fails the screen test.
Overlap with #1761: with it applied, ready() already rejects once the step is aborted, so the first test ("does not read a cancelled step screen after the previous turn stops") passes even without the pre-check and duplicates #1761's test. Asks:
- Rebase on main once #1761 lands (both add the same
setImmediateimport, dedupe it). - Drop that test and the
cancelUntilFilefixture option (scripted-agent.ts:46,:220). To cover the pre-check, abort the step before callingrunStepand assertobserveis never called - no fixture change needed. - Changeset: keep it user-facing, e.g. "A cancelled ACP step now stops right away instead of waiting for the screen read to finish."
Optional: have untilAborted attach a no-op catch to the inner promise when the signal is already aborted, so it is safe without a caller pre-check.
Main now carries the previous-turn cancellation from e2e-inc#1761, so the test that waited on the first turn and the scripted agent's cancelUntilFile option duplicate its coverage. Cover the pre-check with a step aborted before runStep instead, keep one setImmediate import, and word the changeset for users.
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
|
Thanks, the requested changes are addressed in f96f9ea (using a merge instead of the requested rebase to preserve published history):
I left out the optional The PR diff against |
|
Note Automated review. Thanks, all three asks are done at |
There was a problem hiding this comment.
The fix is right and minimal. I checked it locally at f96f9ea3: the 39 tests in executor.test.ts pass, and ends a cancelled step without waiting for its opening screen fails against main's executor.ts. Two gaps remain. Neither blocks this PR, so I suggest tracking them as follow-ups.
-
The
ctx.signal.throwIfAborted()pre-check atexecutor.ts:75has no test that needs it. I deleted only that line and all 39 tests still passed.does not read the screen for an already-aborted steppasses without it, becauseready()rejects first (the PR description says this). The check guards an abort that lands in the microtask gap afterawait ready(). Without it,stepMessagestarts anyway, callsobservefor a step that already ended, and its promise is left unhandled if it rejects. Follow-up options: makeuntilAbortedattach a no-op catch to the inner promise when the signal is already aborted, so no caller needs the pre-check, or add a test that aborts inside that gap. -
The engine's
observekeeps running after the executor stops waiting. This PR changes whenrunStepsettles, not whether the engine call stops (the description says so). I did not check what the next step sees when the engine serializesobservecalls. If the held read blocks the next step'sobserve, the user still waits, only one step later. Follow-up: check whether each engine'sobservetakesctx.signal, and pass it through where it does not.
What and why
runStepraces the screen read against the step signal with the existinguntilAbortedhelper, so it rejects with the step's original reason whilectx.observeis still pending (packages/acp/src/executor.ts:77).runStepchecks the signal before it starts the screen read (packages/acp/src/executor.ts:75), so a step aborted after the previous turn settles never callsobserve.Issue
Fixes #1765
Verified
Ran it locally: yes
pnpm --filter @e2e-dev/acp exec vitest run tests/executor.test.ts, withpackages/acp/src/executor.tsfrom main and then from this branch, on Node v24.22.2 and main0a5ee163:× ends a cancelled step without waiting for its opening screen:runStephas not rejected 1 s after the abort (Number of calls: 0)STEP_TIMEOUTobject, one session, one prompt for the cancelled pair, then the next step passes on the same sessiondoes not read the screen for an already-aborted steppasses on main as well: since fix(acp): cancel the wait for the previous agent turn when the step ends #1761,ready()rejects first for a step aborted beforerunStep. It pins the contract thatobserveis never called; it does not isolate the pre-check, which guards an abort that lands after the previous turn settles.Earlier standalone reproduction against the published
@e2e-dev/acp@0.1.2(scripted ACP agent, held observation, no model account): main stays pending until the screen is released; the fix rejects with the identical reason (stoppedBeforeScreenRelease=true sameReason=true,sessions=1 prompts=2).Not run: a live ACP agent (Claude Code or Codex) on the testbed, which needs a model account.
Local validation of the reviewed content:
pnpm build,pnpm check,pnpm testand ACP typecheck passed; all 50 ACP tests passed. CI on the updated PR head must be checked separately.