Skip to content

Antigravity orphaned background commands hold completed turns in running with no UI indicator and deadlock delegated parent threads #39820

Open

Description

@mahmoodnizamani94-png

When an Antigravity agent leaves a non-daemon run_command process alive from an earlier step and then finishes its final reply, T3 Code keeps the turn stuck in running forever. The UI shows a completed assistant message above an active red Stop button with no background-work indicator, so the thread looks like stuck text streaming. Steering the thread to finish causes the model to write a second complete reply that also stays stuck in running. When this happens inside a delegated child thread from delegate_task, the child finishes its answer while the parent thread waits forever and never receives the result.

I hit this on 0.1.11-nightly.20261119.4954 with managed antigravity 1.5.13 in a delegated review thread. Early in the run, the child executed a shell loop over filenames containing spaces without quoting, which passed - to ffprobe and left ffprobe blocked on stdin. The agent noticed the bug from the task log, ran a fixed command in a later step, completed its full analysis, and wrote its final review. The ACP event log confirmed session/prompt returned succeeded. Later I steered the child thread asking it to finish. The agent wrote a complete second review and session/prompt returned succeeded again, yet the thread stayed in running and the parent thread stayed in waiting indefinitely with the child still listed in pendingBackgroundTasks.

Tracing apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts, apps/server/src/provider/acp/AntigravityProtocol.ts, packages/provider-acp/src/server/adapter.ts, packages/shared/src/orchestrationV2PendingBackgroundWork.ts, and apps/web/src/components/ChatView.logic.ts on main at commit ccc1feb155 shows four defects that create this deadlock.

First, AntigravityAdapterV2 at lines 241 to 245 enables deferFinalizeForBackgroundWork: true and toolOutlivesPrompt: antigravityToolOutlivesPrompt. In AntigravityProtocol.ts at lines 55 to 59, antigravityToolOutlivesPrompt returns true for every non-daemon execute tool call, even when the agent moved past that command many steps earlier and never asked to wait on it. When session/prompt resolves in packages/provider-acp/src/server/adapter.ts at lines 9075 to 9086, hasDeferredBackgroundWork at lines 4199 to 4207 sees the old execute tool still in status === "running", runs closeTextStreams(context), and returns early without calling finalizeTurn. By contrast, backgroundWorkKindHoldsCompletion in packages/shared/src/orchestrationV2PendingBackgroundWork.ts at lines 110 to 120 avoids holding completion for generic commands unless the agent marks them awaited, and adapter.ts at lines 4212 to 4213 skips context.backgroundCommands for other ACP providers for the same reason.

Second, the UI hides the held command. Because the run never leaves running, derivePendingBackgroundWork in packages/shared/src/orchestrationV2PendingBackgroundWork.ts at lines 271 to 279 returns an empty list whenever hasActiveRun is true. In apps/web/src/components/ChatView.logic.ts at lines 1585 to 1620, deriveThreadPendingBackgroundTasks also filters out every turn item whose runId belongs to liveRunIds. The thread reports pendingBackgroundTasks: [] and renders no background-work status bar or running command badge. A user looking at the thread sees only a finished message and an active Stop button, with no clue that a background shell command from earlier in the run is blocking settlement.

Third, steering cannot break the hold and the watchdog never fires. Because AntigravityAdapterV2 sets steersWithPrompt: antigravitySteersWithPrompt at line 250, a steer dispatches a new session/prompt inside the same ActiveAcpTurn. The agent writes another complete reply, session/prompt succeeds, and hasDeferredBackgroundWork still sees the old running tool in context.tools and skips finalizeTurn again. promptInactivityPaused in adapter.ts at lines 8698 to 8711 returns true whenever any tool in context.tools has status === "running", so the inactivity watchdog stays paused forever. PR #39450 covers only background commands canceled via manage_task, where the SQLite step status changes to canceled. Here the OS process is still alive and blocked on stdin, so the step remains running in Antigravity too.

Fourth, delegated orchestration deadlocks silently. Because the child run never reaches completed, T3 Code never delivers the child's final answer to the parent thread. The parent thread sits in waiting forever even though the child finished its review and is doing no foreground work.

