The 2-Million-Token Context Window Is Not What You Think
- Contributor
- 4 days ago
- 9 min read
When Gemini 3.1 Ultra shipped with a 2-million-token context window, the marketing copy wrote itself: "fit an entire library into a single prompt," "process whole books at once," "no more chunking, no more retrieval, just put it all in context." The numbers are impressive. The implications are real for specific use cases. The marketing is also misleading about what long context actually does — and doesn't do.
The 2M context window is genuinely available. You can send Gemini 3.1 Ultra two million tokens of input and get a response. What you can't assume is that the model attends to those two million tokens with equal weight. What you can't assume is that this is better than RAG for your use case. What you can't assume is that you should stop chunking and start stuffing.
This post is about what long context actually does behaviorally, where it wins versus retrieval, and how to use it without falling for the marketing.
The Capability Is Real
Let's start with what the 2M context window genuinely provides.
Computationally, the model can process 2M tokens of input. The architecture supports it. The infrastructure routes it. You will not get a rejection for sending a 1.5M-token prompt. This is a meaningful capability — most other frontier models cap at 200K-1M, so Gemini 3.1's window is multiples larger than the alternatives.
Behaviorally, the model does pull information from the long context. If you put a 1.8M-token document into the prompt and ask a specific factual question, the model will often find the right answer in the document. The needle-in-a-haystack tests that providers run to advertise long-context capability are real — the model can locate specific facts in long contexts.
For specific use cases, this is qualitatively different from anything possible with shorter contexts:
Whole-book analysis. Drop a 200K-token book into context, ask thematic questions, get analysis informed by the whole text rather than retrieved chunks.
Multi-document synthesis. Put 50 related documents in context, ask for cross-document patterns, get analysis that wouldn't be possible with retrieval that processes documents independently.
Long-form code review. Put an entire medium-sized codebase in context, ask architectural questions, get answers that account for cross-file dependencies.
Extended conversation memory. Maintain years of conversation history in context for an assistant that "remembers" prior interactions in a way short-context assistants can't.
For these workloads, long context unlocks something new. The capability is meaningful when the use case fits.
The Capability Is Uneven
The honest version of long-context capability includes the part the marketing skips.
Attention degrades across long contexts. The model attends more reliably to information at the start and end of the context window than to information in the middle. This is the "lost in the middle" effect, documented in research since 2023, persistent across providers and architectures despite ongoing work to address it.
What this means in practice:
A specific fact at position 100,000 in a 2M context is typically more reliably retrieved than the same fact at position 1,000,000.
A specific fact at position 1,900,000 (near the end) is often more reliably retrieved than the same fact at position 1,000,000 (middle).
The retrieval reliability for facts in the middle of long contexts can be substantially lower than for facts at the extremes.
The needle-in-a-haystack tests that providers publish often demonstrate that the model can find facts at various positions in long contexts. They don't always demonstrate that the model finds them as reliably as it would in a shorter context. The distribution of retrieval reliability across position is the part that gets glossed over.
Other long-context behaviors that don't match the marketing:
Reasoning quality may decrease. Tasks that require chaining information from multiple positions in long context sometimes show degraded reasoning compared to shorter context versions of the same task.
Latency increases substantially. A 2M-token call doesn't run at the same latency as a 10K-token call. The user-facing wait time can be significant — tens of seconds for the full input processing.
Cost increases proportionally. Long context isn't free. A 2M-token call is hundreds of times more expensive than a 10K-token call.
These caveats don't make long context useless. They make it a specific tool for specific jobs, rather than a universal replacement for retrieval.
When Long Context Beats RAG
There are workloads where long context genuinely produces better results than RAG. They share a common property: the task benefits from the model seeing the full corpus simultaneously, in a way that chunking would lose.
Cross-document synthesis where retrieval might miss critical pieces. A legal question that requires understanding how a contract clause interacts with five other clauses scattered across a 50-document corpus is hard to answer well with retrieval. The retrieval step would need to identify all five clauses to bring them into context, and if it misses one, the answer is wrong. Long context lets the model see all of them simultaneously.
Long-form structure preservation. Some documents have structure that matters for understanding — a long narrative with character arcs, a technical specification with cross-references, a legal contract with definitions used throughout. Chunking can break these structural relationships. Long context preserves them.
Ad-hoc analysis where retrieval criteria aren't clear. When the user's question doesn't obviously map to a retrieval query, retrieval is harder to do well. "What's the most surprising thing in these documents?" is hard to retrieve for. Long context lets the model survey the full content and find what's interesting.
Code understanding across many files. Large code questions often require understanding patterns that span many files. A retrieval-based approach risks missing the right file. Long context lets the model see all the relevant code and reason across it.
Tasks where the corpus is small enough that "the whole thing" fits. If your knowledge base is 100K tokens, you can fit all of it in context with room to spare. The retrieval step doesn't add value because there's no retrieval to do — everything is already in scope.
For these workloads, long context is the right tool. Try it.
When RAG Still Wins
For most production workloads, focused RAG continues to outperform long-context stuffing. The reasons are practical.
Quality. Focused retrieval of the most relevant chunks usually produces higher-quality answers than stuffing the entire corpus. The model attends to less information, but with higher signal density. Less noise in the context produces better outputs.
Cost. RAG with 50K tokens of focused context is dramatically cheaper than long-context stuffing with 2M tokens. For high-volume applications, the cost difference is the difference between a viable economic model and an unviable one.
Latency. Short contexts process faster. User-facing applications usually have latency budgets that long contexts violate.
Updateability. RAG operates over a corpus that can be updated incrementally — new documents are added to the index, the retrieval picks them up automatically. Long-context approaches that stuff the full corpus every time need to manage corpus changes manually.
Citation and grounding. Focused retrieval makes citation natural — the model used these specific documents, you can show them to the user. Long context makes citation harder — the model used something in the 2M token blob, but the specific source is opaque without additional work.
Failure modes. When RAG fails, it usually fails by retrieving the wrong documents — a recognizable failure mode that can be debugged and improved. When long context fails, it often fails silently — the model attends to the wrong part of the context and produces a confidently wrong answer.
For most production workloads — customer support, content generation, code completion, classification, extraction — RAG with focused retrieval beats long-context stuffing. The cost-quality tradeoff favors retrieval. Long context is the right choice for specific workloads, not the new default.
The Hybrid Pattern
The pattern that often produces the best results combines retrieval and long context. Use retrieval to identify the relevant subset of the corpus. Send that subset (which might still be hundreds of thousands of tokens) to the model. Get the benefits of focused retrieval plus the benefits of having a substantial amount of relevant context.
The hybrid pattern looks like:
Retrieval narrows the scope. Identify the top 100-500 relevant chunks from the full corpus.
Long context handles the relevant subset. Send the retrieved chunks — which might total 100K-500K tokens — to the model in a single call.
Cross-chunk reasoning happens at inference time. The model can attend across all retrieved chunks simultaneously, finding patterns and cross-references that single-chunk processing would miss.
This pattern gets the cost benefits of retrieval (you're not processing the full corpus) and the cross-chunk benefits of long context (you have enough context for cross-document reasoning). It's where many production systems land after experimenting with both pure RAG and pure long-context approaches.
Caching Changes the Economics
One operational consideration that significantly affects long-context economics: prompt caching.
All major providers now offer caching of stable prompt prefixes at significant discounts (50-90% off the cached portion). When a long context is stable across many queries — a fixed knowledge base, a persistent system prompt — caching makes the long-context economics much more viable.
A 1M-token system prompt cached at 90% discount costs roughly 100K full-price tokens per query plus whatever the user-specific input adds. For applications with many queries against a stable long context, this can be cheaper than running RAG over the same corpus, because RAG has its own infrastructure costs.
Caching makes long context economic for specific patterns:
Stable knowledge bases. Internal documentation, product manuals, policy documents — corpora that change slowly and are queried many times.
Long system prompts with templated user input. A long system prompt setting up the model's role plus short user-specific queries.
Multi-turn conversations with stable history. The conversation history is stable until the next user message; only the new message is uncached.
For other patterns (dynamic content, per-query unique contexts), caching doesn't help and the standard long-context economics apply.
How to Test Long Context for Your Use Case
If you're considering long context for a specific workload, the evaluation discipline matters.
Test on your actual data. Vendor benchmarks don't predict performance on your specific content. Build an eval set of representative inputs and expected outputs from your domain.
Test position sensitivity. Place key information at various positions in the long context (start, middle, end, scattered). Measure how reliably the model retrieves and uses each. If middle-position information is unreliable, your use case might not work well even though it "fits in context."
Test cost-equivalent RAG. Build a RAG version of the same workload that costs roughly the same as the long-context version. Compare the outputs. If RAG is competitive (which it often is), the long-context approach isn't earning the cost premium.
Test latency under realistic conditions. Long-context calls take time. Make sure the latency works for your application before committing to the architecture.
Test failure modes. When the long-context approach gives wrong answers, why? Is it position-related? Is it model confusion across long context? Is it the model finding the wrong information in the noise? Understanding the failure modes tells you whether they're tolerable in production.
This testing takes real time. It's worth doing before architecting around long context.
The Takeaway
The 2-million-token context window is a real, useful capability for the right use cases. It is not a universal replacement for RAG. It is not free. It is not equally usable across the full context length.
For most production workloads, focused retrieval with shorter contexts continues to produce higher-quality, lower-cost results than stuffing long contexts. Long context wins for specific workloads: cross-document synthesis, long-form structural reasoning, ad-hoc analysis over moderately sized corpora, code understanding across many files. Test against your actual data and against cost-equivalent RAG before architecting around it.
The hybrid pattern — retrieval narrows scope, long context handles the relevant subset, cross-chunk reasoning at inference time — is often the best of both worlds. Caching makes long context economic for stable-prefix patterns.
Don't fall for the marketing that says retrieval is dead. Don't ignore long context where it genuinely helps. The honest answer is "different tool for different jobs," and the discipline is testing carefully enough to know which job is in front of you.
A 2M context window is impressive. It is also a tool. Use it as one.
Frequently Asked Questions
Does a 2-million-token context window actually work?
Computationally, yes — Gemini 3.1 Ultra can accept 2M tokens of input and process them. Behaviorally, with caveats. Models with very long contexts attend unevenly across the range — information at the start and end is typically attended to more reliably than information in the middle. Specific facts buried in a 2M context can be retrieved by the model, but performance varies significantly with position and task. The window is real; equally usable attention across the whole window is not.
Should I stop using RAG if I have a long context window?
No. RAG with focused retrieval typically produces higher-quality answers than stuffing the entire knowledge base into context. Long context is useful when you can't easily identify the relevant subset of documents upfront, or when the task genuinely requires cross-document reasoning that retrieval might miss. For most production workloads with clear retrieval criteria, focused RAG beats long-context stuffing on both quality and cost.
What is the 'lost in the middle' problem?
Long-context language models tend to attend more reliably to information at the beginning and end of the context than to information in the middle. A specific fact buried 1.2 million tokens into a 2-million-token context may be 'in scope' but harder for the model to retrieve and use than the same fact at position 100,000 or position 1,900,000. The pattern was first documented in 2023 and persists across providers and architectures, though some recent models have reduced its severity.
When does long context actually beat RAG?
Three scenarios. One: when you don't know which subset of documents is relevant upfront and retrieval would risk missing critical information. Two: when the task genuinely requires reasoning across the full corpus rather than answering from individual documents (cross-document synthesis, longitudinal pattern recognition). Three: when chunking would lose context that the model needs (long-form documents where structure matters, code where cross-file references are essential). Outside these cases, RAG usually wins.
Does long context cost more than RAG?
Significantly more per query, yes. A 1-million-token call costs roughly 10× a 100K-token call at typical pricing. Most production workloads can't justify this for typical queries. The economics favor RAG with shorter, focused contexts for high-volume applications, with long context reserved for the queries that genuinely need it. Caching can reduce the cost when the long context is stable across many queries (a fixed knowledge base, a stable system prompt), making long context more economic for specific patterns.


