Skip to content

AI at Work 12 min read

Long Context vs RAG: When a Big Context Window Replaces Retrieval

When a large context window can replace retrieval and when it can't: cost, latency, lost in the middle, permissions and freshness, plus a decision table and a hybrid pattern.

By , Founder & CEO, Acta · Updated

Cover: long context vs RAG, when a big context window replaces retrieval

Long context vs RAG comes down to how much material you have and how often it changes. If everything the model needs fits comfortably in its context window, changes rarely and is read as a whole, paste it in and skip retrieval. If the corpus is large, changes often, needs per-user permissions or must cite exact sources cheaply, keep RAG. Most production systems end up using both.

This guide settles the decision for engineers and the people who sign off on their budgets. It covers cost and latency, the "lost in the middle" effect, permissions, freshness, and a hybrid pattern that routes between the two. It won't tell you which vendor's window is biggest this month; model limits change too often for that to be useful.

Key takeaways

  • Use long context when the whole source fits with room to spare, is read end to end, and the same few users may see all of it.
  • Use RAG when the corpus is bigger than any window, changes daily, needs per-user access control, or each query should cost and take roughly the same no matter how big the corpus gets.
  • A large window isn't a reliable reader: research found models use information at the start and end of the input better than information in the middle.
  • The best default for most teams is hybrid: retrieve first, and only send the full document when retrieval can't answer.
  • Decide with an evaluation set of 30-50 real questions, not with a vendor's needle-in-a-haystack chart.

Table of contents

Long context vs RAG: corpus size, change rate, permissions and query volume decide which approach fits, with hybrid routing in between

Long context and RAG solve the same problem in different places

Both approaches answer the same question: how does the model see information it wasn't trained on? Long context puts the information straight into the prompt. You send the 80-page contract, the full codebase summary or all twelve transcripts from a project, and ask your question at the end. The model does the finding and the reasoning in one pass.

Retrieval-augmented generation (RAG) splits that work. A search step (embeddings, keyword search, or both, often followed by a reranker) picks the handful of passages most likely to matter, and only those go into the prompt. The model reasons over a few thousand tokens instead of a few hundred thousand. If you want the full build, our guide to RAG over meeting transcripts and documents walks through each layer.

So the question "is RAG dead?" comes up every time a vendor ships a bigger window. Google's long-context docs, for example, note that many Gemini models now have windows of 1 million tokens or more. That changes where the line sits. It doesn't remove the line, for the reasons below.

Long context wins when the material is small, stable and read whole

Some tasks need the model to see everything at once. Summarising a whole board pack, checking a contract for clauses that contradict each other, comparing two versions of a spec, or reviewing a 300-line pull request in full: a retriever that returns five chunks will miss connections that only appear when the model reads the whole thing. Retrieval is good at "find the passage that answers X". It's weak at "what's missing" or "what changed across all of this".

Long context also wins on simplicity. No chunking strategy, no embedding model, no vector store, no reranker, no index to keep in sync. For a prototype or an internal tool used by five people over one document set, that's a lot of moving parts you never build.

Research backs this up when cost isn't a constraint. A 2024 study by Li et al. (EMNLP 2024), Retrieval Augmented Generation or Long-Context LLMs?, found that when resourced sufficiently, long-context prompting consistently beat RAG on average across their benchmarks. "When resourced sufficiently" is doing a lot of work in that sentence, though.

Use long context when all of these hold: the material fits with plenty of headroom, it's the same material across many questions, the people asking may see all of it, and the task needs the whole picture.

Cost and latency grow with every token you send

The economics are simple arithmetic. With long context you pay for, and wait on, every input token on every request. With RAG you pay for a roughly fixed slice per request, plus the one-off cost of indexing.

A rough illustration (labelled arithmetic, not a benchmark): say a document set is 200,000 tokens and a RAG prompt carries 4,000 tokens of retrieved context. The long-context request sends 50 times as many input tokens as the RAG request. Ask 1,000 questions a day and that ratio holds for every one of them. Time to first token also grows with input length, so users wait longer before anything appears.

Prompt caching narrows the gap when the same document is reused. If the 200,000-token set is the identical prefix of every request, providers can serve most of it from cache at a reduced rate; our comparison of prompt caching on OpenAI, Anthropic and Gemini covers how. But caching only helps when the prefix is identical. Per-user document sets, a corpus that changes hourly, or questions spread across many different documents won't cache well.

