fix(coding-agent): reject headless idle waiters when a post-compaction continuation cannot start - #1583
Merged
Merged
Conversation
…n continuation cannot start A continuation that fails to start settled headless idle as a clean finish, so ACP and print-mode callers reported a turn as completed that never ran. The settlement is now one-shot with reject support: non-retryable start failures reject waiters, cancellation and the benign nothing-to-continue race still resolve, a settled failure is never re-exposed to later waiters, and interactive waitForIdle is unchanged. Ports the failure semantics from #881 onto the resident-lifecycle settlement from #1494. Co-authored-by: Parker Pettit <parkerpettit@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 20d4f80. Configure here.
xsyetopz
added a commit
to xsyetopz/prime-agent-next
that referenced
this pull request
Aug 20, 2026
…tinuation-failures # Conflicts: # packages/coding-agent/CHANGELOG.md
…tinuation-failures # Conflicts: # packages/coding-agent/CHANGELOG.md
xeophon
approved these changes
Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Follow-up to #1494 and #800; ports the failure semantics from #881 (closed in favor of #1494's settlement placement).
Linear: ENG-5400 — https://linear.app/primeintellect/issue/ENG-5400/headless-idle-must-surface-post-compaction-continuation-start-failures
Problem
#1494's post-compaction continuation settlement is resolve-only:
_runScheduledPostCompactionContinueswallows a continuation that fails to start (.catch(() => undefined)), and_settlePostCompactionContinueresolves the waiters. A headless caller (ACPsession/prompt, print mode) waiting onwaitForHeadlessIdlethen observes a clean finish for a continuation that never ran — the turn silently loses its tail.#881 solved this by rejecting idle waiters, but built the wait into
waitForIdleglobally, which would have exposed interactive and extension callers to a new rejection path. #1494's placement (headless-scopedwaitForHeadlessIdlewrapper,waitForIdleuntouched) is the right architecture, so this PR ports only the failure semantics onto it.Change
settledflag): a failed settlement is cleared in the same step and never re-exposed to later waiters._settlePostCompactionContinue(error?)rejects waiters on a non-retryable start failure; an error settles immediately, while a resolve still defers to a scheduled/timer-pending retry that owns the settlement next."already processing"retry loop is unchanged;"continue from"errors (turn already completed — nothing left to continue) still settle as a clean finish. That benign race was previously invisible under the blanket swallow; feat(acp): harden resident session lifecycle #1494's own "headless idle includes a successful post-compaction continuation" test caught the distinction when the swallow came off.waitForIdleis untouched — a placement-contract test pins that it keeps resolving through a failed continuation.isSessionActiveintegration and all #1494 settle sites (cancel, dispose, abort, update-restart, ownership change) are unchanged; they settle as resolves.Consumer
#1494's ACP error boundary already handles a rejected
waitForHeadlessCompletion: the turn gets one correlated error response-boundary and never an invented terminal-quiescence update. This PR completes that path — before it, the rejection branch was unreachable from the continuation side.Tests
Two, both pinning behavior this PR introduces (adapted from #881 — credit @parkerpettit):
Validation
npm run check, build clean+56/−6 in three files.
Note
Cursor Bugbot is generating a summary for commit 20d4f80. Configure here.
Note
Reject headless idle waiters when post-compaction continuation fails to start in
AgentSessionPostCompactionContinuationSettlementwith asettledflag so a failed settlement is one-shot and not re-exposed to later waiters._settlePostCompactionContinuenow accepts an optionalErrorand rejects the settlement promise on failure instead of always resolving._runScheduledPostCompactionContinuecalls_settlePostCompactionContinuewith the error whenagent.continue()fails for reasons other thanalready processing.AgentSession.waitForHeadlessIdlethat did not handle rejection may now see unhandled promise rejections when a scheduled continuation cannot start.Macroscope summarized eb0a42c.