Problem#
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).
Maintainer verification#
Note
Written by claude-opus-5-5 on behalf of Maria
Merged main (9ceb8bfbecd) into the branch, clean. On a Blacksmith testbox at b32888584b7:
AntigravityAdapterV2.test.ts: 45/45 passed.
- New test with the adapter fix reverted: times out (the turn waits on the open-reply quiet limit). With only the
replyOpen condition reverted: times out. With only the request cleanup reverted: fails on "pending runtime request must be cancelled".
check:changed against main: format, lint, knip, graphql, typecheck (14 packages), tests (47/47) passed.
The changed branch runs only for flavors that set toolOutlivesPrompt, which today is only Antigravity, so other ACP providers keep their behavior.
Not verified: a real Antigravity agent crashing mid post-settle reply in the app; the check used the mock ACP agent in the adapter tests.
coderabbitai[bot](GitHub profile, opens in a new tab) reviewed
Actionable comments posted: 1
4141bd07-ecf4-460b-8dfd-19e0d11c1904Reviewing files that changed from the base of the PR and between 25219da8b4f3b7d43bb735fc0354fcc53b3958bf and b32888584b719bafce1905e2608a290549d8fdf3.
apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.tspackages/provider-acp/src/server/adapter.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.