Interlinked.

Guides · token economics · measured July 2026

Most of your agent's tokens go to looking for files. Here's how to measure it.

You pay for a coding agent by the token: a Claude Max subscription, an API bill, a seat. Run /cost in Claude Code after a real session and you get a big number. What the number won't tell you is that on a 4.47-million-file machine we measured, about 58% of it went to the least glamorous job in software: finding the right file. This is how to see where your tokens actually go, in your own sessions, and the one change that sends the file-hunting share toward zero.

Start here

AI agent token usage is the total number of tokens (the chunks of text a model reads and writes) that a session spends: the system prompt, every file and directory listing it pulls in, every search result, its own reasoning, and the code it writes back. You pay for all of it. On a real machine, most of it goes somewhere surprising.

Key takeaways

01

The total is easy. Claude Code's /cost totals a session; over the API, every response carries a usage object. That is the headline number.

02

The breakdown is the hard part. No tool splits out file-hunting for you. You get it by tallying the search-and-locate tool calls yourself. This guide shows how.

03

~58% goes to finding files. On a 4.47M-file machine, about 58% of a real session's tokens went to locating files, before a line of the answer was written.

04

It compounds. Every search result is re-sent on every later turn, so a fat directory dump is billed again and again as the session grows.

05

The fix isn't a bigger plan. A prebuilt index sends the ~58% toward ~0% without changing your model: one lookup instead of seventy-one.

The method

The counter you already have, and the part it won't label.

Every agent hands you a usage total. What none of them hand you is the breakdown: how much of that total was the model thinking about your problem versus reading directory listings it forgets a turn later. You get the breakdown by reading the buckets you already have and tallying the rest by hand. Five steps.

