Back to Devoured - November 19, 2026
DEVOURED
Why Antigravity Eats Weekly Quota Fast - and What I Measured

Why Antigravity Eats Weekly Quota Fast - and What I Measured

AI Aastha Subedi
Google Antigravity wipes prompt caches after 5 minutes of idle time, forcing users to pay for full context re-ingestion frequently.
What: Researcher Aastha Subedi discovered that a background keep-alive ping can prevent cache eviction, saving up to 8.9x on token costs in large coding sessions.
Why it matters: This reveals how opaque infrastructure costs—like cache TTL (Time To Live)—can significantly impact the economics of using frontier AI models for long-duration coding tasks.
Takeaway: If using the CLI, consider using custom keep-alive scripts to ping your session every 4 minutes and 30 seconds to avoid the 5-minute cache cliff.
Deep dive
  • Cache behavior: Implicit caching is discarded after 285 seconds of inactivity.
  • Cost impact: Re-ingesting 150k context tokens after a miss is drastically more expensive than a warm cache hit.
  • Binary findings: Google's internal code has a dormant 'keepalive.go' engine that performs 1-token pings to keep the cache warm.
  • Methodology: The researcher used binary patching on the Antigravity CLI to unlock the native keep-alive engine.
  • Efficiency: A ping cycle saves 29-36% of effective token costs on standard sessions.
Decoder
  • TTL (Time To Live): A setting that determines how long data remains in a cache before being deleted or refreshed.
  • Implicit caching: A system where the provider automatically attempts to reuse cached tokens from the beginning of a prompt if the sequence matches previous requests.
  • MCP (Model Context Protocol): An open standard for connecting AI agents to data sources and tools.
Original article

Why Antigravity Eats Weekly Quota Fast - and What I Measured

Gemini 4 Hydrogen, Gemini 4 Argon, and hy4-flash via OpenCode used for the binary reverse engineering, empirical cache probing, and keep-alive tooling.

Introduction

Greetings! If you use Google Antigravity (agy) with the big frontier models, you have probably noticed how fast your weekly quota disappears during normal coding sessions.

My suspicion was simple: a short prompt-cache lifetime. When you are coding with an agent, you don’t send messages every 10 seconds. You wait for a response, read the diff, run a test, think for 5 minutes, and then send your next prompt. If the prompt cache expires during that 5-minute pause, your next message has to re-ingest the entire conversation history at full price.

Instead of just assuming that was true, I decided to actually test it and look inside the Antigravity binaries to see how caching works under the hood. What started as a quick TTL check turned into disassembling a 193 MB Go binary, discovering a dormant keep-alive engine that Google already wrote, binary-searching the exact eviction cliff down to a 15-second window, testing whether /btw side-questions can keep the cache warm, and finally unlocking Google’s built-in zero-trajectory keep-alive engine on a live 6-minute run.

1. Background: Implicit Caching & The Idle Tax

To understand why pauses matter, let’s look at how Gemini models handle context in Antigravity.

Every turn in an agentic coding session carries a massive prefix: the system prompt, tool schemas, connected MCP servers, skill definitions, and all previous turns. On Gemini 4 models, Antigravity relies exclusively on implicit caching. Unlike explicit caching (where you manually place cache breakpoints and pay for a guaranteed storage lease), implicit caching is an automatic, best-effort prefix match on Google’s backend.

When your request hits the implicit cache, cached tokens (cache_read_tokens) get a 90% discount compared to regular uncached input_tokens. When the cache misses, you pay 100% on the entire prefix.

Google does not publish a fixed TTL for implicit caching. If that TTL is shorter than a typical code-review pause, interactive coding turns into a worst-case workload.

2. What the Binary Says

Before running live probes, I inspected the local Antigravity installation on macOS (arm64): the desktop app (/Applications/Antigravity.app, v2.33.0), its core Go agent binary (language_server), and the standalone CLI (~/.gemini/bin/agy, v1.5.11 / 1.5.12) across isolated CLI runs.

2.1 Telemetry Buckets Give Away the 5-Minute Cliff

Inspecting the Go symbol table in language_server immediately confirmed that Antigravity tracks cumulative context through CumulativePromptHandler and buckets turn gaps into two telemetry categories: lt_5m (less than 5 minutes) and ge_5m (5 minutes or more). That alone was a strong clue that 5 minutes is the magic number.

2.2 Google Already Built a Keep-Alive Engine

Digging deeper, I found a file path in the binary’s symbol table: modelapiccpa/keepalive.go. Disassembling its functions (keepAlivePings, beforeRequest, scheduleNextPingLocked, ping, and trimLastBlock) revealed that Google already built an automatic background prompt-cache keep-alive mechanism.

