Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): Antigravity threads stay working while a background command runs, and Stop ends it #38916

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/38916/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Two Antigravity problems left after #38864:

  1. The thread showed idle while a command ran. agy ends its prompt while a command it backgrounded still runs, and replies by itself when the command finishes. T3 Code ended the run at the prompt and marked the command completed. The thread looked stopped until the reply started a second run, and Stop was not offered.
  2. Every Antigravity thread listed two servers. They were agy's own loopback ports, not servers the agent started.

Fixes #16442. Fixes #38868.

Fix

  • A run stays open while a command the agent waits for still runs. The command row shows running, and the reply lands in the same run.
  • A daemon (IsDaemon: true) does not hold the run, because it may never end. When one exits, the continuation from #38864 still reports it.
  • Stop sends session/cancel, which ends the command in agy 1.5.11. A message sent while the command runs does not send it, so the command keeps running.
  • A held run fails when the agent process exits. No prompt is open then, so nothing else reported it.
  • The Servers panel skips a listener that is the agent CLI itself (a direct child of the server). Servers that the agent's commands start are still listed.

No process-group teardown is needed. Captures from agy 1.5.11 show that session/cancel ends a background command even with no prompt open, and that killing the agy process does not end it, because each command is its own session leader.

Other providers do not change: the new behavior is behind a flavor hook that only the built-in Antigravity adapter sets.

Proof

Real agy 1.5.11 through vp run dev:

  • Held run: one run stayed running for a 20 s background command, the command row went from running to completed, then the run completed. Before, this was two runs with an idle gap.
  • Stop: with sleep 240 running after the prompt ended, Stop ended the process, and the run and the command row showed interrupted. agy stayed alive.
  • Message while a command runs: the command kept running, the agent answered the message, and a follow-up run reported the command output when it finished.
  • Servers panel: only the python3 -m http.server that agy started is listed.
Run stays open, Stop is offeredServers panel lists only the real server
Thread shows Working and a running command after the agent ended its promptServers panel lists one python3 server