session: usage$claude  /costinput · prompt + files + tool resultsoutput · the code it wrotecache-read · history re-sent every turn→ inside the input, ~58% was the agent finding files(the line /cost won't split out for you)Illustrative of the categories, not token counts. The total is one command away; the 58% you tally yourself.
1

Read the total. In Claude Code, /cost prints the tokens and dollars a session spent. Over the API, every response carries a usage object. That is the headline number, and it does not yet tell you where the money went.

2

Split it into four buckets. Input (the system prompt, the tool definitions, and everything the agent pulled in), reasoning, output, and tool results: the directory listings, grep dumps and files it reads while hunting. Three are small and roughly fixed. The fourth is the one that balloons.

3

Watch the re-reads. Because the whole conversation is re-sent on every turn, a search result is billed again and again. When cache_read_input_tokens dwarfs output_tokens, the agent is re-reading its own search history, not writing your code.

4

Tally the hunting calls. Count how many tool calls were locate-a-file (ls, grep, find, Glob) versus edit-or-reason. On the session we measured, finding one file took 71 of them.

5

Do the money math. Multiply the hunting share by your bill. About 58% of a session is about 58% of what you paid, for output the model throws away a turn later. That proportion, not a smarter model, is the thing to move.

One session, to scale

The whole session's tokens, drawn as one bar.

Here is where the five steps land. The fixed tax and the actual work (the reasoning and the code) are a sliver. The rest is the agent walking the disk: a find that returns four thousand paths is four thousand lines the model re-reads on every step that follows, which is why the slice keeps growing as the session runs. The share is measured; the split inside the rest is illustrative.

ONE AGENT SESSION · 100% OF THE TOKENS YOU PAID FOR8%REASONING + OUTPUT~34% · the work you wanted58%FINDING FILES■ ~8% FIXED: the system prompt and tool definitions, sent every turnWHAT THE 58% IS MADE OF71 tool calls · ls · grep · find · glob · cat: 6m 57s to one file→ found in 16 ms with an index: one call, ~0% of the budgetMeasured: Claude Code, one real file-hunt task · Ryzen 9 9950X3D · Windows 11 · 4.47M files.Only the file-hunting share is measured; the reasoning/output split shown inside the rest is illustrative.

Same drawing, more detail: the session budget, unpacked walks the anatomy turn by turn, and the cost of file hunting turns the slice into dollars per developer per day.

The money, in plain terms

A plan that spends more time searching than thinking.

Claude Max keeps a frontier model in the loop and lifts your limits, often worth every dollar for the reasoning. But if most of a session's tokens go to locating files, the plan is doing more searching than reasoning. You are renting a frontier model to run ls and grep. The model is not the bottleneck. The floor it stands on is.

~58%
of a real session's tokens went to locating files, before a line of the answer was written
6m 57s → 16ms
the same file, found: near seven minutes of grinding, then faster than a blink
71 → 1
tool calls for one lookup, once the floor answers from an index instead of the disk
YOUR SESSION'S TOKEN BUDGETsplit by where the tokens went
58% · FINDING FILES
42% · THE WORK

End to end, that is roughly a 7,200,000× speed-up on the measured task, and the content query the agent actually shells out to is no kinder: the same search that an index answers in 16 ms took 93.8 seconds on ripgrep, 58,625× slower across the set. Tokens spent grepping are tokens not spent reasoning, and on a metered plan they are dollars; on a subscription, they are how fast you hit your cap.

THE FIX ISN'T A SMARTER MODEL. IT'S A FASTER FLOOR.

Same session · measured two ways

What moves once the agent asks an index instead of the disk.

The measurement is the same on both sides: same machine, same task, same model. The only variable is whether the agent walks the drive on every query or asks a prebuilt index that is always fresh. Run /cost before and after and this is the row that changes.

Per lookupWalking the diskWith the index
Time to the file6m 57s16 ms
Tool calls to locate it711
Session tokens on file-hunting~58%~0%
Single-file lookupwalks the drive85 μs
Heavy content query93.8 s (ripgrep)16 ms
Edit → searchablere-scan / re-walk~1 ms

Methodology: Ryzen 9 9950X3D · 64 GB DDR5 · NVMe · Windows 11 · 4,470,000 files. Single-file lookup is 85 μs (139 μs median across 20 queries, best case 2 μs); the ripgrep row is one heavy content query over the same corpus; the agent run is the measured Claude Code session. The same picture as a stack is in the backbone write-up.

Questions people ask

Measuring token usage, answered.

How do I check how many tokens my AI agent used?

In Claude Code, /cost totals the tokens and dollars for the current session. Over the API, every response carries a usage object with input, output, and cache-read tokens. Neither splits out file-hunting by default: you get that share by tallying the search-and-locate tool calls.

Why does file searching cost so many tokens?

Every tool result is appended to the conversation and re-sent on the next turn, so a fat directory listing or grep dump is billed again and again. It compounds: by late in a session, the agent can spend more re-reading its own search history than reading the file it is looking for.

Will a bigger plan like Claude Max reduce it?

No. A larger plan raises your usage ceiling; it does not change how files are found. The retrieval floor (find, grep, Glob, walking the disk) is identical on every tier. You just burn through more of it before you hit a wall.

What actually reduces the file-hunting tokens?

Give the agent a prebuilt, always-fresh index so it asks once instead of scanning the disk. That takes the ~58% search share toward ~0% without touching the model. Scoping to a folder when you know where something lives, and not pre-pasting file trees into context, help too.

Do I need a smarter or bigger model?

No. The file-hunting tax is a retrieval problem, not a reasoning one: the model is fine; it is being fed walls of directory output. The fix is a faster floor, not a bigger brain.

Do this today

Measure it, then move it.

1

Baseline first. Run /cost on a real session before you change anything, and write the number down. You can't tell what the fix bought you without the before.

2

Install once. One signed installer auto-configures 19 AI clients: Claude Code, Cursor, Codex, Copilot, Windsurf, Zed, Cline and the rest. No JSON editing, no keys.

3

Let it index; ask the 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 its index takes under 1% of the drive.

4

Measure again. Run /cost after. The tokens that were hunting are now reasoning: same plan, same model, more of it spent on your actual problem.

Everything local is free forever, on all your devices, no card. Hosting starts at $5.99/mo. No AI, no keys, no metered lookups, and the index never leaves your machine. Download for Windows.

Related reading: where your tokens go, how to reduce AI coding costs, and the backbone of the LLM economy.

Measured July 2026 · Ryzen 9 9950X3D · 4.47M files · Windows 11← All research