Skip to content

fix(antigravity): keep threads waiting on background tasks and handle reactive wakes - #7

Open
omar7550 wants to merge 1 commit into
mainfrom
fix/antigravity-background-wait
Open

omar7550 wants to merge 1 commit into
mainfrom
fix/antigravity-background-wait

Conversation

@omar7550

Copy link
Copy Markdown
Owner

Problem

When Antigravity (antigravity acp 1.5.10) starts a background run_command, schedule, run_workflow, or invoke_subagent, the tool call remains in_progress when session/prompt returns { stopReason: "end_turn" }. Previously:

  1. AcpAdapterV2.finalizeTurn force-completed open foreground tools at end_turn, leaving pendingBackgroundTasks empty so the UI immediately showed Completed instead of Waiting and stopped watching for background completion.
  2. When the background task later finished and Antigravity spontaneously began its reactive follow-up wake (without a second session/prompt), AcpAdapterV2 had activeTurn === null and rejected session/request_permission with -32603, causing Antigravity to abort the follow-up step (user denied permission to run command).

Fix

  • Classify & track Antigravity background work (AntigravityProtocol.ts, AntigravityAdapterV2.ts, packages/provider-acp/src/server/adapter.ts):
    • Keep open background tool calls (run_command, schedule, run_workflow, invoke_subagent) alive across end_turn instead of force-completing them, and sync them into providerThread.pendingBackgroundTasks / pendingBackgroundWork.
    • Non-daemon run_command defaults to awaited: true (holds Waiting automatically); IsDaemon: true commands stay non-blocking unless explicitly marked via t3_background_wait.
    • Resolve Antigravity step task IDs (<sessionId>/task-<N> / task-<N>) to their toolCallId from <sessionId>.db (AntigravityChildWork.ts) so t3_background_wait works with native Antigravity task IDs as well as toolCallId.
    • Preserve rawOutput.output when projecting command outputs on completion.
  • Reactive post-settle wakes & permissions (packages/provider-acp/src/server/adapter.ts):
    • On post-settle completion of an awaited background task (or buffered wake traffic), update the original turn item, clear the task from pendingBackgroundTasks, and immediately offer a continuation run.
    • Hold post-settle session/request_permission requests until the reactive continuation turn attaches instead of failing with -32603 (auto-approving under full-access or surfacing the approval card under approval-required).
    • Settle reactive wake turns after their trailing usage_update debounce rather than prematurely cutting off multi-second thinking gaps.
    • Clear/quarantine pending background tasks and close the runtime on Stop (interruptTurn with requestRuntimeRestart: true).

Verification

  • vp test run apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts apps/server/src/provider/acp/AntigravityProtocol.test.ts apps/server/src/provider/acp/AntigravityChildWork.test.ts (3 files, 69 passed)
  • vp test run apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts (2 files, 148 passed)
  • vp run check:changed (format, lint, knip, graphql, typecheck across 14 packages, 4 test files / 71 tests — all green)

Done with Antigravity (Gemini 3.1 Pro).

… reactive wakes

When Antigravity (ACP 1.5.10) leaves a background run_command, schedule, run_workflow, or invoke_subagent in_progress at end_turn, AcpAdapterV2 previously force-completed the tool call, left pendingBackgroundTasks empty (marking the thread Completed instead of Waiting), and rejected post-settle session/request_permission calls during Antigravity's spontaneous reactive wake with -32603.

Track open Antigravity background tasks across end_turn into pendingBackgroundTasks (non-daemon commands awaited by default; IsDaemon commands non-blocking unless marked via t3_background_wait), wire step-ID resolution for t3_background_wait, keep the session watching for post-settle completions, offer a reactive continuation run on wake, hold post-settle permission requests until the continuation turn attaches, settle reactive wake turns after their trailing usage_update, and clear/quarantine background work on Stop.

Done with Antigravity (Gemini 3.1 Pro).
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XL labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant