RAG Mechanics: Classical Retrieval vs. Agentic Search
CoreApply context curation techniques: pruning, compaction, isolation, and retrieval · Difficulty 3/5
Explanation
Retrieval Is the Mechanism Behind Just-in-Time Retrieval
The just-in-time retrieval technique in the previous concept assumes some mechanism for finding the right slice of material to pull in. Retrieval-augmented generation (RAG) is the general pattern that does this: rather than loading an entire knowledge base into context, the system stores material outside the context window, finds the parts relevant to the current request, and supplies only that slice to the model. There are two fundamentally different ways to implement that mechanism, and the exam expects you to distinguish them by more than name.
Classical RAG: Index Now, Search Later
Classical RAG does its hard work upfront, before any question is asked:
- Chunk the source documents into smaller pieces.
- Embed each chunk -- convert it into a vector of numbers that captures its meaning mathematically.
- Store those vectors in a searchable vector index.
- At query time, embed the incoming question the same way, then run a similarity search against the index to retrieve the chunks whose embeddings are closest to the question's embedding.
This is the librarian-with-pre-written-summary-cards model: all the expensive work (reading everything, writing the cards) happens before the library opens, so that when a question arrives, the matching cards are already sitting there ready to hand over.
Where Classical RAG Concretely Fails
Classical RAG breaks down in three specific, nameable places -- these are the exam's favorite trap surface for this concept, because each failure sounds like a minor implementation detail but actually determines whether retrieval works at all:
(a) Chunking. Chunk size is a real design decision with a real failure mode on both ends. Too-small chunks lose the surrounding context a fact needs to be understood correctly -- a sentence pulled with no paragraph around it can be technically retrieved and still be useless or misleading. Too-large chunks dilute the signal: the one relevant sentence gets buried in a large block of mostly-irrelevant surrounding text, which both wastes context-window tokens and can lower the embedding's precision (a big chunk's embedding represents an average of everything in it, not the one fact that matters). A reasonable default is sentence- or section-based chunking with some overlap between adjacent chunks, so a chunk boundary doesn't sever the exact fact a query would need.
(b) Embedding match. Similarity search operates on *semantic* closeness, not exact matching. This is usually the point -- it's what lets a query about "refund policy" match a chunk that says "return window" even though the words differ. But that same property means embedding search can miss a query that hinges on an exact term or identifier: a specific product SKU, an error code, an exact API parameter name. Two chunks can be semantically similar to a query while the one chunk containing the *exact string* the query needed sits just outside the embedding-similarity threshold. Pairing embedding search with a lexical/keyword match (a plain text/substring search running alongside the vector search) catches exactly what pure similarity search misses on identifier-heavy queries.
(c) Assembly. Retrieving the right chunks doesn't automatically mean the model uses them. If the assembled prompt's structure doesn't match what the model's instructions lead it to expect -- retrieved chunks dumped in without clear delimiting, or placed somewhere the prompt doesn't point the model toward -- the model can silently answer from its own training-data memory instead of the content that was just retrieved, ignoring the retrieval step's entire output without any error or signal that anything went wrong. This connects directly to the delimiter and placement techniques from earlier in this domain (Lesson 6.2): retrieved content needs to be clearly delimited and the instruction needs to point at it explicitly, or retrieval quietly does nothing.
Agentic Search: No Index, Search at the Moment of Need
Agentic search skips the upfront indexing step entirely -- there is no pre-built vector database. Instead, the model searches live, at query time, figuring out what it needs the moment the question arrives and fetching it on the spot: querying whichever live sources are available, opening documents as they're needed, weaving new findings in as the work progresses. This is the researcher-who-goes-and-finds-it model, as opposed to the librarian with cards prepared in advance.
Two concrete, real-world examples of agentic search you may already have encountered without the name: Claude Code's own MCP tool-discovery mechanism (when connected to many external tools, Claude doesn't load every tool definition up front -- it discovers and loads only the tools a given task needs, searching for them live rather than pre-indexing them), and Claude.ai Projects over a large knowledge base (when a project's material is too large to fit in context, the system surfaces only the sections most relevant to each question, found at question time rather than pre-indexed).
Classical RAG and Agentic Search Do the Same Job, on Different Timing
Strip away the mechanics and both approaches are doing the same underlying job: surface the relevant piece of material and build the answer from it. What separates them is purely when that surfacing happens. One matches against an index that was already sitting there; the other goes and looks the moment it's needed. Calling either one categorically "better" misses the point -- each is buying a different set of tradeoffs.
The Fetch-Once vs. Iterative-Search Tradeoff
| Classical RAG (fetch-once against a pre-built index) | Agentic search (iterative, live, across multiple rounds) | |
|---|---|---|
| Per-query latency/token cost | Lower -- one similarity search against an already-built index | Higher -- the model spends turns searching, reading, and deciding whether to search again |
| Index infrastructure | Required -- a vector database that must be built and kept in sync with source material | Not required -- nothing to build or maintain ahead of time |
| Staleness risk | Real -- the index reflects the source material as of whenever it was last (re)built; if source material changes, the index can be stale until reindexed | Minimal -- searching live means always reading current material |
| Cost as the corpus grows | Index build/maintenance cost grows with corpus size, though query-time cost stays roughly flat once built | Scales as a flat per-request cost as the corpus grows -- no reindexing step exists to slow down or fall behind |
Agentic search's flat-cost-at-scale property is genuinely useful, but it comes with an important caveat: agentic search is only as good as what it can actually find. Because there's no pre-built index doing the matching for it, the model is relying on live search and its own judgment about what to look for and where -- which means how source material is *organized and named* matters far more for agentic search than it does for classical RAG's embedding-based matching. A file named notes_final_v3.pdf is much harder for agentic search to correctly retrieve than one named Q3 refund policy, updated August 2024 -- the descriptive name is itself a retrieval signal that a live search step can act on, where a vague version-numbered name gives it nothing to go on.
Common exam traps
- Treating chunk size as a minor implementation detail rather than a real tradeoff -- too-small loses context, too-large dilutes signal, and "sentence/section-based with overlap" is the reasonable default to reach for.
- Assuming semantic/embedding search alone is sufficient for queries that hinge on an exact term, code, or product identifier -- pairing it with lexical/keyword search is the fix, not a nice-to-have.
- Assuming that retrieving the correct chunks guarantees the model will use them -- a mismatched or undelimited assembly can cause the model to silently answer from its own training data instead of the retrieved content.
- Treating classical RAG and agentic search as differing in *quality* rather than *timing* -- they do the same fundamental job (find a relevant slice, generate from it); the difference is whether the index was built in advance or the search happens live.
- Assuming agentic search works equally well regardless of how source material is organized -- vague or generic file/document names actively hurt its ability to find what's needed, since there's no embedding index doing that work for it.
Key Takeaways
- Classical RAG: chunk documents, embed each chunk, store embeddings in a vector index, then run a similarity search against that index at query time
- Chunking fails in two directions: too-small chunks lose surrounding context; too-large chunks dilute the signal with irrelevant text -- sentence/section-based chunking with overlap is a reasonable default
- Embedding match operates on semantic closeness and can miss queries that hinge on an exact term or identifier -- pairing it with lexical/keyword search catches what similarity search misses
- Assembly failures happen when retrieved content's structure doesn't match what the prompt expects -- the model can silently answer from training-data memory instead of the retrieved context
- Agentic search has no pre-built index -- the model searches live at query time (e.g., Claude Code's MCP tool discovery, or Claude.ai Projects over a large knowledge base)
- Classical RAG and agentic search solve the same underlying problem (surfacing the relevant material and generating from it) -- what distinguishes them is only when the surfacing happens: pre-built index vs. live lookup on demand
- Agentic search scales as a flat per-request cost as the corpus grows (no reindexing), but is only as good as what it can find -- descriptive file/document naming meaningfully improves its retrieval
- Fetch-once (classical RAG) trades index infrastructure and staleness risk for lower per-query latency/cost; iterative agentic search trades higher per-query cost for freshness and no separate index to build
Glossary Terms
A pattern that dynamically retrieves relevant information from an external knowledge base and injects it into the context window based on the current query. Allows Claude to reason over large document sets without fitting everything in context at once.
An agent-environment interface design where a lean surface is exposed up front and the agent fetches additional detail on demand, rather than front-loading every tool, schema, and document into context (monolithic context). Progressive discovery is the scalable pattern for large integrations; monolithic context is acceptable only when the full set is small and stable.
Related Concepts
Context Isolation via Subagents and Just-in-Time Retrieval
Context isolation delegates heavy subtasks to a subagent with its own window, keeping the main context clean
Delimiters, Input Sanitization & Iterative Refinement
XML-style tags/headings separate instructions from data, improving reliability and enabling sanitization