Learn/Generative AI, RAG & Agents/MODULE 4: THE 2026 UPDATE AND PUTTING IT TO WORK
Lesson 32 of 37 · 3 min read

4.2 Agentic Search, RAG or Long Context? A Decision Rule

In Module 2, RAG looked like the answer to "how do I give a model my documents?"

RAG is still a standard technique, but it is no longer the only option, and for some jobs it is no longer the simplest.

There are three approaches to compare.

The Three Approaches

Long context. You put the documents straight into the prompt.

This works when everything fits in the context window.

Context windows have grown: Anthropic lists 1 million tokens for its Claude 5.5 models, and Google lists 1 million for its Gemini 4 models.

For Claude, Anthropic estimates that 1 million tokens is roughly 555,000 words.

Prompt caching makes repeat use cheaper: with Claude, a cache read costs a fraction of the normal input price, and the default cache lifetime is 5 minutes, refreshed each time the cached text is used.

RAG. You index the documents ahead of time, retrieve the few most relevant chunks for each question, and give only those to the model (Module 2).

Agentic search. You give the model search tools (keyword search, file reading, database queries, a vector search) and let it decide what to look up, read the results, and look again until it has enough.

It is the agent loop from Module 3 applied to finding information.

Trade-offs at a Glance

Long contextRAGAgentic search
Setup effortLowestHighest (chunking, embeddings, index)Medium (tools and guardrails)
Cost and speed per questionHigh per question unless cachedLow and predictableVariable: several model calls per question
Handles huge or fast-changing collectionsNoYesYes
Good at exact terms, codes, namesYes, if it fitsWeaker with semantic search alone; add keyword (hybrid) search, lesson 2.7Strong, with keyword tools
Multi-step questionsOnly if all sources fitWeak in a single passStrong
CitationsPossible, you must askNatural (you know the chunks)Possible, from what it read
Main riskCost, and details lost in a very long promptWrong chunks retrievedWandering, slow, runaway cost

This table is a rule of thumb from how the approaches work, not a benchmark.

A Decision Rule

Work down these questions in order and stop at the first "yes".

  1. Does all of it fit comfortably in the context window, and does it change rarely? Use long context, and turn on caching if the same documents are used repeatedly. This is the simplest thing that can work, so start here.

  2. Is the collection too big or too fast-changing, and are most questions simple lookups that need a specific passage and a citation? Use RAG.

  3. Are the questions multi-step or exploratory, or do they depend on exact terms, structure, or live systems (code, logs, tickets, a database)? Use agentic search, with step limits and logging (lesson 3.8).

  4. Do you have both kinds of question? Make RAG one of the tools the agent can call. Many real systems end up here.

Then Test It

Whichever you pick, write 15 to 20 real questions from your own users, with the answers you would accept, before you commit.

Run them through the simplest option first, and move to a more complex one only when the failures justify it.

Measure three things: how often the answer is right, how long it takes, and what each question costs.

If you cannot say which of the three you are optimizing, you are not ready to choose.

Keep going with a free account

A free account saves your progress across lessons and lets you pick up where you left off.