Before, for the Servers panel (from #38864's proof, two Agent · antigravity rows): Servers panel lists agy's own two ports

Tests:

  • AntigravityAdapterV2.test.ts: the run stays open and ends in one run; Stop sends one cancel; a new message sends none; the agent exiting fails the run. Each case fails without its part of the fix.
  • PortScanner.test.ts: the agent CLI's own listener is not listed, on Linux and macOS.
  • vp run check:changed passes. vp test run src/orchestration-v2/Adapters src/preview src/provider/acp: 33 files pass.

Credit

This PR takes over two open PRs for #16442:

  • #35073 by @juliusmarminge: keep the turn open for a running command, and the test direction.
  • #36585 by @saphid: fail a held turn when the runtime dies.

Their process-group and macOS libproc teardown is not included, because session/cancel already ends the command.

Known limits:

  • A daemon row is still marked completed when the run ends, and Stop cannot end a daemon after the run.
  • A message sent while a command runs marks that command row interrupted until the command finishes. The command itself keeps running.
  • The registry agy path keeps the #38864 behavior (the run ends, then a continuation run).
  • An agent launched through a wrapper process still lists its own ports.

Reviewed with sol-loop: 2 passes with GPT-6.2 Sol. Sol verdict: approved

Created with Claude Fable 5.2 in Claude Code, running in T3 Code.

🤖 Generated with Claude Code

    1. tanstack-source added labelsbug

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.5 KiB21.5 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Other scenarios

      All 64 scenario measurements match main.

      All 64 scenario measurements
      ProviderScenarioMetricMain baselineThis PRImpactPR ceiling
      Codexshort turn resumeWebSocket decoded10.5 KiB10.5 KiB0 B (0.0%)12.7 KiB✅
      Codexshort turn resumeWebSocket messages220 (0.0%)2✅
      Codexlong turn running, cold openHTTP decoded281.7 KiB281.7 KiB0 B (0.0%)302.7 KiB✅
      Codexlong turn running, cold openrows75750 (0.0%)75✅
      Codexlong turn running, history pageHTTP decoded92.4 KiB92.4 KiB0 B (0.0%)107.4 KiB✅
      Codexlong turn running, history pagerows75750 (0.0%)75✅
      Codexlong turn finished, cold openHTTP decoded381.5 KiB381.5 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, socket cold openWebSocket decoded381.6 KiB381.6 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Codexlong turn finished, socket cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, work pageHTTP decoded186.2 KiB186.2 KiB0 B (0.0%)200.2 KiB✅
      Codexlong turn finished, work pagerows1501500 (0.0%)150✅
      Codexidle thread resumeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexidle thread resumeWebSocket messages110 (0.0%)1✅
      Codexfleet shell snapshotHTTP decoded42.4 KiB42.4 KiB0 B (0.0%)53.7 KiB✅
      Codexfleet shell snapshotrows27270 (0.0%)27✅
      Codexfleet shell subscribeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexfleet shell subscribeWebSocket messages110 (0.0%)1✅
      Codexfleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Codexfleet shell resume checkrows0000✅
      Codexstale shell reloadHTTP decoded42.4 KiB42.4 KiB0 B (0.0%)53.7 KiB✅
      Codexstale shell reloadrows27270 (0.0%)27✅
      Codexstale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Codexstale shell resumeWebSocket messages220 (0.0%)2✅
      Codexstale todo list cold openHTTP decoded72.4 KiB72.4 KiB0 B (0.0%)83.0 KiB✅
      Codexstale todo list cold openrows75750 (0.0%)75✅
      Codexstale todo list cold opennodes220 (0.0%)4✅
      Codexstale todo list cold opensubagents220 (0.0%)4✅
      Codexstale todo list cold openplans110 (0.0%)2✅
      Codexstale todo list cold openproviderTurns110 (0.0%)2✅
      Codexstale todo list cold opencheckpoints110 (0.0%)2✅
      Claudeshort turn resumeWebSocket decoded10.6 KiB10.6 KiB0 B (0.0%)12.7 KiB✅
      Claudeshort turn resumeWebSocket messages220 (0.0%)2✅
      Claudelong turn running, cold openHTTP decoded283.3 KiB283.3 KiB0 B (0.0%)302.7 KiB✅
      Claudelong turn running, cold openrows75750 (0.0%)75✅
      Claudelong turn running, history pageHTTP decoded93.4 KiB93.4 KiB0 B (0.0%)107.4 KiB✅
      Claudelong turn running, history pagerows75750 (0.0%)75✅
      Claudelong turn finished, cold openHTTP decoded384.2 KiB384.2 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, socket cold openWebSocket decoded384.3 KiB384.3 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Claudelong turn finished, socket cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, work pageHTTP decoded188.1 KiB188.1 KiB0 B (0.0%)200.2 KiB✅
      Claudelong turn finished, work pagerows1501500 (0.0%)150✅
      Claudeidle thread resumeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudeidle thread resumeWebSocket messages110 (0.0%)1✅
      Claudefleet shell snapshotHTTP decoded43.0 KiB43.0 KiB0 B (0.0%)53.7 KiB✅
      Claudefleet shell snapshotrows27270 (0.0%)27✅
      Claudefleet shell subscribeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudefleet shell subscribeWebSocket messages110 (0.0%)1✅
      Claudefleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Claudefleet shell resume checkrows0000✅
      Claudestale shell reloadHTTP decoded43.0 KiB43.0 KiB0 B (0.0%)53.7 KiB✅
      Claudestale shell reloadrows27270 (0.0%)27✅
      Claudestale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Claudestale shell resumeWebSocket messages220 (0.0%)2✅
      Claudestale todo list cold openHTTP decoded73.4 KiB73.4 KiB0 B (0.0%)83.0 KiB✅
      Claudestale todo list cold openrows75750 (0.0%)75✅
      Claudestale todo list cold opennodes220 (0.0%)4✅
      Claudestale todo list cold opensubagents220 (0.0%)4✅
      Claudestale todo list cold openplans110 (0.0%)2✅
      Claudestale todo list cold openproviderTurns110 (0.0%)2✅
      Claudestale todo list cold opencheckpoints110 (0.0%)2✅

      Baseline: 455a60a · PR result: 0d9973d · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Sign in to join this conversation.