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?
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.
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.
Detailed answer & concept explanation~6 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: token math on 500KB + cost per call + lost-in-the-middle + prefill latency + when stuffing actually wins + production RAG pattern.
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.
- Cursor's repo-aware features retrieve a handful of relevant files at request time rather than stuffing the entire codebase into Claude Opus 4.7, which is how the per-edit latency stays interactive.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhen does prompt caching change the math in favor of stuffing?
QWhat does a credible RAG eval look like for this kind of system?
QHow do you handle the case where the relevant content spans many chunks?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
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.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.