Guides · measured July 2026 · 7 min read
How to stop your AI agent from re-reading the same files.
Watch an agent work for an hour and you'll catch it opening the same file three, four, five times: re-listing the same folders, re-grepping for the same function, re-reading a file it already read two turns ago. You pay for every trip. It happens because the agent has no fast way to find things, so it rediscovers your machine from scratch, over and over.
On a real 4.47-million-file machine we measured the bill. Left to its own tools, Claude Code spent 6 minutes and 57 seconds and 71 tool calls hunting for one file. About 58% of the session's tokens went to finding, not thinking. With a live index underneath it: 16 milliseconds, one call. A bigger plan like Claude Max buys a smarter model; it does not stop the re-reading. This guide shows what does.
TL;DR · the 60-second version
- 01
The re-read tax is the tokens and wall-clock an agent burns re-finding and re-opening files it already saw this session, because it has no fast index to locate them and no memory that survives between turns. You pay for every repeat.
- 02
It gets worse on long sessions: as the context window fills, older reads get compacted away, so the model re-reads to recover what it just forgot.
- 03
Measured on a 4.47-million-file machine, one file-hunt cost Claude Code 6 minutes 57 seconds and 71 tool calls; the same lookup against a live index took 16 milliseconds and one call, end to end roughly 7,200,000× lighter.
- 04
The fix has two halves: fast retrieval so re-finding is one ~85 µs lookup instead of a disk walk, and reading less(content search returns the matching lines with context), so the agent pulls the few lines it needs instead of the whole file.
- 05
Interlinked ships that index: every file on the machine by name, always fresh, git-ignored files included, plus content search, shared by every agent, offline, no model in the box.
The re-read tax, defined
Name the problem first. Then it's fixable.
The re-read tax is the tokens and wall-clock an AI agent spends re-finding and re-opening files it already saw earlier in the same session, because it has no persistent index to locate them quickly and no way to ask for just the lines it needs. It is not a bug in the model; it is a gap in the layer underneath it, the slowest, most token-expensive layer every agent stands on.
Four things drive it. The first two are why the agent forgets; the last two are why re-remembering is expensive.
No memory between turns.
A language model is stateless: each turn it knows only what is in the context window right now. A file it read is just text sitting in that window; once it scrolls out, the knowledge is gone and the file has to be opened again.
The window fills, and old reads get dropped.
On a long session the harness compacts or summarizes earlier turns to make room. File contents are the first thing to go, so the model re-opens them to recover what it had a few turns ago. That is a big part of how the context window works.
No fast way to find things.
When it does need a file again, it has no index to ask, so it re-lists directories and re-greps the disk, the same slow walk as the first time. That is how Claude Code finds files today, and why re-finding one can cost minutes.
Nothing survives the session.
Close the window and everything it found (where a file lives, which repo holds what) is gone. Tomorrow it walks the disk again from zero.
You can blunt the tax yourself: scope the agent to a specific path so it walks less, checkpoint or compact a long session on purpose before the window fills, and hand it explicit file paths instead of “go find the auth guard.” All of it helps at the margin, and all of it fights the symptom. The cause is the two missing pieces underneath: a fast index and a way to read only the lines that matter.
One file, one session
Read once, or read it five times.
Here is the same file across one working session, drawn two ways. On the left the agent has no index and no memory, so it opens auth.ts again and again and re-greps to re-find it: four full reads of one file. On the right, one indexed lookup, then only the matching lines, carry the rest of the session for almost nothing.
Six minutes and fifty-seven seconds (long enough to make a coffee) spent finding a file the agent had already opened once. Sixteen milliseconds is about a third of the time it takes to blink. Fold time, tool calls and tokens together and that one workflow came in roughly 7,200,000× lighter. And more than half the bill on a $200/month plan went to reads the model would forget one turn later. That is exactly where your tokens go.
Same machine · same drive · same queries
Four repeats, one fix.
| The repeated step | Today's fallback | Today's cost | With the index |
|---|---|---|---|
| Re-find a file it saw earlier | re-list dirs, re-grep the disk | 35 s to 93.8 s | 85 µs to 16 ms |
| Re-open a file to find one line | re-ingest the whole file | full tokens, again | the matching lines, with context |
| Re-derive the repo layout | re-walk every repo | every session | type:'repo', one call |
Methodology: Ryzen 9 9950X3D · 64 GB DDR5 · NVMe · Windows 11 · 4,470,000 files. Single-file lookups run a median 85 µs (best case 2 µs; 139 µs across 20 whole-drive queries). The content row is one hard query timed both ways: 93.8 s walking the disk, 16 ms indexed, a 58,625× median speedup across the content set. Full per-tool methodology in the ripgrep comparison and the 412,000× VS Code write-up. Notice the pattern: every row is the agent trying to find something it already had.
Anchor · Claude Max
A bigger plan buys a smarter model. Not a faster floor.
It is tempting to answer a slow, forgetful agent by upgrading the plan. Claude Max raises your usage ceiling and keeps the strongest model in the loop, and for hard reasoning it is often worth every dollar. But the retrieval floor is identical on Free, Pro and Max: the same directory walk, the same grep, the same short memory that drops your files first when the window fills.
So a bigger plan does not shrink the re-read loop: it just runs the same loop on a more expensive model. Keep Max for the thinking; fix the floor for the speed. They are different layers, and the index is the neutral one every plan plugs into.
What Max changes
Model quality in the loop
Higher usage limits
Deeper reasoning per turn
What it doesn't
How files are found
The grep-the-disk floor
The re-read tax
The fix, both halves
Find it once. Read only what you need.
Half one is speed. Interlinked keeps an always-fresh index of every file on the machine (names and contents, every repo, the git-ignored files a cwd grep never sees, documents included) and exposes it to any agent over MCP. Re-finding a file is one lookup at about 85 µs (139 µs median across 20 queries), content in 7 to 9 ms, and a save is searchable in about a millisecond, under 30 ms worst case. The re-find loop stops costing minutes because it stops costing anything.
Half two is reading less. Where text search is installed, a content query returns the matching lines with line numbers and context, so the agent reads the few lines it needs instead of re-ingesting the whole file. And because the index covers the whole machine, including the git-ignored files and the folders outside the repo, there is no second dig for the file it could not see the first time.
SPEED ENDS THE RE-FIND. MATCHING LINES END THE RE-READ. THE AGENT STOPS REDISCOVERING YOUR MACHINE.
Questions people ask
The honest FAQ.
Why does my AI agent keep re-reading the same files?
Because it is stateless and has no fast memory. Each turn the model only knows what is in its context window; when earlier turns get compacted to make room, the file contents drop out first, so it re-opens them. And when it needs to locate a file again, it has no index: it re-lists directories and re-greps the disk exactly as it did the first time. A fast index is the missing piece.
Does a bigger plan like Claude Max fix it?
No. Claude Max raises your usage ceiling and keeps the strongest model in the loop, which makes the thinking better, but every plan uses the same retrieval floor underneath: the same find, grep and glob, and the same short memory. A bigger plan buys a smarter model, not a shorter re-read loop. You end up paying premium rates for the model to re-read directory listings it will forget one turn later.
An index just makes finding faster. Doesn't the model still re-read the file?
Fair point, and it is the honest nuance. An index removes the re-find cost (the archaeology dig to locate the file), but re-reading a file's contents back into context still costs tokens. That is exactly why the second half matters: content search returns the matching lines with line numbers and context, so the agent pulls the few lines it needs instead of re-ingesting the whole file. The name index kills the re-find; content search shrinks the re-read.
Is Interlinked an AI?
Neither. There is no model inside it. It is the retrieval layer underneath any agent, handing it instant whole-machine search through one MCP server. The index covers every file on the machine, including the git-ignored ones a cwd grep never sees, and every agent on the machine shares it. Nothing leaves the machine.
How much faster is it, really, and what does it cost?
On the benchmark machine, one file among 4.47M returns in about 85 microseconds (139 µs median across 20 whole-drive queries) versus 35 seconds in VS Code and about 67 in Windows Search; a content query that took ripgrep 93.8 seconds returned in 16 milliseconds. A save is searchable in about a millisecond. The app, the file index and the MCP server are free forever. Interlinked is timelines for your files: version control for your team and its agents, hosting from $8.99/mo. See also how to make Claude Code faster.
Do this today
End the re-read loop in one install.
Install once. One signed installer auto-configures 19 AI clients: Claude Code, Cursor, Copilot, Codex, Windsurf, Zed, Cline and the rest. No JSON editing, no keys.
Let it index. Filename search works immediately; content fills in behind it. At rest the whole engine sits around 44 MB (less than a browser tab), and the index is under 1% of the drive.
Let the agent ask the index. Re-finding a file becomes one call that returns in microseconds instead of a re-list-and-re-grep dig. Whole-machine when you don't know where something lives; scoped to a folder when you do.
Let it read the lines, not the file. Where text search is installed, a content query hands back the matching lines with context, so the agent reads what it needs instead of the whole file again.
The app, the file index and the MCP server are free forever. Interlinked is timelines for your files: version control for your team and its agents, hosting from $8.99/mo. Download for Windows and stop paying your agent to rediscover the same files.