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 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.
Two meanings of one word
RAG names the goal, not the method
The narrow meaningThe goal in the name
How it fetchesA vector search over chunksAny search: keywords, SQL, an API, a file
Who fetchesYour code, before the model startsYour code, or the model itself
Where it comes fromThe retriever in the 2020 paperThe words in the name
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. 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.
Who decides what the model reads
The real choice is who fetches
Your code fetchesThe model fetches
WhenOnce, before the model startsDuring the answer, as often as it needs
Model callsOne per questionSeveral, each rereading the conversation
CostLow and predictableHigher, and it varies
If the search missesThe answer is built on the wrong textIt searches again with other words
They nest: OpenAI's file search is a tool with a vector search inside.
A chat with no vectors
The Ask button on this site is RAG done with one tool and no vector database. An earlier note 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.
This site's Ask chat, first day
126 pages, one tool, no vector database
126pages in the list, with titles, summaries and headings
10 of 24questions answered from the list alone, no page opened
$0.0037the most expensive answer: four pages opened
Ten thousand pages would need a list of up to about a million tokens.
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.
Five patterns under the word RAG
One name, five patterns, each built for a different miss
How it worksWhat it fixes
Classic vectorChunks become vectors; the closest ones are fetchedThe starting point: finds meaning, even in other words
Hybrid and rerankKeyword search next to the vectors, then a second model re-sortsExact strings, like "Error code TS-999"
ContextualA model adds a line of context to each chunkChunks that lost what they were about
GraphRAGA graph of entities and links, with a summary per groupQuestions about the whole collection
AgenticThe model searches with tools, round after roundA first search that missed
Each maker measured its own pattern, on its own tests.
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.
- 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.
- 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.
- 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.
- 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.
Where to start with your own documents
Add a layer only when the last one breaks
- Up to about 500 pagesAll in the promptNo retrieval. A prompt cache keeps repeat questions cheap.
- A list still fitsList and read toolThe model picks pages from titles and summaries.
- The list is too longSearch toolKeywords plus vectors inside, and a reranker.
- Whole-collection questionsA graphOnly if they come often and the data holds still.
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: the chat with no vectors, its limits and its cost. Or click Ask, at the bottom right of this page.
- Contextual Retrieval, Anthropic, September 2024: hybrid search, reranking and the numbers above.
- The evolution of GraphRAG, Microsoft Research: the three versions and how they measured them.
- File search, OpenAI's guide: a tool with a vector search inside.
- Claude Code: Anthropic's Agent in Your Terminal, 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, 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.
Plain text: rag-is-what-tool-call-is-how.md · Atom feed · All notes