Back to the map

Module 08 · Advanced retrieval · Lesson 4 of 6

Long context versus retrieval

A 1M-token window changed when to retrieve, not whether: stuff a small static corpus and lean on the cache; retrieve when the corpus is large, changing, access-controlled or must be cited; or retrieve a few large sections.

CoreMust-knowMid 12 minPro Updated Nov 2026

Why it matters

When frontier windows reached a million tokens, a claim followed: retrieval is dead, put the documents in the prompt. It did not happen, for reasons that are arithmetic and product constraints rather than model quality. A million tokens is about 750,000 English words, roughly 1,500 pages, which is a lot of documents and also not very many. Interviewers now ask the question in its real form: given this corpus, this traffic and this budget, do you retrieve, do you stuff, or both? The strong answer works the cost per query, names the quality effects of a full window, and knows the constraints that retrieval satisfies and a prompt cannot.

The idea

What a big window buys

A whole corpus in the prompt removes the retrieval system: no chunking, no index, no embeddings, no recall failures, no freshness pipeline. The model sees everything and can join facts across documents without anyone designing a graph. For a small corpus that rarely changes, read by one analyst for one afternoon, this is the right design, and building a retriever for it is over-engineering.

The arithmetic

Take a 200-page handbook, about 150,000 tokens, and a mid-lineup list price of $3 per million input tokens. Every question that carries the handbook costs about $0.45 in input before the answer is written. Prompt caching changes that: cache reads cost 2.5 to 10 percent of the base input price, so a cached reread of the same 150,000 tokens is roughly $0.01 to $0.045. Retrieval instead sends the question plus five chunks, perhaps 4,000 tokens, for about $0.012, plus the cost of running an index. At the top of the cache range the two are close; at the bottom the cache wins on price, as long as the prefix is identical on every call and the cache stays warm. Change one line of the handbook and the next read is full price again. Multiply by a thousand questions a day and the design decision is a line in the budget.

What the full window does to quality

Two effects are worth naming. The needle in a haystack test hides one fact in a long context and asks for it; current models pass it well, which is why the claim sounded plausible. The lost in the middle effect is subtler: when many facts compete, those near the start and the end of the context are used more reliably than those in the middle, and irrelevant material dilutes attention. Finding one needle is easy; reasoning over twenty needles scattered through 150,000 tokens of hay is where answers degrade. The Context engineering lesson covers the same effect from the prompt side.

whole corpus in the prompt150K-token handbookModelinput: 150K tokens a querycache read: 2.5 to 10% of baselatency: seconds of prefillcitations: weak; middle is lostretrieve, then readIndex5 sectionsModelinput: 4K to 20K tokens a queryindex to build and keep freshlatency: lookup, short prefillcitations: exact; filterable
Both designs reach the same model. The whole-corpus prompt pays for every token on every question unless the cache holds; the retriever pays for an index and sends a few thousand tokens.

Where retrieval still wins

Four constraints decide it. Size and change: a hundred thousand documents do not fit, and a corpus that changes hourly invalidates the cache as fast as it is built. Cost and latency per query: prefill on 150,000 tokens takes seconds before the first output token, every time, and uncached it is the dearest thing in the system. Precision and citations: a retriever returns the five passages the answer rests on, with their locations, which is what a user clicks and an evaluator checks; a full-window answer cites "the handbook". Access control: a prompt is all or nothing, so a user who may read only part of the corpus cannot be served from a shared prefix. The Permission-aware retrieval lesson builds on that point.

The hybrid

The strongest current designs do both. Retrieve, but retrieve large: a few whole sections or documents, 20,000 to 50,000 tokens, rather than fifty 500-token chunks. The model gets coherent text with its surroundings, the retriever still provides filtering, citations and access control, and the window is far from full, so the middle is not lost.

 Long contextRetrievalRetrieve, then long context
Cost per queryEvery token, every time; cache cuts it to 2.5 to 10% if the prefix holdsA few thousand tokens plus index costTens of thousands of tokens; no index-wide cache
LatencySeconds of prefillRetrieval round trip, short prefillRetrieval plus a medium prefill
FreshnessRe-send or re-cache the corpusRe-embed the changed chunkRe-embed the changed section
CitationsWeak; the whole corpusExact passagesSections, with passages inside them
Access controlAll or nothing per prefixFiltered in the indexFiltered in the index
Long context versus retrieval · Backplane