fix(daemon): harden ACP query abort and interrupt semantics - #2792
Merged
Merged
Conversation
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).
Owner
Author
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Owner
Author
|
Deduplicated in 8a928bf — the extraction had pasted two test blocks twice; each scenario now appears exactly once (61 tests). |
Owner
Author
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Extracted from #2711 (ACP split 8/10) — final slice of the stack.
What this adds
Query runner:
createAbortableQuerykeeps the in-flightiterator.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.assertActiveAcpStartupcheckpoints: pre-controller, post-callbacks, post-client, post-authenticate, post-models-fetch) instead of running the whole handshake against a dead query.finally;_lastConsumedUserMessageclears when the query settles.clearAcpSessionState()replaces thepersistAcpSessionId(undefined)retry hack and also clears instructions/context estimate.QueryLifecycleManager:
queryAbortController/queryPromise/queryObject/startup timer when a replacement query has not already installed new references; reset also clearsacpContextUsageEstimate.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 skippedtsc --build --noEmit, knip, pinned-biome — clean