Skip to content

fix(daemon): harden ACP query abort and interrupt semantics - #2792

Merged
lsm merged 2 commits into
devfrom
space/acp-split-8e-abort
Aug 23, 2026
Merged

lsm merged 2 commits into
devfrom
space/acp-split-8e-abort

Conversation

@lsm

@lsm lsm commented Aug 23, 2026 •

Copy link
Copy Markdown
Owner

Extracted from #2711 (ACP split 8/10) — final slice of the stack.

What this adds

Query runner:

  • createAbortableQuery keeps the in-flight iterator.next() promise; on abort it no longer drops that message. Post-abort, tool-result/tool-use messages in flight or still queued are drained (bounded: ≤256 messages, 1 s deadline) and yielded, and pending adapter messages flush — interrupted tool calls end with synthesized results instead of hanging the next turn. A late producer that never yields stops after the deadline.
  • Startup aborts as soon as cleanup begins (5 assertActiveAcpStartup checkpoints: pre-controller, post-callbacks, post-client, post-authenticate, post-models-fetch) instead of running the whole handshake against a dead query.
  • Startup-timeout path cancels and closes the session before closing the client (retry starts clean); stale queries close a leftover client in finally; _lastConsumedUserMessage clears when the query settles.
  • clearAcpSessionState() replaces the persistAcpSessionId(undefined) retry hack and also clears instructions/context estimate.

QueryLifecycleManager:

  • Aborts the active query controller before waiting on stop; terminates agent processes discovered during the stop window; only clears queryAbortController/queryPromise/queryObject/startup timer when a replacement query has not already installed new references; reset also clears acpContextUsageEstimate.

Tests: +9 runner tests (abort drain, dedupe of results completed during abort, stale-startup aborts, stale client close, interrupted tool call delivery, bounded drain of continuing producers) and +7 lifecycle stop-window tests. 321 passed / 21 skipped across the touched suites.

Extracted from #2711.

Verification

  • vitest run tests/unit/lib/acp/ tests/unit/1-core/agent/query-lifecycle-manager.test.ts tests/unit/1-core/acp-transport.test.ts — 321 passed / 21 skipped
  • oxlint, tsc --build --noEmit, knip, pinned-biome — clean

Open in Devin Review

Track the in-flight iterator promise so an abort no longer drops the
message it was fetching: after an abort, tool-result and tool-use
messages still in flight or queued are drained (bounded by message count
and a deadline) and delivered before the iterator settles, so
interrupted tool calls end with synthesized results instead of hanging
the next turn. Startup now aborts as soon as cleanup begins instead of
after the handshake, timed-out sessions are cancelled and closed before
the retry, stale queries close a leftover client in finally, and the
lifecycle manager aborts the active query before waiting on stop,
terminates processes spawned during the stop window, and only clears
context references a replacement query has not already replaced.

Extracted from #2711 (ACP split 8/10).
@lsm

lsm commented Aug 23, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

devin-ai-integration[bot]

This comment was marked as resolved.

@lsm

lsm commented Aug 23, 2026

Copy link
Copy Markdown
Owner Author

Deduplicated in 8a928bf — the extraction had pasted two test blocks twice; each scenario now appears exactly once (61 tests).

@lsm

lsm commented Aug 23, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

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.

1 participant