Skip to content
Context windows and tokensallAllLearnContext windows and tokens LearnAllAntigravity AppAntigravity CLIAntigravity IDEIDE ExtensionsAntigravity SDK

Every language model reads and writes text in chunks called tokens. Each model has a maximum context window it can hold at once. Even with a large window, clean context makes replies faster, more accurate, and lighter on quota.


Models split text and code into subword units before processing them:

  • In English prose, 1 token is roughly 4 characters or three-quarters of a word.
  • In source code, indentation, brackets, and punctuation often count as separate tokens. A 100-line TypeScript file usually uses 400 to 800 tokens.
  • Every turn shares one context window across system instructions, built-in tools, MCP tool schemas, and active rules. Conversation history, file contents, command outputs, and model reasoning tokens share that same window.

Antigravity reduces background overhead automatically. Connected MCP tools are lazy-loaded by default so full parameter schemas stay on disk until needed. Always-on rules share a 20,000-token budget, automatically demoting the largest files to on-demand pointers if exceeded.

For exact token-counting behavior on Gemini models, see Understand and count tokens.


Dumping dozens of unrelated files into a single prompt rarely improves quality:

  • Diluted attention: Irrelevant logs, old stack traces, and unrelated files compete with the lines that matter for your edit.
  • Higher latency and quota use: Larger prompts take longer to process on every turn and consume more model quota.
  • Stale assumptions: Long threads accumulate outdated file snapshots and abandoned ideas that can confuse later turns.

Treat context like RAM, not a hard drive. Keep a small active working set and let the agent fetch reference code only when needed.

Context layerWhat belongs hereHow to manage it
Active working setTarget files, failing test output, and specs for the current task.Reference files with @-mentions or paste only the failing error lines.
Reference codebaseNeighboring packages, utilities, and documentation.Let the agent search and read files on demand instead of pasting whole folders.
Durable rulesRepo conventions and repeatable workflows.Store in Rules and Skills rather than long chat intros.

@-mentions pass the file or folder path, not its raw contents, so the agent reads only what it needs. In the Antigravity App, use Quote to send exact selected lines (Cmd + L on macOS; Ctrl + L on Windows and Linux).


Antigravity compacts older turns automatically as a thread nears the context limit. You can also manage context directly on both surfaces:

  • Mention and quote: Type @ to reference files, folders, rules, or past conversations. Select text in a response, diff, or artifact and click Quote (Cmd + L or Ctrl + L).
  • Compact on demand: Run /compact (v2.21.0+) to checkpoint earlier turns. Pass /compact <focus> to summarize and continue in one turn.
  • Ask side questions: Run /btw (v2.32.0+ with tools) to open a read-only Side Question tab. Its lookups stay out of your main thread.
  • Revert or fork: Click Revert on an earlier prompt to drop a dead end. Click Fork to test another approach in a new thread.
Symptom or goalAntigravity toolWhat happens to context
Long thread after exploration or a milestone/compact <focus>Summarizes earlier turns into a checkpoint and continues with your focus.
Quick tangential question while the agent works/btw <question>Answers in a read-only fork without adding to main history.
Unexpectedly high token usage (CLI)/contextBreaks down token share across messages, tools, rules, and MCP servers.
Dead-end debugging tangent/rewind (CLI) or Revert (App)Drops failed turns so stale assumptions do not linger.
Switching to an unrelated task/clear (CLI) or New Conversation (App)Starts a clean thread with empty history.
Multi-module task across separate filesSubagents or /swarmGives each worker a fresh context focused only on its own files.

Run compact-and-continue right after finishing codebase exploration:

/compact Keep the key architecture decisions, target file paths, and failing test names, and now implement the next step.