What this is about
When you talk to an AI model, you do not pay by the word. You pay by the token. A token is a small piece of text, often a short word or part of a longer word. The model reads tokens and writes tokens, and the bill counts both.
For a chatbot, that is a small bill. For an agent it is not, because agents read a lot. This article explains why, and where the tokens go in a working day.
Why it matters
Tokens are three things at once. They are money, because most services charge per token. They are time, because more text to read means a slower answer. And they are room, because a model can only hold a fixed amount of text in view at once.
When an agent wastes tokens, it pays all three. It also has less room left for the thing you asked about.
How tokens add up
A token is a piece of text
The word "cat" may be one token. A long word like "unbelievable" may be three. Code and numbers often split into many small pieces. A rough rule that works for plain English is that one token is about four letters. Our context tool ctxd uses exactly that kind of rule: it estimates the size of a request as bytes divided by four.
The rule is only an estimate. Our line counter mokei can estimate tokens for a whole repository. Without a real tokenizer file, its estimate stayed within 3 percent of the real count on the repositories we measured.
An agent resends everything
Here is the surprise. A model has no memory. To continue a conversation, the software sends the whole history again with each turn. So turn ten pays for turns one to nine as well.
Think of a taxi meter that restarts from the first street every time you turn a corner. The longer the trip, the more each turn costs.
Services soften this with a cache. If the start of a request is the same as last time, the service can reuse its work and charge much less for that part. In one of our own measurements, a cached read cost about 0.1 times the normal price after the first write. That is cheap, but it is not free, and the cached text still takes up room.
Every file the agent opens is paid for
When an agent opens a file, the full text of that file enters the conversation. From then on it is resent with every turn. A two thousand line file read at the start of a long session is paid for again and again.
In one of our measured sessions, tool results and tool commands were the largest classes of context. In plain words: what the agent read and what the agent typed cost more than what we typed. That points to two cheap fixes: read less, and keep tool output short.
Fixed text at the start counts too
Every request begins with the same standing text: the instructions, the list of available skills and tools. This is the fixed start. In one count of ours, 40 skill descriptions came to about 4,600 tokens, and those sat at the start of every request in a run. You pay for it on every turn, so small cuts there repeat many times.
Repetition is the quiet cost
One block of text in one of our hook messages was 964 bytes. A single real session received it 50 times, about 48 KB in total. No single copy looked large. The sum did.
Pictures cost by size, not by content
A 900 by 300 screenshot of text cost 363 vision tokens when we sent it as a picture. The text written in it, recognised and sent as words, cost 27. The model can read the same words from either. The picture cost about thirteen times more for nothing.
A working day, in order of cost
From our own sessions, the biggest spenders are usually these, from most to least:
- Tool results. Files read, long command output, search hits.
- The growing history. Every earlier turn, resent.
- The fixed start. Instructions and lists, sent every time.
- Repeats. The same hint or block, delivered again and again.
- What you type. Usually the smallest part.
This ordering comes from what we saw. It will differ for you, so measure before you cut. Our later article "Measuring token savings honestly" shows how.
What to do about it
You do not need a tool to begin.
- Ask for less. "Show only the lines around the error" costs far less than "show the file."
- Start fresh when the topic changes. A new session drops the old history.
- Prefer text to pictures when the picture is mostly words.
- Cut at the source. If something repeats, stop it from being sent. That beats compressing it afterwards.
The next two parts of this series show how we do the last point, and how we fold old turns into short summaries.
Glossary
- Token: a small piece of text a model reads or writes. Roughly four letters of English.
- Context window: the most text a model can hold in view at once.
- Cache: a service feature that reuses work on a request start it has seen before, for a lower price.
- Prefix: the fixed start of a request, the same each time.
- Vision token: a token charged for an image. The count depends on the picture's size.
- Tokenizer: the program that splits text into tokens.
Try it
- Count your own repository. mokei is our line counter. It counts lines in 40 languages and can print an estimated token total per language with its
--tokensoption. Run it on a project you work on and see which language costs the most to put in a prompt. - See what a context proxy does. ctxd sits between an agent and its model and folds old history into summaries. Its project page explains the four-letters-per-token estimate it uses.
- Do the taxi test. Next time you use an assistant, note how long the first answer takes and how long the twentieth takes. If the twentieth is slower, you have felt the meter running.

Comments
No comments yet.
Log in to comment.