Verdict on cost: long context is fine for low-volume, high-value questions over one stable document. For a product feature used thousands of times a day across a growing corpus, RAG's flat per-query cost wins.

A bigger window is not a better reader

The headline context window is the most the model accepts, not the most it uses well. Two research results are worth knowing.

First, Lost in the Middle (Liu et al., published in TACL in 2024) tested models on multi-document question answering and key-value retrieval. Performance was highest when the relevant information sat at the beginning or end of the input and dropped when it sat in the middle, giving a U-shaped curve. That held for models with extended windows too.

Second, NVIDIA's RULER benchmark argued that the popular needle-in-a-haystack test measures only shallow retrieval. With harder tasks such as multi-hop tracing and aggregation, the original paper found that of the models it tested that claimed 32K tokens or more, only four kept satisfactory performance at 32K. The effective context length was well below the advertised one for most models. Newer models have moved those numbers, but the lesson holds: test at the length you'll actually use.

Vendors give matching advice. Anthropic's prompting guidance recommends putting long documents (20K+ tokens) near the top of the prompt and the query at the end, and says that query placement improved response quality by up to 30% in its tests. Google's long-context guide also says performance is usually better with the question at the end. If you do use long context, follow that order, wrap each document in clear tags with its title and date, and ask the model to quote the passages it relies on before answering.

Permissions and freshness are where long context breaks

These two get skipped in most "is RAG dead" threads, and they're often what decides it in a company.

Permissions. If you paste a whole folder into the prompt, the model can quote any of it to whoever is asking. With RAG, you can filter at retrieval time so a user only ever gets chunks from documents they're allowed to open. That filter is the control point. Long context has no equivalent unless you build a per-user document set for every request, which is a retrieval system by another name. Our guide to permission-aware RAG shows how to enforce this, and securing RAG covers what goes wrong when you don't.

Freshness. A RAG index updates when a document changes; the next query sees the new version. A long-context setup that preloads a big cached document set has to rebuild that prefix whenever anything in it changes, which throws away the cache and costs the full input price again. For a wiki edited all day, or meeting notes that arrive after every call, retrieval is the natural fit.

Citations. RAG knows which chunk each answer came from because it chose the chunks. With long context you depend on the model to cite accurately from a huge input. You can ask it to quote, and you should, but checking a quote against 200,000 tokens is harder than checking it against five passages.

Long context vs RAG decision table

Use this as a first pass. When answers point both ways, go hybrid.

SituationPickWhy
One document under a quarter of the window, many questionsLong context + cachingWhole-document reasoning, cached prefix
Thousands of documents, growingRAGCorpus exceeds any window
Different users may see different documentsRAG with filtersAccess control at retrieval time
Content changes dailyRAGIndex updates; no cache rebuild
"What's missing" or cross-document comparisonLong contextNeeds the full picture
High query volume, tight latency targetRAGSmall, flat prompt size
Prototype for a handful of peopleLong contextNothing to build or maintain

Read the table as a rag vs large context window cheat sheet, not a law. A legal team reviewing one merger agreement should paste it in. The same team searching five years of matter files needs retrieval.

Hybrid routing: retrieve first, fall back to the full text

The Li et al. study above didn't stop at "long context wins". It proposed Self-Route: send the query with retrieved chunks first and let the model say whether it can answer from them; only if it can't, send the full context. In their tests most queries were answered at the cheap first step (82% for Gemini-1.5-Pro), and the authors report cost cuts of 65% for Gemini-1.5-Pro and 39% for GPT-4o while staying close to long-context quality. That's their benchmark, not yours, but the pattern travels well.

Animated flow: a question goes to retrieval first; if the model says the chunks are not enough, it falls back to the full document

Build it in five steps:

  1. Retrieve as usual. Top 5-10 chunks after reranking; a reranker makes this step far more reliable.
  2. Ask with an escape hatch. Instruct the model to answer only from the chunks, or reply with a fixed token if they're insufficient.
  3. Route on the token. If you get the token, load the full source document (only documents this user may open) and ask again.
  4. Put the question last. In the fallback call, documents first, query at the end, as both Anthropic and Google advise.
  5. Log the route. Track the share of queries that fall back. A rising share usually means chunking or retrieval needs work.

