There's a specific kind of frustration that shows up during long Antigravity sessions: the agent starts ignoring conventions you established ten minutes ago, contradicts earlier decisions, or simply throws a "context length exceeded" error and stops responding. These all point to the same underlying cause — the model's context window has filled up.
When an explicit error appears, you know exactly what's happening. The trickier case is when the quality just quietly degrades — shorter responses, forgotten instructions, inconsistent code — and you're left wondering if you're doing something wrong. You're probably not. You've just hit the context limit.
How to Recognize a Context Limit Error
Context limit issues show up in two forms.
Explicit error messages
The most obvious sign is a message like this in the chat:
Context length exceeded. Please start a new conversation or reduce the context.
Or from the underlying Gemini API:
400 INVALID_ARGUMENT: Request payload size exceeds the limit
Gradual quality degradation
More commonly, there's no error — just a noticeable change in the agent's behavior:
- It starts ignoring naming conventions or architectural patterns you agreed on earlier
- References like "the function we just wrote" stop making sense to it
- Responses get shorter or cut off mid-sentence
- It imports different libraries than the ones you've been using throughout the session
This second pattern is easy to misread as a model quality issue or a bug. In reality, the model is running out of room to hold the full conversation history, and earlier context is being effectively dropped.
Distinguishing from connection errors
Network errors show up as "Network Error," "timeout," or "cannot connect to server." Context limit errors are model-side constraints — reconnecting your network won't fix them. A simple test: start a fresh chat and try the same operation. If the problem disappears, context was the culprit.
Immediate Fix: Restarting a Chat Without Losing Your Work
The fastest way out is to open a new chat session with Cmd/Ctrl + N or the "+" button in the sidebar.
The challenge is continuing where you left off. Copying your full conversation history into the new chat will hit the limit again almost immediately. Instead, compress what you need into a short context summary and paste it at the start of the new conversation.
## Project
Next.js 15 + TypeScript + Supabase SaaS app
## Current task
Fixing JWT refresh logic in /src/app/api/auth/route.ts
## Decisions made so far
- Managing sessions in Route Handlers, not Middleware
- RLS checks done explicitly in server components, not bypassed
## Next step
Wrap handleRefreshToken in try/catch and add proper error typesFour elements cover almost everything: what the project is, what you're working on right now, what's already been decided, and what comes next. With this in a new chat, you can pick up where you left off within a few exchanges.
It's worth keeping a running version of this summary as you work — update it when you make important decisions. That way, a context reset never means losing more than a few minutes.
Better @File References to Reduce Token Usage
Hitting the context limit frequently usually means @file references are consuming more tokens than necessary. For a deeper look at precision referencing, see Mastering @References in Antigravity: A Practical Guide to Context Precision. Here are the patterns that make the biggest difference for token efficiency.
References that eat through your context budget
# ❌ Referencing an entire directory loads every file at once
@src/
# ❌ Multiple large, loosely related files at the same time
@src/lib/utils.ts @src/types/global.ts @src/app/layout.tsx @src/components/Nav.tsxReferences that keep token usage low
# ✅ One relevant file, with a specific question
"Look at @src/app/api/auth/route.ts.
I want to improve error handling in the handleRefreshToken function."
# ✅ Scoped to the exact section you need
"In @src/components/Button.tsx, update only the disabled state CSS classes."The shift from "look at this whole file" to "look at this specific function in this file" can cut token usage dramatically. The more precise your reference, the more useful content fits in each exchange.
Using .antigravityignore to Exclude Unnecessary Files
Antigravity automatically indexes your project files and includes relevant ones in its context. The .antigravityignore file lets you exclude directories and files from this index — which means they won't consume context budget at all.
For full configuration options, see The Complete .antigravityignore Guide. For context limit management specifically, these exclusions tend to have the most impact:
# .antigravityignore (place in project root)
# Build outputs — always exclude
.next/
dist/
build/
out/
# Test snapshots — can grow large
__snapshots__/
*.snap
# Large data files
data/
*.csv
*.json.bak
# Documentation — reference with @ when needed, not constantly indexed
docs/
# Log files
logs/
*.logAfter saving the file, reload the window (Cmd/Ctrl + Shift + P → "Reload Window") for the changes to take effect.
In monorepos or large projects, excluding unrelated packages alone can make a noticeable difference in how quickly you reach the context ceiling.
A Workflow That Prevents Context Overflow
If you're hitting the limit repeatedly, the root cause is often task size rather than file size. Antigravity agents work better with small, focused tasks repeated many times than with large, sweeping requests.
For major refactors or feature additions, a planning-then-implementing split is worth adopting. The Antigravity Planning Mode vs. Fast Mode: Practical Guide covers this in detail, but the core pattern is simple:
- Ask the agent to break down the feature into a numbered task list (this phase can use broad context)
- Save that plan somewhere — a comment block, a scratch file, or a README section
- Open a new chat for implementation: "I'm working on step 1 of this plan: [paste plan]"
- Finish that step, close the conversation, and open a new one for step 2
Each chat stays focused and relatively short. You never lose much when the context resets. And when something goes wrong, it's much easier to pinpoint which step caused the problem.
Context limits are an unavoidable constraint in any AI IDE, but with the right habits they become a minor inconvenience rather than a blocker. Start with one small change: next time you reference a file, add a sentence specifying exactly which function or section you need help with. The difference in how long your sessions stay useful is noticeable.