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
- Start a delegated task in a project using the Antigravity ACP provider with
gemini-4-neon.
- Let the agent run at least one backgrounded shell command so the initial
session/prompt settles and the run enters deferred finalization.
- 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.
- 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