A prompt you can copy for step 2:

Answer the question using only the passages below. Quote the passage you rely on. If the passages do not contain enough information to answer, reply with exactly NEED_FULL_CONTEXT and nothing else.

[passages with document title, date and ID]

Question: [user question]

This hybrid keeps the permission filter (fallback only loads allowed documents), keeps cost flat for most queries, and still lets the model read the whole thing when a question needs it.

Test both on your own questions before choosing

Vendor charts measure vendor tasks. Build a small evaluation set instead: 30-50 real questions with known answers and the source passage for each. Include easy lookups, questions whose answer sits in the middle of a long document, multi-document questions and a few that have no answer at all. Run each question through long context, RAG and the hybrid. Score correctness, whether the citation is right, latency and input tokens. Our guide to evaluating a RAG system has a scoring rubric you can adapt.

Mistakes I see often: testing long context only with needle questions placed near the start, comparing a tuned RAG pipeline with a sloppy long-context prompt (or the other way round), ignoring "no answer" questions where long context tends to improvise, and forgetting to measure effective context length at the size you'll actually run. Chunking matters as much as model choice for RAG; for transcripts, see chunking by speaker turns and timestamps.

Meeting notes are a good example of where retrieval earns its keep: they keep arriving, each person should see only their own and shared meetings, and answers need to point to the moment something was said. Acta's OneChat answers questions across your meetings and shows where each answer was found. Capture works through the Chrome extension or desktop app without a bot in the call.

Frequently asked questions

Is RAG dead now that context windows are so large?

No. Large context windows replace RAG for small, stable document sets that one group of users can see in full. RAG still wins when the corpus is larger than any window, changes often, needs per-user permissions, or must keep per-query cost and latency flat. In long context vs RAG decisions, most production systems combine the two rather than pick one.

What is lost in the middle?

"Lost in the middle" is a finding from Liu et al. (TACL 2024): language models answered best when the relevant information was at the start or end of a long input and noticeably worse when it was in the middle. It means a model accepting a long input doesn't guarantee it uses all of it equally well.

What is effective context length?

Effective context length is the input size at which a model still performs well on a task, as opposed to the maximum it accepts. NVIDIA's RULER benchmark found it was often well below the advertised window for the models it tested. Measure it for your own task by placing answers at different depths in realistic documents.

Is long context cheaper than RAG with prompt caching?

Sometimes. If many questions hit the same identical document prefix within the cache lifetime, caching cuts the cost of resending it. If documents differ per user, change often, or questions are spread across a large corpus, caching rarely applies and RAG's small prompts stay cheaper per query.

What is Self-Route?

Self-Route is a hybrid method from Li et al. (EMNLP 2024). The model first tries to answer from retrieved chunks and says when they're insufficient; only then does the system send the full long context. The authors report most queries resolved at the cheaper retrieval step, with quality close to full long-context prompting.

Choose between long context and RAG

Run your use case through these checks before you build.

  • Size the corpus: if it fits in under a quarter of the window today and won't grow much, long context is a fair starting point.
  • Map who sees what: any per-user access rule points to RAG with retrieval-time filters.
  • Check the change rate: daily updates favour an index over a rebuilt, cached prompt.
  • Estimate volume: multiply input tokens by daily queries for both designs before you pick.
  • Evaluate on real questions: 30-50 questions, including middle-of-document and no-answer cases, across long context, RAG and hybrid.

If your corpus is your team's calls, Acta's desktop app captures Zoom, Teams and other calls without a bot and turns them into searchable notes.

Found this useful? Share it with your team.

Record your next meeting without a bot

Acta writes the transcript with speaker names, the summary and the action items for you. No notetaker joins the call. Free for 15 days.

Acta desktop app for Windows and Mac

Records Zoom, Microsoft Teams or any calling app from your own computer. It opens by itself when a Zoom or Teams meeting starts, and your screen is never recorded.

Download the desktop app

Acta Chrome extension

One click from the meeting tab in Google Meet, or Zoom and Teams in Chrome. Nothing else to install, so it works on a work laptop where you can't add apps.