Environment
- Platform: Windows 11 (x64)
- Tool / Component: Antigravity CLI (
agy.exe, v0.154+ / latest build) - Execution Mode: Headless print mode (
--input-format stream-json --output-format stream-json --json-schema <path>) - Selected Model: Gemini 3.8 Flash (High)
- Backend Service:
https://daily-cloudcode-pa.googleapis.com/v1internal:streamGenerateContent?alt=sse
Summary & Impact
In autonomous long-running agent tasks (e.g. 269 steps across 19 modified files and comprehensive Maven test execution, accumulating >230K prompt tokens):
- The agent successfully completes the task and calls the built-in
finishtool at step 268, providing valid parameters strictly adhering to the specified JSON schema (125 tests passed, exitCode 0). - The runtime engine executes the tool and returns:
"Task is complete. Summarize what you did and do not call any more tools." - AGY CLI then sends a subsequent
streamGenerateContent?alt=sserequest to obtain the final conversational summary. - Due to the high token count (~231K tokens) and payload size, the upstream SSE streaming connection abruptly drops after ~4.7s with:
API error (attempt 1): request failed: Post "https://daily-cloudcode-pa.googleapis.com/v1internal:streamGenerateContent?alt=sse": EOF
(or"The stream was interrupted. Please continue the task you were working on.") - The Critical Defect: AGY CLI’s execution loop treats this non-essential final conversational turn failure as a fatal error, overriding the entire session’s
result.statusto"ERROR". It completely ignores that thefinishtool call succeeded and validstructured_outputwas already generated and persisted. Downstream callers parsing--output-format stream-jsonare forced to mark successful tasks asFAILED.
Trace IDs & Production Evidence for Google Backend Engineers
Incident 1 (Terminal Hard EOF):
- Conversation ID:
28c4dafa-4d17-411e-8ed2-** - Failing Request Timestamp:
2026-09-20 23:44:45.486 CST(15:44:45.486 UTC) - Trace ID:
0x4f780ad9c*** - ResponseID:
af-vaqOMGYrM0-*** - Context Size at Crash:
230,982input tokens (cumulative turn tokens > 2.03M, cache read tokens > 14.1M) - Step Sequence: Step 268 (
finishtool called) → Step 269 (tool response received) → Step 270 (streamGenerateContentfailed with EOF after 4.768s)
Incident 2 (Stream Interrupted):
- Conversation ID:
5424b0a7-802b-404b-8739-*** - Failing Request Timestamp:
2026-09-20 23:29:45.578 CST(15:29:45.578 UTC) - Trace ID:
0x3849660ea*** - ResponseID:
5vuvar2YKOP82** - Step Sequence: Step 128 (
finishtool called) → Step 129 (tool response received) → Result emitted with"error": "The stream was interrupted. Please continue the task you were working on."
Root Cause Analysis
1. Mismatch Between Nominal Model Window and Streaming Gateway Stability
- The Gemini model nominal context window is 1,048,576 tokens.
- Internal compaction rules (
CompactionConfig/checkpointNeeded) only evaluate threshold triggers at high utilization (typically ~70-80% of nominal window). - At 230K tokens (~22% utilization), automatic compaction is never triggered because AGY believes there is ample headroom.
- However, the HTTP/2 SSE streaming gateway (
daily-cloudcode-pa.googleapis.com) cannot sustain reliable connections when TTFT and prompt context reach hundreds of thousands of tokens, dropping the TCP/SSE stream prematurely.