You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(acp): fail open post-settle replies and cancel pending requests on agent exit - #40484
In packages/provider-acp/src/server/adapter.ts, handleRuntimeTerminationAtGeneration handles !followsAgentWorkState runtimes (such as Antigravity) by returning early whenever !hasDeferredBackgroundWork(held). As a result:
If the agent process crashes/exits after a background command completes while streaming its post-settle reply (held.replyOpen === true, before usage_update), handleRuntimeTerminationAtGeneration does nothing—the turn hangs for the 2-minute ACP_OPEN_REPLY_QUIET_LIMIT and then falsely settles as "completed".
Even when hasDeferredBackgroundWork(held) is true, the !followsAgentWorkState branch does not clear agentRequests, wakeBuffer, or continuationRequested, nor call cancelPendingRuntimeRequests(), leaving pending approval/question cards stuck in "pending" / "waiting".
Change
packages/provider-acp/src/server/adapter.ts: Updated the !followsAgentWorkState path in handleRuntimeTerminationAtGeneration to:
Fail any unfinalized post-settle turn when either hasDeferredBackgroundWork(held) or held.replyOpen is true (preserving normal completion during the short debounce once replyOpen is false and no deferred work remains).
Clear agentRequests, wakeBuffer, and continuationRequested, and call cancelPendingRuntimeRequests() before failing open tools and finalizing the turn as "failed" (transport_error).
apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts: Added "fails a post-settle reply immediately and cancels pending requests when the agent exits" covering both an agent exit mid post-settle reply and an agent exit with a pending interaction_* question request.
Scope
Small, focused bug fix for post-settle runtime crash cleanup in AcpAdapterV2; no separate tracking issue is needed.
Verification
Reproduced before fix: Ran vp test run apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts -t "fails a post-settle" on main (194025ef11) with only the new test; the test hung on the 2-minute ACP_OPEN_REPLY_QUIET_LIMIT timer (Test timed out in 120000ms).
Verified after fix:
vp test run apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts: 33/33 passed (new test completes in ~720 ms).
vp run check:changed: passed format, lint, knip, graphql (apps/server), typecheck (14 packages), and tests (35/35 passed across AntigravityAdapterV2.test.ts and AgentContextBudget.test.ts).
Built with Gemini 4 Neon in T3 Code (Antigravity harness).
No actionable comments were generated in the recent review.
Walkthrough
The ACP adapter now handles runtime termination for settled turns that have deferred background work or an open reply. It clears request and continuation state, cancels pending runtime requests, fails open tools, and finalizes the turn with a transport error. Tests cover partial replies and permission requests after agent exit.
Changes: ACP runtime termination handling
Layer / File(s)
Summary
Handle runtime termination for settled turns packages/provider-acp/src/server/adapter.ts, apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts
The adapter handles settled turns with an open reply, even without deferred background work. Before finalizing, it clears agent requests and buffered continuation state, then cancels pending runtime requests and fails open tools. Tests verify that a partial reply leads to a failed turn and that an outstanding permission request is cancelled when the agent exits.
When an ACP agent exits after a prompt settles, the turn now fails immediately and pending approval or question requests are cancelled, instead of waiting out the quiet limit and falsely completing. The added tests cover both cases, and no concrete merge-blocking risk was found in review.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: failing open post-settle replies and cancelling pending requests when an ACP agent exits. It follows the conventional commit format and matches the adapter change and …
Description check
The description follows the repository template closely. It has Problem, Change, Scope, and Verification sections. The Problem and Change sections explain the bug and the fix in detail. Scope states t…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: failing open post-settle replies and cancelling pending requests when an ACP agent exits. It follows the conventional commit format and matches the adapter change and the added test.
Full details: Description check
Explanation
The description follows the repository template closely. It has Problem, Change, Scope, and Verification sections. The Problem and Change sections explain the bug and the fix in detail. Scope states this is a small bug fix and why no issue is needed. Verification gives the focused test commands, the failure reproduced before the fix, and the passing results after it. It also names the model and harness used, as the template asks.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
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
size:S10-29 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
1 participant
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.
Problem
In
packages/provider-acp/src/server/adapter.ts,handleRuntimeTerminationAtGenerationhandles!followsAgentWorkStateruntimes (such as Antigravity) by returning early whenever!hasDeferredBackgroundWork(held). As a result:held.replyOpen === true, beforeusage_update),handleRuntimeTerminationAtGenerationdoes nothing—the turn hangs for the 2-minuteACP_OPEN_REPLY_QUIET_LIMITand then falsely settles as"completed".hasDeferredBackgroundWork(held)is true, the!followsAgentWorkStatebranch does not clearagentRequests,wakeBuffer, orcontinuationRequested, nor callcancelPendingRuntimeRequests(), leaving pending approval/question cards stuck in"pending"/"waiting".Change
packages/provider-acp/src/server/adapter.ts: Updated the!followsAgentWorkStatepath inhandleRuntimeTerminationAtGenerationto:hasDeferredBackgroundWork(held)orheld.replyOpenis true (preserving normal completion during the short debounce oncereplyOpenis false and no deferred work remains).agentRequests,wakeBuffer, andcontinuationRequested, and callcancelPendingRuntimeRequests()before failing open tools and finalizing the turn as"failed"(transport_error).apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts: Added"fails a post-settle reply immediately and cancels pending requests when the agent exits"covering both an agent exit mid post-settle reply and an agent exit with a pendinginteraction_*question request.Scope
Small, focused bug fix for post-settle runtime crash cleanup in
AcpAdapterV2; no separate tracking issue is needed.Verification
vp test run apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts -t "fails a post-settle"onmain(194025ef11) with only the new test; the test hung on the 2-minuteACP_OPEN_REPLY_QUIET_LIMITtimer (Test timed out in 120000ms).vp test run apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts: 33/33 passed (new test completes in ~720 ms).vp run check:changed: passed format, lint, knip, graphql (apps/server), typecheck (14 packages), and tests (35/35 passed acrossAntigravityAdapterV2.test.tsandAgentContextBudget.test.ts).Built with Gemini 4 Neon in T3 Code (Antigravity harness).