A complete, state-of-the-art fix should solve the lifecycle, UI visibility, and parent-child delivery contract together instead of treating every running execute tool call as an indefinite silent hold:

  1. Show held background tools clearly in the UI and thread state. Whenever promptSettled is true and a run stays open only because hasDeferredBackgroundWork matched running tools, expose those tools in the thread's background-work panel with the command summary, elapsed time, and direct actions to inspect output, kill the background command, or finalize the turn. Never leave the UI showing a finished message, an active Stop button, and an empty pendingBackgroundTasks list.
  2. Distinguish awaited background work from abandoned commands. Align Antigravity with backgroundWorkKindHoldsCompletion in packages/shared/src/orchestrationV2PendingBackgroundWork.ts. Keep the run held only for work the agent is waiting on, such as a schedule wake, an explicitly awaited task, or a background command started in the final planner step where the agent paused to wait for its completion wakeup. If a background command started in an earlier planner step and the agent continued through later steps and emitted a complete final answer with session/prompt succeeding, settle the run cleanly while tracking the still-running command in pendingBackgroundTasks so the user can see or stop it and any late wakeup can still attach.
  3. Prevent delegated parent-child deadlocks. When a delegate_task child finishes its final reply and session/prompt resolves with no foreground work or explicit wait pending, settle the child run and deliver its answer to the parent thread instead of holding the parent in waiting forever on an orphaned shell process. Clean up or clearly report any orphaned child shell processes on child completion.
  4. Bound silent post-prompt holds and make steers aware of held tools. Do not let promptInactivityPaused suppress all staleness detection forever after promptSettled is true when a held tool produces zero output for a long period. If the user steers a thread held open only by an older running tool, show the held command clearly and re-evaluate settlement instead of repeating the same unfinalized hold after the steered prompt succeeds.
  5. Add automated tests across the adapter, projection, and web UI layers. Cover an Antigravity turn that backgrounds a command in an earlier step, runs later steps, and finishes its reply while that earlier command stays running and silent. Verify that the UI displays the running background work instead of an empty pending list, that steering settles cleanly, and that a delegated child delivers its completed reply to its parent thread without deadlocking.

Activity

  1. fcakyon commented on Nov 21, 2026

    @fcakyon
    Contributor

    Another reproduction on nightly with managed agy 1.5.13, this time from an autonomous wake run and with the root cause traced on the command side.

    • session/prompt settled with end_turn at 12:50:48Z. Background task wakes kept the same T3 run busy from 12:51:12Z.
    • At 12:59:48Z the executor model (gemini-flash-worker-agy) started sync-versions.sh && npm ci && npm test && <validators> with WaitMsBeforeAsync: 10000 and no BypassSandbox. Earlier commands in the same run had BypassSandbox: true.
    • Chrome could not launch inside agy's terminal sandbox, and node --test then never exits because browser.test.mjs keeps a handle open. The task log stops at 12:59:59Z. I reproduced the hang outside T3 with a browser executable that fails to launch.
    • The model's last reasoning says Chrome failed in the sandbox, yet it ended with "waiting for the run to finish" and set no wake-up. agy wakes the model only when a task finishes, so the agy log shows no model call and no prompt for 17 minutes, only quota refreshes.
    • T3 held the run the whole time, matching point 4 above. retireInactivePrompt returns done once promptWireSettled is done, and promptInactivityPaused pauses while any tool runs. Nothing bounded it until a later send closed the session (ForceStopCascadeTree, kill_background_tasks=true).
    • T3 never reads agy's task log (brain/<session>/.system_generated/tasks/task-N.log), so the command's Details output stays empty and nothing shows whether it is alive or stuck. The provider handoff summary rendered the command as status=running and Exit code: unknown with no output. The next agent ran ps after the close, found nothing, and reported the indicator as stale.
    • The agy 1.5.13 and 1.5.14 binaries still contain NotificationTimeoutSeconds (a "still running" notice) and a prompt telling the model to set a bounded wake-up, but none of about 13,000 local run_command calls since 2026-11-14 used it, so the model apparently cannot reach it. The 1.5.14 changelog changes nothing here.

    So silent post-settle holds need a bound even for commands the agent did mean to wait on, and tailing the task log into the command item would give the UI and handoffs real evidence.

  2. redrixvix commented on Nov 21, 2026

    @redrixvix

    I saw a related stall in a top-level Antigravity ACP thread on macOS arm64 with Gemini 4 Neon. The background command finished and Antigravity recorded the result, but T3 held the turn open until I stopped it.

    1. The agent started a test command with WaitMsBeforeAsync: 10000. Antigravity returned session/prompt successfully at 15:44:44 UTC on November 21, 2026.
    2. At 15:45:22 UTC, Antigravity recorded Task … finished with result and 62 passed (50.4s). Its transcript shows a subsequent planner step requesting a command to summarize the test output. I found no execution record for that follow-up and no corresponding completion of the T3 turn.
    3. T3 still showed the turn as running at 16:16:57 UTC, about 31 minutes after the task finished. A manual Stop cleared it, and the next message completed normally. T3 surfaced the original command output on that next turn.

    The incident preceded the local update to 0.1.12-nightly.20261121.5051 at 16:28 UTC. The previous build was likely 0.1.12-nightly.20261121.5038, based on the desktop update log. The latest patch addresses ACP history replay in #40328. This command started live, and 5051 still defers settlement for running non-daemon Antigravity commands. I have not reproduced the incident on 5051.

    This looks related to the settlement behavior reported here. In this case Antigravity itself logged that the background task finished, so it may help to check whether its terminal tool update or the subsequent wake reached T3.

    Triaged with Codex in T3 Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions