Zenaique

You have 500KB of relevant documentation that exceeds the 200K-token context window of your production model. How should you choose between context stuffing (fit what you can) and RAG retrieval?

MCQ·Medium·4.0 · 0·~1 min·Asked atAi21ReplicateShopify·Relevant atAmazonAnthropicAppleOpenAI
Attempt it
TL;DR

500KB ~= 125K tokens. It fits a 200K window but pays full cost per call and hits lost-in-the-middle. RAG retrieves only 5K-10K relevant tokens per query, cutting cost 10x to 25x and keeping high-recall positions.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine you have a 1,200-page reference book and somebody asks you a question. You could carry the whole book to the meeting every time, but it is heavy, you only read a few pages, and you tend to forget what was on the pages in the middle. RAG is the librarian who hands you only the three pages relevant to the question. Context stuffing is dragging the whole book. The book strategy works if it is a thin pamphlet you read every time, but for a real reference, the librarian wins on weight, on cost, and on actually remembering what you read.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

The 'long context killed RAG' narrative was big in 2024 and has not aged well. Modern frontier models do have 200K to 1M token windows, but the cost, latency, and recall properties of long contexts make stuffing a poor default for anything beyond a small, stable corpus. The 500KB scenario in this question is exactly the shape where the wrong choice looks superficially correct and is structurally wrong.

The deep dive walks through the three quantities that drive the decision (cost, recall, latency), the lost-in-the-middle effect that long-context evals have measured repeatedly, the production RAG pattern that wins on each axis, and the narrow cases where stuffing actually is the right call.

The token math and what it costs

The starting calculation is mechanical. English text averages roughly 4 characters per token on the byte-pair encodings used by Claude and GPT, so 500KB of plain text is around 125K tokens. The number varies with language and content (code is denser, structured JSON is sparser) but 100K to 150K is the right ballpark.

Frontier-model input pricing in 2026 is around $5 per million tokens for Claude Opus 4.7, $1.25 to $2.50 for GPT-5.5, $3 for Claude Sonnet 4.x, $1.25 for Gemini 3.1 Flash. At $5 per million (Opus 4.7), a 125K-token prefix costs $0.63 per call before the model writes a single output token. A small-business app at 10K calls per day is paying $18,800 per day, $5.6M per year, just for the input prefix.

RAG retrieving 5 to 10K tokens per query collapses that to $0.075 to $0.15 per call: a 10x to 25x reduction. At the same 10K calls per day, you are looking at $750 to $1,500 per day. The cost gap is what funds the retrieval infrastructure, the embedding compute, the vector store, and the cross-encoder re-ranker several times over. Prompt caching helps stuffing but does not close the gap unless the cache hit rate is very high and the prefix is genuinely identical across calls.

Lost-in-the-middle and what it means
Latency and the user experience
The production RAG pattern that wins
The narrow case where stuffing wins
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • Anthropic's prompt-engineering docs explicitly recommend RAG over stuffing for Claude Opus 4.7 once the corpus exceeds a small fraction of the 200K window, citing both cost and recall on the middle of the context.
  • Perplexity routes every search through dense plus BM25 retrieval before invoking Claude or GPT-5.5, because stuffing the web index is structurally impossible and even a daily slice would dilute attention.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QWhen does prompt caching change the math in favor of stuffing?
A

When the static prefix has 80%+ cache hit rate, the per-call cost of stuffed context drops by roughly an order of magnitude; on small stable corpora this can flip the decision, but not at 500KB.

3 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Treating a 200K window as license to stuff the whole corpus, paying for 125K tokens per call, and shipping a system that quietly misses facts buried in the middle of the prompt.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • How to estimate token count from byte size (~4 chars per token)

  • Cost formula: tokens times per million input tokens price

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Which metric best measures whether a RAG answer is grounded in the retrieved context?
MCQ·Medium