Tutorial · Antigravity

Antigravity 300: Mastering the Context Window & Health Extension

Every instruction, open file, and chat message consumes your Context Window. Here is the ultimate guide to optimizing Antigravity for peak reasoning power.

The video version · same thesis, looser edits

In Google Antigravity, the “Context Window” is your most precious resource. It is the finite “RAM” where the agent processes instructions, history, and code.

When this window gets full, you pay three prices: higher token costs, increased latency, and “Context Rot” (where the agent becomes “stupid” or forgets instructions). Today, we’re looking at the “Tab Tax” and why your 20 open files are killing your agent’s reasoning power.

The Three Pillars of Context

Every interaction involves a competition for space between three different data sources:

  1. Instructions: Rules, Skills, Workflows, MCP Tools.
  2. History: Chat logs, Agent Manager discussions, Planning Artifacts.
  3. Source Code: The Repository Map, Open Tabs, @ mentions.

Pillar 1: Instruction Layer (Rules & Skills)

The .agent/ folder defines the agent’s “personality” and “capabilities,” but it can easily become a “token tax” on every prompt. If a rule is “Always On,” its text is injected into the system prompt of every message.

Having 10 “Always On” rules can eat up 30,000 tokens before you even type your first word.

The Solution: Progressive Disclosure. Move complex logic into .agent/skills/. The agent only sees the description first. It only “reads” the full skill if the task requires it. Also, use Glob Patterns (glob: "src/**/*.ts") to ensure a React rule doesn’t take up space when you are editing a Python script.

Pillar 2: Conversation History

Antigravity uses an Agent Manager to track your progress. Over time, the “Rolling History” becomes a liability. Every new message sends the entire previous conversation back to the LLM.

The Solution: The “Fresh Start” Protocol. Once a Task Group is finished, or if the agent starts hallucinating, start a new session. This wipes the “Rolling History” while keeping your Rules and Skills intact. Keep one chat session per specific feature or bug.

Pillar 3: Source Code & RAG

Antigravity handles large codebases using Retrieval-Augmented Generation (RAG), but user habits can override this efficiency. Most agentic IDEs prioritize open tabs. If you have 20 files open, the agent often “stuffs” the content of all 20 files into the context window, bypassing the efficiency of RAG.

The Solution: Close Dead Tabs. If you aren’t working on it, close it. Trust the index before using an @ mention. Let the RAG do the heavy lifting of finding the logic. Use Planning Mode to let the agent create Task Groups, which compartmentalizes the code it needs to “see” for each sub-task.

The Antigravity Health Extension

To help manage all of this, I built and open-sourced the Antigravity Health Extension (available on my GitHub).

This extension provides a visual dashboard of your current token consumption, breaking it down by Rules, History, and Open Tabs. It warns you when you are approaching “Context Rot” levels and suggests when it’s time to initiate a Fresh Start.

By applying these optimizations, you can make your AI development 10x cheaper and 2x faster. Keep your context clean!

More in Antigravity