Skip to content

fix(acp): stop cancelled steps while reading the opening screen - #1766

Merged
kdy1 merged 4 commits into
e2e-inc:mainfrom
jxnxts:jxnxts/wave2-acp-reliability
Nov 16, 2026
Merged

kdy1 merged 4 commits into
e2e-inc:mainfrom
jxnxts:jxnxts/wave2-acp-reliability

Conversation

@jxnxts

@jxnxts jxnxts commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What and why

  • A cancelled ACP step no longer waits for its opening screen. runStep races the screen read against the step signal with the existing untilAborted helper, so it rejects with the step's original reason while ctx.observe is still pending (packages/acp/src/executor.ts:77).
  • runStep checks the signal before it starts the screen read (packages/acp/src/executor.ts:75), so a step aborted after the previous turn settles never calls observe.
  • The cancelled step sends no prompt, and the session stays held for the next step.
  • The previous-turn wait from fix(acp): cancel the wait for the previous agent turn when the step ends #1761 is unchanged. The runner's outer deadline is unchanged too; this changes when the executor promise settles, and does not stop an engine operation that ignores its own cancellation.

Issue

Fixes #1765

Verified

Ran it locally: yes

  • pnpm --filter @e2e-dev/acp exec vitest run tests/executor.test.ts, with packages/acp/src/executor.ts from main and then from this branch, on Node v24.22.2 and main 0a5ee163:
main this branch
× ends a cancelled step without waiting for its opening screen: runStep has not rejected 1 s after the abort (Number of calls: 0) passes: rejects with the same STEP_TIMEOUT object, one session, one prompt for the cancelled pair, then the next step passes on the same session
1 failed, 38 passed 39 passed
  • does not read the screen for an already-aborted step passes 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 before runStep. It pins the contract that observe is 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 test and ACP typecheck passed; all 50 ACP tests passed. CI on the updated PR head must be checked separately.

@jxnxts
jxnxts requested a review from okwasniewski as a code owner November 13, 2026 23:49
@github-actions github-actions Bot added the size:XS Up to 9 changed lines, not counting tests, fixtures, or the lockfile label Nov 13, 2026
@jxnxts

jxnxts commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

[Codex] responding on behalf of jxnxts

Could a maintainer authorize the workflow runs for head 074ab53172c4d55e867f12169776930adda9a1c4? All four are action_required with zero jobs started: spec, benchmark, mobile, docs.

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.

@cubic-dev-ai cubic-dev-ai Bot 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.

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 okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[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:

  1. Rebase on main once #1761 lands (both add the same setImmediate import, dedupe it).
  2. Drop that test and the cancelUntilFile fixture option (scripted-agent.ts:46, :220). To cover the pre-check, abort the step before calling runStep and assert observe is never called - no fixture change needed.
  3. 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.

@cubic-dev-ai cubic-dev-ai Bot 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.

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

@jxnxts

jxnxts commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, the requested changes are addressed in f96f9ea (using a merge instead of the requested rebase to preserve published history):

  1. Merged main (with fix(acp): cancel the wait for the previous agent turn when the step ends #1761) into the branch. The test file has one setImmediate import.
  2. Dropped "does not read a cancelled step screen after the previous turn stops" and the cancelUntilFile option; tests/fixtures/scripted-agent.ts now matches main. As suggested, the pre-check's contract is covered by aborting the step before runStep and asserting observe is never called. One limit: on current main that test also passes without the pre-check, because ready() rejects first. It pins the "observe is never called" contract rather than isolating that line.
  3. The changeset now reads "A cancelled ACP step now stops right away instead of waiting for the screen read to finish."

I left out the optional untilAborted no-op catch to keep the diff to the reviewed change; happy to add it.

The PR diff against main is now three files. pnpm check and pnpm test pass locally on the merged tree.

@okwasniewski

Copy link
Copy Markdown
Member

Note

Automated review.

Thanks, all three asks are done at f96f9ea37: merged main with one setImmediate import, the duplicate test and cancelUntilFile are gone, and the changeset is user-facing. untilAborted races the inner promise, so a screen read that rejects after the abort is still handled. CI green. Ready for human review.

@kdy1 kdy1 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

  1. The ctx.signal.throwIfAborted() pre-check at executor.ts:75 has 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 step passes without it, because ready() rejects first (the PR description says this). The check guards an abort that lands in the microtask gap after await ready(). Without it, stepMessage starts anyway, calls observe for a step that already ended, and its promise is left unhandled if it rejects. Follow-up options: make untilAborted attach 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.

  2. The engine's observe keeps running after the executor stops waiting. This PR changes when runStep settles, not whether the engine call stops (the description says so). I did not check what the next step sees when the engine serializes observe calls. If the held read blocks the next step's observe, the user still waits, only one step later. Follow-up: check whether each engine's observe takes ctx.signal, and pass it through where it does not.

@kdy1
kdy1 added this pull request to the merge queue Nov 16, 2026
Merged via the queue into e2e-inc:main with commit 92bf0a9 Nov 16, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for Human Review size:XS Up to 9 changed lines, not counting tests, fixtures, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACP executor waits for its opening screen after the step is cancelled

3 participants