---
title: RAG is what you do, a tool call is how you do it
description: People argue about RAG against tool calls as if they were two rival designs. RAG is the goal, an answer written from text fetched for the question, and a tool call is one way to fetch that text. The real choice is who fetches: your code before the model starts, or the model itself.
date: 2026-11-19
tags: RAG, tool calls, AI agents, retrieval, vector search, GraphRAG
---

RAG and tool calls are not two rival designs. RAG, short for retrieval-augmented generation, is a goal: the model answers from text fetched for the question. A tool call is one way to fetch that text: the model asks for what it wants to read. The real choice is who does the fetching, your code before the model starts or the model itself.

The two words get mixed up all the time. Some say coding agents killed RAG when they dropped their vector databases. Others say an agent that searches is just doing RAG. Both are right, because they use the same word for two different things. Once you separate them, choosing a design for your own documents gets much simpler.

## RAG names the goal, not the method

Read the name slowly. Generation: a model writes an answer. Retrieval-augmented: with text fetched for this question, on top of what the model learned in training. Nothing in the name says how the text is fetched.

The narrow meaning has history behind it. The name comes from a [2020 paper](https://arxiv.org/abs/2005.11401) by Patrick Lewis and colleagues at Facebook AI, and their retriever was a vector search over Wikipedia. Many teams copied that shape, and "RAG" came to mean one pipeline:

- **Chunks.** Your documents are cut into pieces of a few hundred words.
- **Embeddings.** A small model turns each piece into a vector, a list of numbers where texts with a similar meaning land close together.
- **The search.** The question gets a vector too, and a vector database returns the closest chunks.
- **The prompt.** Your code pastes those chunks into the prompt, and the model answers.

That pipeline is one way to reach the goal. A keyword search reaches it too, and so does a SQL query, an API call or reading a file. If the model answers from text fetched for the question, it's retrieval-augmented generation.

<figure class="fd-fig kf" aria-labelledby="rt1-cap" data-desc="Two meanings of the word RAG, compared on three rows. How it fetches: the narrow meaning is a vector search over chunks; the goal in the name allows any search, keywords, SQL, an API or a file. Who fetches: the narrow meaning is your code, before the model starts; the goal allows your code or the model itself. Where it comes from: the narrow meaning comes from the retriever in the 2020 paper; the goal comes from the words in the name. The goal column is highlighted.">
<p class="kf-kick">Two meanings of one word</p>
<p class="kf-title">RAG names the goal, <em>not the method</em></p>
<div class="kf-swap is-3">
<p class="kf-swap-h"><small></small><span>The narrow meaning</span><span>The goal in the name</span></p>
<p><small>How it fetches</small><span>A vector search over chunks</span><em>Any search: keywords, SQL, an API, a file</em></p>
<p><small>Who fetches</small><span>Your code, before the model starts</span><em>Your code, or the model itself</em></p>
<p><small>Where it comes from</small><span>The retriever in the 2020 paper</span><em>The words in the name</em></p>
</div>
<figcaption id="rt1-cap">The 2020 paper is by Lewis and colleagues at Facebook AI. Its retriever searched a vector index of Wikipedia.</figcaption>
</figure>

## The real choice is who fetches

What people mean by "RAG against tool calls" is a question of control. Who decides what the model reads: your code, or the model?

In the classic pipeline, your code fetches before the model starts. It runs one search and pastes the results. The model never asks for more. That makes one model call per question, cheap and easy to predict. It fails when that one search misses: the model answers from the wrong chunks, or says it doesn't know.

With tools, the model fetches. It gets a tool such as `search(query)` or `read_file(path)`, decides what to look for, reads the result, and can search again with better words. That takes several model calls per question, and [each call reads the whole conversation again](/notes/tokenops-agent-cost-curve.html). It costs more and takes longer. But it recovers from a bad first search, the way you would.

Coding agents moved this way. Boris Cherny, who created Claude Code at Anthropic, said in 2025 that early versions indexed the code with an off-the-shelf vector search. The team switched to letting the model search with plain file tools, `glob` and `grep`, and found it worked better. He also said the evidence was mostly everyday use, with only a few internal benchmarks.

The two also fit inside each other. OpenAI's `file_search` is "a tool available in the Responses API". The model decides when to call it, and inside, the tool searches your files "through semantic and keyword search". That's a tool call with the classic vector search inside. Asking "RAG or tool calls?" is a bit like asking "SQL or HTTP?": one often runs inside the other.

<figure class="fd-fig kf" aria-labelledby="rt2-cap" data-desc="Your code fetches against the model fetches, compared on four rows, with neither side highlighted. When: once, before the model starts, against during the answer, as often as it needs. Model calls: one per question, against several, each rereading the conversation. Cost: low and predictable, against higher and variable. If the search misses: the answer is built on the wrong text, against it searches again with other words. Under the table: the two nest, since OpenAI's file search is a tool with a vector search inside.">
<p class="kf-kick">Who decides what the model reads</p>
<p class="kf-title">The real choice is <em>who fetches</em></p>
<div class="kf-swap is-3 is-even">
<p class="kf-swap-h"><small></small><span>Your code fetches</span><span>The model fetches</span></p>
<p><small>When</small><span>Once, before the model starts</span><span>During the answer, as often as it needs</span></p>
<p><small>Model calls</small><span>One per question</span><span>Several, each rereading the conversation</span></p>
<p><small>Cost</small><span>Low and predictable</span><span>Higher, and it varies</span></p>
<p><small>If the search misses</small><span>The answer is built on the wrong text</span><span>It searches again with other words</span></p>
</div>
<p class="kf-note">They nest: OpenAI's file search is a tool with a vector search inside.</p>
<figcaption id="rt2-cap">A schematic comparison. OpenAI's file search guide describes semantic and keyword search over your files.</figcaption>
</figure>

## A chat with no vectors

The Ask button on this site is RAG done with one tool and no vector database. [An earlier note](/notes/ai-chat-answers-only-from-my-site.html) covers how it works and what it guards against. Here is only the retrieval part.

Every time the site is built, it writes a list of its 126 pages, in English and French. Each entry holds the page's title, summary and headings. The model gets that list in its prompt, plus one tool, `read_page`, which returns the full text of one page. It reads the list, opens up to five pages, and answers with a link to each page it used.

The first day gave real numbers. Ten of the first 24 questions needed no page at all: the list alone answered them, for about 13,000 tokens read. The most expensive question opened four pages, read 42,000 tokens and cost $0.0037.

At this size, the list does the job a vector index would do. The model picks pages by their titles and summaries, the way you scan a table of contents. Then it reads each page whole, so no chunk cuts an explanation in half.

So when does that stop working? When the list itself gets too long. The 13,000 tokens include the chat's rules, so this is a rough upper bound: ten thousand pages would need a list of up to about a million tokens, sent with every question. That's where a search tool takes over, with a keyword or vector index inside.

<figure class="fd-fig kf" aria-labelledby="rt3-cap" data-desc="This site's Ask chat on its first day, as three big numbers. 126 pages in the list, with titles, summaries and headings. In blue, 10 of 24 questions answered from the list alone, with no page opened. 0.0037 dollars for the most expensive answer, which opened four pages. Under the numbers: ten thousand pages would need a list of up to about a million tokens.">
<p class="kf-kick">This site's Ask chat, first day</p>
<p class="kf-title">126 pages, one tool, <em>no vector database</em></p>
<div class="kf-stats">
<p><b data-count="126">126</b><span>pages in the list, with titles, summaries and headings</span></p>
<p class="is-key"><b data-count="10">10 of 24</b><span>questions answered from the list alone, no page opened</span></p>
<p><b data-count="0.0037">$0.0037</b><span>the most expensive answer: four pages opened</span></p>
</div>
<p class="kf-note">Ten thousand pages would need a list of up to about a million tokens.</p>
<figcaption id="rt3-cap">My numbers from the chat's first day, November 17. The million is arithmetic from 13,000 tokens for 126 pages, rules included.</figcaption>
</figure>

## One name, five patterns

Under the word RAG, teams now use at least five patterns. Each one was built for a different miss.

- **Classic vector search.** The pipeline above. It finds meaning even when the words differ: a question about "cancelling" finds the paragraph on "termination". It can miss exact strings.
- **Hybrid search with reranking.** A keyword search runs next to the vectors, usually BM25, the scoring that classic search engines use. Anthropic's example is the query "Error code TS-999": embeddings can miss that exact string, and keywords catch it. Then a reranker, a second model, reads the top 150 results and keeps the best 20.
- **Contextual retrieval.** A chunk often loses what it's about. Anthropic's example reads "The company's revenue grew by 3% over the previous quarter": which company, which quarter? So before indexing, a model writes a short line of context for each chunk.
- **GraphRAG.** Microsoft Research built it for questions about a whole collection, like "what are the main themes across these documents?". A model reads every document and builds a graph of the people, things and links in it. Then it groups related nodes and writes a summary for each group, and answers come from those summaries.
- **Agentic retrieval.** The model searches with tools, in as many rounds as it needs. Any of the four above can sit inside its tools.

Two of these come with numbers from their makers. On Anthropic's tests, contextual retrieval cut the searches that missed the right chunk by 35%. With keyword search added, the cut was 49%, and with reranking on top, 67%.

GraphRAG's first version was expensive: it made model calls on every document just to build the index. Microsoft's later versions cut that cost. LazyGraphRAG brought it to 0.1% of the original, and GraphRAG Zero makes no model calls at all while indexing. On whole-collection questions, Microsoft reports that GraphRAG Zero covered 57.4% of the expected points, against 53.4% for plain vector search. Vector search still did better on precise lookups. These are Microsoft's results, on a benchmark Microsoft built, and the gain is modest.

<figure class="fd-fig kf" aria-labelledby="rt4-cap" data-desc="Five patterns under the word RAG, each with how it works and what it fixes, the fixes highlighted. Classic vector: chunks become vectors and the closest ones are fetched; the starting point, it finds meaning even in other words. Hybrid and rerank: keyword search next to the vectors, then a second model re-sorts the results; it fixes exact strings, like Error code TS-999. Contextual: a model adds a line of context to each chunk; it fixes chunks that lost what they were about. GraphRAG: a graph of entities and links, with a summary per group; it fixes questions about the whole collection. Agentic: the model searches with tools, round after round; it fixes a first search that missed. Under the table: each maker measured its own pattern, on its own tests.">
<p class="kf-kick">Five patterns under the word RAG</p>
<p class="kf-title">One name, five patterns, <em>each built for a different miss</em></p>
<div class="kf-swap is-3">
<p class="kf-swap-h"><small></small><span>How it works</span><span>What it fixes</span></p>
<p><small>Classic vector</small><span>Chunks become vectors; the closest ones are fetched</span><em>The starting point: finds meaning, even in other words</em></p>
<p><small>Hybrid and rerank</small><span>Keyword search next to the vectors, then a second model re-sorts</span><em>Exact strings, like "Error code <span class="kf-nw">TS-999</span>"</em></p>
<p><small>Contextual</small><span>A model adds a line of context to each chunk</span><em>Chunks that lost what they were about</em></p>
<p><small>GraphRAG</small><span>A graph of entities and links, with a summary per group</span><em>Questions about the whole collection</em></p>
<p><small>Agentic</small><span>The model searches with tools, round after round</span><em>A first search that missed</em></p>
</div>
<p class="kf-note">Each maker measured its own pattern, on its own tests.</p>
<figcaption id="rt4-cap">From Anthropic's Contextual Retrieval post and Microsoft Research's GraphRAG article. The grouping is mine.</figcaption>
</figure>

## Add a layer only when the last one breaks

My rule of thumb is a ladder. Start at the top, and go down a step only when the step you're on stops answering.

1. **Everything in the prompt.** Anthropic's advice: under 200,000 tokens, about 500 pages, put the whole collection in the prompt, with no retrieval at all. A prompt cache, a copy the provider keeps for a few minutes and reads back cheaply, keeps repeat questions affordable.
2. **A list and a read tool.** When the collection doesn't fit but a list of titles and summaries does. This site's chat lives here.
3. **A search tool.** When even the list is too long. Inside it: keyword plus vector search and a reranker, with contextual chunks if searches keep missing.
4. **A graph.** When people keep asking about the whole collection, and it doesn't change every hour, so the cost of building it pays back.

Anthropic wrote its advice in 2024. Context windows have grown since, but every token sent is still paid for, on every question. So the ladder holds: the bigger windows only push the first step further.

<figure class="fd-fig kf" aria-labelledby="rt5-cap" data-desc="Where to start with your own documents, as four steps. One, in blue, up to about 500 pages: everything in the prompt, no retrieval, with a prompt cache keeping repeat questions cheap. Two, when a list still fits: a list and a read tool, the model picks pages from titles and summaries. Three, when the list is too long: a search tool, with keywords plus vectors inside and a reranker. Four, for questions about the whole collection: a graph, only if those questions come often and the data holds still.">
<p class="kf-kick">Where to start with your own documents</p>
<p class="kf-title">Add a layer <em>only when the last one breaks</em></p>
<ol class="kf-steps">
<li class="is-key"><small>Up to about 500 pages</small><b>All in the prompt</b><span>No retrieval. A prompt cache keeps repeat questions cheap.</span></li>
<li><small>A list still fits</small><b>List and read tool</b><span>The model picks pages from titles and summaries.</span></li>
<li><small>The list is too long</small><b>Search tool</b><span>Keywords plus vectors inside, and a reranker.</span></li>
<li><small>Whole-collection questions</small><b>A graph</b><span>Only if they come often and the data holds still.</span></li>
</ol>
<figcaption id="rt5-cap">My rule of thumb. The 500 pages, or 200,000 tokens, is Anthropic's figure from 2024.</figcaption>
</figure>

## Try it

Pick one assistant you use or build, and find out who fetches. If your code does, look at what happens when its one search misses. If the model does, count the model calls per question.

- [An AI chat for my website that answers only from its own pages](/notes/ai-chat-answers-only-from-my-site.html): the chat with no vectors, its limits and its cost. Or click Ask, at the bottom right of this page.
- [Contextual Retrieval](https://www.anthropic.com/news/contextual-retrieval), Anthropic, September 2024: hybrid search, reranking and the numbers above.
- [The evolution of GraphRAG](https://www.microsoft.com/en-us/research/story/the-evolution-of-graphrag-advancing-systems-and-evaluation-together/), Microsoft Research: the three versions and how they measured them.
- [File search](https://developers.openai.com/api/docs/guides/tools-file-search), OpenAI's guide: a tool with a vector search inside.
- [Claude Code: Anthropic's Agent in Your Terminal](https://www.latent.space/p/claude-code), Latent Space, 2025: Boris Cherny and Cat Wu on moving from a vector index to agentic search.
- [Personal AGI is an agent you own, not a chat you rent](/notes/personal-agi-own-not-rent.html), on the "it's just RAG" objection: fetching is the easy part.

If your documents break the ladder, a collection where the next step down didn't help, tell me with "Reply by email" below.