Here is how their internal keep-alive works:

  1. Zero-Trajectory Pollution: When a turn finishes (onRequestDone), the client schedules a background timer. When the timer fires, it clones the last request protobuf, calls trimLastBlock to replace the final prompt block with a single period ("."), sets max_output_tokens = 1, tags the request with "prompt_cache_keep_alive": "true", and sends it in the background. When the 1-token response comes back, it throws it away so it never pollutes your conversation history.
  2. Exact Hardcoded Timers:
    • Ping interval: Hardcoded in scheduleNextPingLocked to 4 min 30 s (270s).
    • Staleness cutoff: Hardcoded in ping to 4 min 45 s (285s). If the timer wakes up more than 4m 45s after the last turn (e.g., after laptop sleep), it aborts the ping because it knows the server cache is already dead.

Why do we still lose the cache every 5 minutes? Two gates in the binary stop it from running:

  • Gate A (keepAlivePings): Locked behind server-side Mendel experiment flags (enable-prompt-cache-keep-alive and prompt_cache_keep_alive_max_pings) that aren’t exposed in settings.json or Antigravity hooks.
  • Gate B (beforeRequest): Checks the internal model provider enum (0x5 or 0xa) and currently restricts background pings to explicit-cache provider enums (like Claude), completely skipping Gemini models.

3. Experimental Setup: Measuring Cache Hits

Since account-level quota percentages are noisy (other background agents share the same quota pool), I used cache_read_tokens from agy --input-format stream-json --output-format stream-json as the primary ground-truth signal.

At the end of every turn, agy emits a DONE event for agent_response with three numbers:

  • input_tokens (T_uncached): Tokens billed at full price.
  • cache_read_tokens (T_cached): Prefix tokens served from the implicit cache.
  • output_tokens: Generated response tokens.
Observed Signal What It Means
Large cache_read_tokens (~14,770), small input_tokens (~2,150) Cache Hit - prefix served from cache, only tail billed at full price.
cache_read_tokens = 0, large input_tokens (~16,820+) Cache Miss - full prefix re-ingested from scratch.

4. What I Measured

4.1 Separate CLI Processes Don’t Share the Cache

First, I tried running two separate one-shot agy -p --conversation <same-id> commands back-to-back. Two things stood out immediately:

  1. Even on a brand-new conversation with a 5-word prompt, Turn 1 sends 16,816 tokens (system prompt, tool declarations, MCP servers, and skills).
  2. In the same process, Turn 2 hits the cache for 14,762 tokens, leaving only 2,152 uncached tokens. Across separate one-shot agy -p processes, cache_read is always 0 because one-shot mode re-initializes the step timestamp at step 0, breaking prefix continuity.

4.2 The 8-Minute Idle Test (With vs. Without a Ping)

I tested an 8-minute idle gap with no activity, and compared it against an 8-minute window with a single keep-alive ping at +4 minutes. This proved that without a ping, waiting 8 minutes forces Turn 2 to pay full price, and hitting the implicit cache resets its TTL timer.

4.3 Binary Search for the Exact Expiry Boundary

To find the exact cliff where the cache dies, I ran a binary search across idle intervals. The boundary is between 4 min 45 s and 5 min 00 s. That matches both my initial 5-minute estimate and the 4 min 45 s (285s) staleness cutoff hardcoded inside Google’s keepalive.go.

5. Cost Analysis & Scaling Math

Since Gemini gives a 90% discount on cached tokens, I calculated the effective token cost (C) of any turn by weighting cache_read_tokens at 0.1x: C = T_uncached + 0.1 * T_cached.

Even on an empty conversation with just the 14.8k base prefix, one well-timed ping saves 29-36% savings. In a 150k-token session, pausing for 5 minutes costs you 133,065 extra effective tokens on your very next message.

6. The /btw Experiment: Can Side-Questions Keep the Cache Warm?

Sending a normal user message as a keep-alive in the CLI has one downside: each ping adds a user and assistant turn to your trajectory. Antigravity has a /btw slash command that lets you ask a side question in a forked thread. My tests showed /btw does keep the main cache warm, but it is expensive: it costs ~4.9x a normal warm ping and ~26% more than just accepting a cache miss.

7. Unlocking Google’s Built-In Engine & Live Verification

I built a verification and binary-patching script to unlock Google’s internal keepalive.go engine. By patching the prologue and provider branch, I confirmed that the background streamGenerateContent ping fired automatically and refreshed the backend cache without adding a single character to the conversation history.

8. Wrapping Up & Practical Takeaways

  1. The 5-minute cache cliff is real: Both empirical binary search (4m 45s - 5m 00s) and Google’s own hardcoded 285s (4m 45s) cutoff confirm that a 5-minute pause wipes your prompt cache.
  2. A 4m 30s keep-alive ping works, if you cap it: Refreshing the cache before expiry saves 30% to 88% of effective tokens across a pause.
  3. Google’s built-in keepalive.go engine works on Gemini: Once its Mendel flag and provider-enum gates are unlocked, Antigravity’s native background ping keeps Gemini caches warm across 6+ minute pauses with zero trajectory growth.
  4. Trim your baseline prefix: Disabling unused MCP servers and plugins shrinks every cold turn and cache miss across the board.
Explore all 60 articles in today's digest

Fresh dev news, AI-digested daily. Never miss a trend at devoured.fyi