lowob

Long Context Windows vs RAG

Long context means putting whole documents directly into the model's prompt and letting it read everything. Retrieval-augmented generation (RAG) means searching a store first and giving the model only the passages that look relevant. Long context is simpler and often more accurate on a bounded set of documents. RAG is cheaper, scales to large and changing collections, and is the natural place to enforce who may see what.

Gateway 0ToolingContextRecordReasoningGateway 1Gateway 2Gateway 3
Where this piece sits in The Build Order: the context layer.

What the two approaches mean

A context window is the amount of text a model can take in one request; lowob's explainer on context engineering covers how teams decide what goes into it. With long context, the application loads the source material straight in: a full contract, a year of account emails, a product manual. The model reads all of it for each question.

RAG adds a retrieval step. Documents are split into passages, indexed, usually as embeddings in a vector store, and searched at question time. The model sees only the top results. Quality then depends on two things: whether retrieval found the right passages, and whether the model used them.

Long contextRAG
What the model seesEverything loaded, every timeThe passages retrieval selects
Setup effortLow: load and askHigher: chunking, indexing, search tuning
Cost per questionHigh, scales with document sizeLow, scales with passages returned
Corpus sizeBounded by the windowEffectively unbounded
Fresh contentReload each timeRe-index changed documents
Typical failureMisses facts buried in the middleRetrieves the wrong passage, or none
PermissionsAll-or-nothing per requestCan filter by user before the model sees anything
TraceabilityHard to say which part was usedEach answer can cite retrieved passages

What the research says

The best direct comparison is Li and colleagues' Retrieval Augmented Generation or Long-Context LLMs?, accepted to the EMNLP 2024 industry track. Their finding has two halves. With enough resources, long-context models outperformed RAG on average. RAG's much lower cost remained its distinct advantage. Their hybrid, Self-Route, lets the model decide per query whether retrieved passages are enough, and falls back to long context only when they are not.

Advertised window size overstates usable size. RULER, a 2024 benchmark, found that almost all 17 models tested scored near-perfectly on the basic needle-in-a-haystack test. Yet almost all showed large drops on harder tasks as inputs grew, and only half stayed satisfactory at 32,000 tokens. Liu and colleagues' Lost in the Middle showed the position effect: performance was highest when the relevant fact sat at the start or end of the input. Both studies tested 2023 and 2024 models, so the lesson is to measure current models on your own documents rather than trust a headline window.

Cost has moved too. Anthropic's documentation prices a five-minute cache write at 1.25 times the base input rate and a cache read at 0.1 times or less. For a document asked about repeatedly in a short period, such as one contract under negotiation, caching makes long context much cheaper than the list price suggests. It does not help a question that spans thousands of documents.

Which to choose

SituationBetter fitWhy
One contract, RFP or call transcript, many questionsLong context, with cachingBounded, and the whole document matters
Comparing a few long documents side by sideLong contextCross-references are lost when text is chunked
Thousands of help articles, policies or past proposalsRAGToo large for any window, and changes often
Users with different access rightsRAG with permission filtersLong context cannot hide part of a prompt from the reader
Answers that must cite a sourceRAGRetrieved passages give a natural citation
Mixed workload, uncertain which appliesRoute per queryThe Self-Route pattern: try retrieval, fall back to long context

The lowob view

lowob's view is that retrieval is rarely the bottleneck, an argument made at length in Retrieval is not the bottleneck. In the brain loop, long context and RAG are both choices about the wiring: how material in the store reaches the reasoning step. Neither fixes a store that holds the wrong material, and neither replaces the record.

Two rules follow. First, permissions belong in the wiring, before the model. If a sales rep should not see a client's credit file, it must not enter the prompt. A long window makes that easier to get wrong. Second, the most valuable context is often a past decision with its reason: why a discount was approved, or why a deal was lost. That lives in the record and comes back through retrieval. A bigger window does not supply reasons nobody wrote down.

lowob takeaways

  • Long context suits bounded documents. One contract or transcript, read whole, often with caching.
  • RAG suits large, changing, permissioned collections. It is cheaper and can cite its sources.
  • Measure the usable window. Benchmarks show performance falls well before the advertised limit.
  • Neither fixes the record. Reasons for past decisions have to be written down before any model can use them.

Common questions

Do long context windows make RAG obsolete?

No. Research finds long context can score higher on bounded tasks, but RAG costs far less, scales to large collections and allows permission filtering. Many teams use both.

When should I use long context instead of RAG?

When the material is a handful of documents that fit comfortably in the window, the whole text matters, and the same users may see all of it.

Is long context more accurate than RAG?

Often, on average, when well resourced, according to a 2024 EMNLP study. Accuracy still drops with length and when key facts sit in the middle of the input.

Sources and notes

What Is an AI Agent, and Where Does It Fit in the Brain?

Read next in The Build Order