Cost · Caching

A First Principles Approach to AI Agent Spend

Every AI agent's spend is volume times rate. Taken apart one layer at a time, that sentence becomes the formula behind where the spend goes.

6 min read

Start with the foundational question: what is cost?

Equation 1
Cost=Volume×Rate
Volume
how many tokens: set by the work you ask for and the context it carries
Rate
the price of one token: set by the model you pick

How much you used, and what each unit cost you. AI agents are no different. An agent is AI that works through a task step by step, like a coding assistant that reads files and runs commands. The trouble is that its spend hides both halves, and most people look at only one.

What follows comes from one user’s agent usage on one model, tens of thousands of steps examined one by one. One person’s record, studied closely, is a narrow base. Treat it as a way of thinking you can test against your own numbers, not as a verdict on them.

Layer one: the rate and the volume

AI is sold by the token. A token is a word, or a fragment of one. The model reads tokens in and writes tokens out, and the provider charges for each.

The rate is the price of a token. You choose it by choosing a model.

The volume is how many tokens. It has two parts: the work you ask for, and the context that work drags along with it, the instructions, documents and conversation the model must have in front of it to do the job. The context is not a third variable beside volume and rate. It is a part of the volume, and, as the last layers show, usually the biggest part.

Layer two: the rate, by model

Equation 2
Cost=Volume×Rate of the model you pick

Take Claude as an example. Anthropic sells it in tiers, each priced per token to match what it is built for. At the time of writing: Haiku, the fastest and cheapest, for simple, high-volume work; Sonnet, the everyday workhorse; Opus, for long, complex work; and Fable, the most capable, for the hardest reasoning.

You could think of it as hiring: a quick assistant, an experienced practitioner, a senior specialist, and the best mind you can borrow. The picture is loose. A senior hire does not simply do the same job at a higher day rate. The tiers differ in capability, in speed, and in how much work a task takes them. So the price per token is not the price of the task.

That is the rate: a number you set by choosing a model, and by itself an incomplete answer.

Layer three: the volume, by kind of token

Equation 3
Cost=Σ Volume of each kind of token×Rate of that kind

To see the other half of the equation, picture a colleague on their first day, with no memory of anything. An agent works in steps, and each step is one request to the model. The volume comes in four kinds of token, and the colleague shows all four.

  • Input. You email them a task. That is new material, sent plain.
  • Output. They write back. That is what the model produces, and it carries the highest rate of the four.
  • Cache reads. You send a follow-up. They remember nothing, so before answering they must re-read the whole thread. To keep that affordable, the provider keeps your thread open on the colleague’s desk. This is the cache, and reading from the desk is quick and cheap: the lowest rate of the four.
  • Cache writes. Each new message has to be put on the desk too. That costs a little more than plain input.

If you walk away for an hour, the desk is cleared, and the thread has to be set out again.

Equation 4
Cost=r(I+mw·W+ρ·R)+rout·O
r
the model's plain input price
I
input tokens
mw
a write's multiple of plain input
W
cache writes
ρ
a read's fraction of plain input
R
cache reads
rout
the output price
O
output tokens

Write every rate as a multiple of the model’s plain input price, r, and the four kinds become one equation for a single step: I is input, W cache writes, R cache reads, O output. A write costs a multiple of plain input (m_w), a read costs a small fraction of it (ρ), and output has a price of its own (r_out).

Priced this way, each step of the agent comes out exact: the formula reproduces the measured cost of 21,456 steps to the last decimal. What it does not yet explain is what happens when steps pile up.

Layer four: how spend compounds

In school, we are taught two kinds of cost. A fixed cost stays flat however much you do. A variable cost rises in step with how much you do. Plot either, and you get a line.

Token spend is neither. Each step re-reads everything that came before it, so a long conversation does not cost its length. It costs its length multiplied by itself.

Equation 5
Tokens read≈N·C0+s·N(N−1)/2
N
steps in the run
C0
tokens of context at the start
s
tokens each step adds

Take a run of N steps. It starts with C₀ tokens of context, and every step adds s more. The first term is a charge repeated on every step, the same each time. The second is the one that compounds: step 50 re-reads everything steps 1 to 49 produced. Twice the steps costs more than twice as much.

The context, then, is not just part of the volume. It is where the volume compounds. A long conversation that carries a lot is expensive at any price per token.

Layer five: when the cache expires, you pay twice

Putting a message on the desk is meant to be a one-time cost. Sometimes the desk is cleared anyway, and the whole thread is put back at the higher price. Nothing new is bought. The same material is bought twice. We call it a break re-write.

A few things can clear the desk:

  • A long pause. The cache lasts about an hour. Leave for lunch, a meeting or the night, and it is gone. In our research, this was the most common cause by a wide margin.
  • A change to the instructions or tools the model was given, or a switch of model. The thread is no longer the one on the desk.
  • A compaction: when a long conversation is summarised to save space, the summary replaces the thread.
Equation 6
Cost=prefix reads+growth reads+routine writes+break re-writes+output+fresh input

Six lines that always add up to the whole: re-reading the starting instructions, re-reading what the session has added since, the first storing of new material, the re-buying after a break, the answers, and a sliver of fresh input. This is the formula. We built it on one model’s agent, and it tends to hold up on another’s too.

Cost equals volume times rate, with the volume taken apart into the pieces that each have an owner. None of them is the rate card.

Sources

  • 01-volume-x-rate-figures.md. One user's agent use, 30 April to 28 November 2026.