Skip to content

Long Context vs Retrieval: The Break-Even Decision

Feeding a whole corpus into a million-token window buys answer completeness; one measured head-to-head put the cost at sixteen times retrieval.

Replacing a retrieval pipeline with a large context window works on one shape of problem: a corpus that fits well inside the model's usable window, queried tens of times rather than thousands, where an incomplete answer costs more than a slow one. Outside that shape the arithmetic reverses on query volume rather than on token price.

The four gates

Work through them in order; the first failure decides the architecture.

Does the corpus fit the usable window?

The advertised window is not the working window. NoLiMa evaluated 13 models claiming 128K tokens or more and found that at 32K, 11 of them "drop below 50% of their strong short-length baselines", with GPT-4o falling "from an almost-perfect baseline of 99.3% to 69.7%" (arXiv:2502.05167v3). The degradation is silent, so a corpus that fits on paper can answer worse than retrieval.

How often will you query it?

Long context re-pays the whole corpus as input on every query. A published head-to-head over a 127,068-token corpus and 12 questions cost $3.82 through the window against $0.23 through retrieval, "sixteen times as much", and the same author projects "roughly $3,800 against $230" at 12,000 questions (Towards Data Science). Nothing amortizes across queries, so the ratio holds at every volume.

Is the latency budget interactive?

The long-context path averaged 111 seconds per question, and its hardest question took 273.7 seconds. Chat, editor, and CI-gate uses fail this gate whatever the cost comparison says.

Is the output cap sized for thinking tokens?

On a reasoning model, thinking is drawn from the same allowance as the visible answer: "Thinking tokens count toward the max_tokens limit for the turn, so the budget must leave room for the final response" (Claude docs). A cap set before you turned thinking on now truncates the answer to nothing.

What the head-to-head measured

Dimension Long context Retrieval
Cost over 12 questions $3.82 $0.23
Average latency 111 s per question Faster on single-fact questions
Hardest corpus-wide question 273.7 s 46.3 s
Correctness score (0–2) 2.00 1.92
Completeness score (0–2) 2.00 0.83

The corpus was 32 files of 127,068 tokens. The retrieval arm sent "the five most similar chunks" of "788 chunks of 900 characters with 150 characters of overlap", embedded with all-MiniLM-L6-v2 (Towards Data Science).

Why it works

The completeness gap has a structural cause. Ranked retrieval with a fixed k bounds the evidence the model can see, and the ranker emits no signal that k was too small, the failure covered under exhaustive retrieval for listing questions. The measured scores show that shape: what retrieval found was right, and there was not enough of it. Handing the model the whole corpus removes the bound.

The cost gap is the same fact read the other way: per-query input is corpus-sized for long context and k-chunk-sized for retrieval, so the price ratio tracks the corpus-to-selection ratio.

Prefix caching does not rescue that arithmetic. The cache "kicked in on three out of eight calls", and a cached call cost $0.0466 against $0.3916 uncached. Anthropic's cache has "a 5-minute lifetime" by default (prompt caching docs), so a pause or a corpus edit puts you back on the uncached price.

When this backfires

  • Order-preserving retrieval reverses the quality verdict. OP-RAG reaches 47.25 F1 on the ∞Bench En.QA benchmark using 48K retrieved tokens, where Llama3.1-70B reading all 117K tokens reaches 34.26 (arXiv:2409.01666v1). The measured sixteenfold premium is priced against a plain top-five chunk baseline, so the real comparison for most teams is long context today against a day of retrieval work and a sixteenth of the bill afterwards.
  • The chunking strategy may be what lost, rather than retrieval itself. An evaluation of both approaches found that "summarization-based retrieval performs comparably to LC, while chunk-based retrieval lags behind" (arXiv:2501.01880v1).
  • More context can lower quality outright. OP-RAG attributes the inverted-U curve to distraction: "as more chunks are retrieved, the likelihood of introducing irrelevant or distracting information also increases. This excess information can confuse the model" (arXiv:2409.01666v1).
  • Query volume flips the decision with no change to the model or the corpus, and both corpus size and query count grow after launch.
  • A corpus that changes between queries never warms the cache, so every request pays the uncached price.

Example

The reasoning-token failure is a configuration bug, and it surfaces as silence instead of an error.

Before — cap sized before thinking was enabled:

max_completion_tokens=800

At that setting, "twelve out of 24 answers ... were completely empty, plus three more that broke off mid-word", because thinking consumed the allowance before any visible text was generated (Towards Data Science).

After — cap covers the reasoning spend and the answer:

# raise the cap to cover the reasoning spend on top of the answer
max_completion_tokens=REASONING_BUDGET + ANSWER_BUDGET

Size the new value from measurement rather than a guess. Claude's API reports the split in usage.output_tokens_details.thinking_tokens, "which reports how many of the billed output tokens were internal reasoning" (Claude docs).

Key Takeaways

  • Gate on the model's measured usable window, not its advertised one. NoLiMa found most 128K-plus models below half their short-context baseline at 32K.
  • Query volume decides the economics. A sixteenfold per-query premium is $3.59 over 12 questions and roughly $3,570 over 12,000.
  • Compare against a retrieval arm worth beating. Order-preserving retrieval beat a full 117K-token read using 48K tokens.
  • Budget the output cap for thinking before you switch a reasoning model on, or the request returns an empty string with no error to catch.