Lesson 47 of 57
Agentic Search
You ask an agent, "Where did we land on shipping rates?" The answer is written down somewhere in a project folder with six files. You did not say which file. The model has never seen the folder. Before it can answer, it has to find the right text.
Most of what a model is asked for is like this. The needed fact is not in the request, and it was not in the training data either, so the first job is to go and get it.
Agentic search is one way of getting it. The agent looks through your files step by step, and the model decides at each step what to look at next. Nobody prepares the files in advance, and nobody tells the agent which ones matter.
After this lesson you can describe the tool calls behind agentic search, compare it with the two other common ways an agent finds information, and explain what it costs and where it goes wrong.
| Term | Short meaning |
|---|---|
| Agentic search | Search in which the model decides, step by step, what to list and what to open |
| File system | The folders and files on a disk |
| Directory | Another word for a folder |
list_dir |
A tool that returns the names of the files in a folder |
read_file |
A tool that returns the contents of one file |
| Pass | One round of looking: list, choose, open, read |
1. Three places an agent can get a missing fact
When an agent needs a fact it does not have, there are three common places to look.
flowchart LR
A["The agent<br/>needs a fact<br/>it does not have"] --> W["Web search<br/>if a tool for it exists"]
A --> F["Your file system<br/>the disk in front of you"]
A --> V["A vector database<br/>the retrieval setup"]- Web search. The agent sends a query to a search engine and reads the results. This works only if the agent has been given a web search tool.
- Your file system. The file system is the set of folders and files on a disk. The agent looks through the files that are right there on the machine.
- A vector database. This is the setup described in the lessons on RAG and vector databases. Documents are cut into pieces and indexed ahead of time, and the pieces closest in meaning to the question are fetched.
These are not the only options. An agent can also get information in other ways, for example by querying an ordinary database or calling a company's internal service.
The second option, looking through files directly, is the one usually meant by the name agentic search. The word "agentic" means "done by an agent". The term is also used more widely for any search in which the model chooses the steps itself, including repeated web searches. This lesson uses the file case because it shows the idea most clearly.
2. The folder and what the agent is given
Here is the folder for the example. It is called ~/work/northwind, and it holds six files:
| File | Size |
|---|---|
supplier-terms.pdf |
14 pages |
rates-and-fees.md |
6 KB |
kickoff-notes.md |
2 KB |
old-logo.png |
240 KB |
meeting-minutes.md |
9 KB |
handover.md |
4 KB |
KB stands for kilobyte, a unit of file size. A text file of 6 KB holds roughly a thousand words.
For agentic search, the agent is handed three things, and the third is an absence:
- A folder. One directory (another word for folder) that the agent is allowed to read.
- A boundary around it. This is usually a sandbox: the agent can reach that folder and nothing outside it.
- No instructions about the contents. There is no list of files, no reading order, and no rule that says which files matter.
The third point is what separates agentic search from the vector database approach. With a vector database, someone has to prepare the documents first. With agentic search there is no preparation. The agent starts with a folder it knows nothing about.
3. One question, six files, two opened
Now the question arrives:
Where did we land on shipping rates?It is one sentence, and it does not contain a file name. This is what happens next.
| File | What the agent did |
|---|---|
supplier-terms.pdf |
Opened |
rates-and-fees.md |
Opened |
kickoff-notes.md |
Skipped |
old-logo.png |
Skipped |
meeting-minutes.md |
Skipped |
handover.md |
Skipped |
The agent opened two files and left four shut. It made that decision from the file names alone.
The reasoning behind each choice can be reconstructed. The question is about shipping rates. A file called rates-and-fees.md has the word "rates" in its name, so it is the most likely place. A file called supplier-terms.pdf is a contract with a supplier, and contracts commonly state prices, so it is the second most likely place. A logo image cannot contain an agreement about rates. The remaining three notes files are possible but less likely, so the agent leaves them for later.
"For later" matters here. If the two opened files do not contain the answer, the agent can go back and open meeting-minutes.md next. The search is not a single shot. It continues until the model judges that it has what it needs.
4. The same decisions as tool calls
Underneath, agentic search is a short series of tool calls. There are two kinds.
First the agent asks what is in the folder:
list_dir("~/work/northwind")
-> supplier-terms.pdf
rates-and-fees.md
kickoff-notes.md
old-logo.png
meeting-minutes.md
handover.mdThe list_dir tool takes the path of a folder and returns the names of the files in it. It does not return any file contents.
Then the agent asks for two of the files:
read_file("rates-and-fees.md")
read_file("supplier-terms.pdf", pages="3-5")The read_file tool returns the contents of one file. The second call shows a refinement: the agent asks only for pages 3 to 5 of the 14-page PDF. Some read tools accept a page or line range like this, so the agent can fetch a part of a long document instead of the whole thing.
sequenceDiagram
participant M as Model
participant H as Agent software
participant D as Disk
M->>H: list_dir(folder)
H->>D: Reads the folder
H-->>M: Six file names
M->>H: read_file(rates-and-fees.md)
H->>D: Reads the file
H-->>M: File contents
M->>H: read_file(supplier-terms.pdf, pages 3-5)
H->>D: Reads three pages
H-->>M: Page contentsThe model never touches the disk. It writes a tool call, and the agent software around it does the listing and the reading and passes the result back. This is the agent loop from an earlier lesson, used for searching.
Many agents also have a third kind of tool that searches inside files for a word or phrase and returns the matching lines. With it, the agent can ask "which files mention shipping" without opening each one. The pattern stays the same: the model decides what to search for and what to do with the result.
5. The same steps a person would take
Imagine you were sent to that folder with the same question. Nobody hands you the right files either. You would do this:
- Scan the folder. You look at what is there.
- Read the names. You judge that "rates-and-fees" sounds closer to shipping rates than "old-logo" does.
- Open two of the files to see which one states the answer.
This is the same procedure as the agent's, step for step. The only difference is who carries it out.
This comparison explains why agentic search needs no setup. It relies on the same clues people rely on: file names, folder names, and what a file says once it is opened. It also shows a dependency. A folder with clear names such as rates-and-fees.md is quick to search. A folder full of names such as doc1.md and final-v2.md gives neither a person nor an agent anything to judge by, so more files have to be opened.
6. The difference is speed, not better guesses
Put a person and an agent at the same folder and time them.
| Which files look worth opening | How long one pass takes | Passes in the same stretch of time | |
|---|---|---|---|
| A person | Two of the six | Long | One |
| An agent | The same two | Short | Several |
A pass is one round of looking: list the files, choose, open, and read.
The agent does not guess better than the person. It picks the same two files. What differs is the time for one pass. In the time a person needs for a single pass, an agent can make several, one after another.
This matters when the first pass fails. Suppose the answer was not in the first two files. A person has to start a second slow round. An agent has already opened the meeting minutes, found a reference to another document, and opened that too. Being able to repeat quickly makes up for individual guesses that turn out wrong.
7. What agentic search costs
Each step in the search is a request to the model, and everything the agent reads is added to its context.
- Tokens. The list of file names and the full text of every opened file become tokens in the context window. Opening many large files fills the window and raises the cost.
- Time. Several tool calls in a row take longer than one lookup.
- Scale. Six files can be judged from one listing. A store of a million documents cannot be searched by reading names and opening files one at a time.
This gives criteria for choosing between the approaches.
| Agentic search over files | Vector database retrieval | |
|---|---|---|
| Preparation | None | Documents must be split and indexed first |
| Stays current | Always reads the files as they are now | The index has to be updated when documents change |
| Cost per question | Several tool calls, and whole files in the context | One lookup, and only the fetched pieces in the context |
| Fits | A project folder or codebase with meaningful names | Very large collections of documents |
| Weak point | Poorly named files, and very large collections | Pieces fetched without their surrounding text |
The two are not exclusive. An agent can have a vector database tool and file tools, and choose between them per question.
8. What the term comes down to
Agentic search is a search through your own files in which the model makes the decisions.
You do not write a search query. You ask a question in ordinary words, and the agent makes a run of choices: which folder to list, which names look promising, which file to open, which pages to read, and when to stop. At the end of that run there is one fact or one file, which the model then uses to answer you.
Interview points
- An agent that lacks a fact can get it from web search, from the file system, from a vector database, or from another source such as a database query. Looking through files directly is the case most often called agentic search.
- In agentic search the agent gets a folder, usually inside a sandbox, and no information about what the folder contains.
- The search is built from ordinary tool calls: one that lists a directory and returns file names, and one that reads a file, sometimes limited to a page or line range. Many agents add a tool that searches file contents for text.
- The model chooses which files to open from their names and from what it has already read. It can go back and open more if the first files do not contain the answer.
- The model does not access the disk. It requests tool calls, and the agent software executes them and returns the results.
- The procedure is the same one a person follows: scan the folder, judge the names, open the likely files.
- An agent's choices are not better than a person's. Its advantage is that one pass is fast, so it can make many passes in the time a person makes one.
- Agentic search needs no index and always reads current files, but it uses more tool calls and more context per question than a vector database lookup.
- It fits project folders and codebases with meaningful names. It fits poorly when names carry no information or when the collection is very large.
Summary
- Agentic search means the model decides step by step what to look at.
- The agent starts with a folder and no description of its contents.
- It lists the folder, picks files by name, and opens them with tool calls.
- In the example, one question led to two of six files being opened.
- The agent software reads the disk. The model only asks.
- A person would follow the same steps, more slowly.
- Speed lets the agent repeat the search when a first guess fails.
- Everything the agent lists or opens uses context window space.
- Vector database retrieval needs preparation but handles very large collections.
