Skip to content

[Bug]: Antigravity delegated run finalizes early during 3-second deferred finalize debounce between model steps #41345

Closed as not planned

Description

@netherguy4

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Impact

Major degradation or frequent failure

Summary

A delegated Antigravity run finalizes and closes while the agent is still working between two model steps. After the initial session/prompt settles, T3 Code keeps the run open only while a non-daemon execute command runs or while hasPendingReply sees an unread high-priority inbox wake or a trailing SYSTEM_MESSAGE in the transcript. Between a tool step such as a file edit and the next model response, no command is running and readAntigravityPendingReply returns false. scheduleDeferredFinalize then finalizes the run after the 3-second ACP_DEFERRED_FINALIZE_DEBOUNCE, and about 4 seconds later T3 Code sends session/close with kill_background_tasks=true.

Environment

  • OS: Linux
  • T3 Code version: 0.1.12-nightly.20261122.5111, still present on main as of 2026-11-23
  • Provider: Antigravity ACP
  • Model: gemini-4-neon

Steps to reproduce

  1. Start a delegated task in a project using the Antigravity ACP provider with gemini-4-neon.
  2. Let the agent run at least one backgrounded shell command so the initial session/prompt settles and the run enters deferred finalization.
  3. After the background command wakes the agent, let the agent run a multi-step sequence that includes a synchronous tool such as a file edit followed by a slow model response.
  4. Observe the run state while the model prepares its next response after the tool completes.

Expected behavior

The delegated run stays open while the agent waits for the next model response after a tool call or tool result. T3 Code does not finalize the turn or send session/close until the agent finishes its final model response.

Actual behavior

Once the initial session/prompt settles, packages/provider-acp/src/server/adapter.ts sets context.replyOpen = false on usage_update and arms ACP_DEFERRED_FINALIZE_DEBOUNCE for 3 seconds whenever no non-daemon execute command, schedule, or subagent is running.

When the 3-second debounce expires, scheduleDeferredFinalize calls hasPendingReply, which delegates to readAntigravityPendingReply in apps/server/src/provider/acp/AntigravityChildWork.ts. readAntigravityPendingReply returns true only when .system_generated/messages/ has an unread MESSAGE_PRIORITY_HIGH message or when the last line of .system_generated/logs/transcript.jsonl has type === "SYSTEM_MESSAGE". Between a completed tool step such as a file edit and the next model response, neither condition holds, so readAntigravityPendingReply returns false.

T3 Code emits turn.completed, creates a checkpoint, and sends session/close with kill_background_tasks=true about 4 seconds later. The delegated task closes with incomplete work. Sending a new message to the thread resumes the session without losing context.

Evidence

  • Observed on several consecutive runs of one delegated task in my project at durations of 19 minutes, 47 minutes, 57 minutes, and 62 minutes.
  • Between two model steps, for example a file edit followed by a model response taking about 60 seconds, T3 Code finalized the run with turn.completed and a checkpoint, sent session/close with kill_background_tasks=true about 4 seconds later, and the model response arrived about 1 second after the run closed.
  • The Antigravity language-server log contained no stop reason, no max-tokens error, and no context or auth error.
  • Verified on main as of 2026-11-23 that readAntigravityPendingReply in apps/server/src/provider/acp/AntigravityChildWork.ts lines 763 to 783 checks only unread high-priority inbox messages and a trailing SYSTEM_MESSAGE line in transcript.jsonl.

Suggested fix

Update readAntigravityPendingReply in apps/server/src/provider/acp/AntigravityChildWork.ts to treat the turn as unfinished when the last step in transcript.jsonl is a tool call or a tool result without a following model response. Return true when the trailing transcript record is a tool execution step, a tool result step, or a PLANNER_RESPONSE carrying tool_calls with no subsequent PLANNER_RESPONSE.

That allows scheduleDeferredFinalize to extend into the 2-minute ACP_OPEN_REPLY_QUIET_LIMIT while the model generates the next step, matching the existing bound used for queued background wakes in #39989.

Workaround

Send a new message to the delegated thread to resume the Antigravity session. Context is not lost.

Related

Activity

  1. juliusmarminge commented on Nov 23, 2026

    @juliusmarminge
    Member

    I tried to reproduce this on the current build and could not.

    Commit 7180578 (origin/main). Live attempt: fresh worktree, T3CODE_DEV_SEED=0 GOOGLE_GEMINI_BASE_URL=<hub> vp run dev, added an Antigravity instance in Settings > Providers > Add provider with sign-in method 'Gemini API key', added a scratch git project, and started threads via t3 thread start --provider <antigravity instance> --model <m> with a prompt asking for a background sleep 45 command, then file edits and a long reply. All three hub models (gemini-4-neon, gemini-4-hydrogen, gemini-3.8-flash) failed the first turn immediately with HTTP 429 'Individual quota reached ... reset in 64h', so the background/tool-boundary sequence never ran. Code-level reproduction: extended the existing readAntigravityPendingReply case in apps/server/src/provider/acp/AntigravityChildWork.test.ts with a transcript ending on a PLANNER_RESPONSE carrying tool_calls, and on that tool call followed by its GENERIC result step. vp test run src/provider/acp/AntigravityChildWork.test.ts -t 'detects unread high-priority' fails on main: expected true, got false at the trailing tool-call assertion. Pushed as factory/repro-41345 (b93922b).

    Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.

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