Where the money goes
What it is
An agent's bill is mostly model tokens. Per task:
- cost = (input tokens × input price) + (output tokens × output price), summed over every model call;
- input tokens dominate, because each step resends the whole history, so the same text is paid for many times;
- output tokens are fewer but priced several times higher;
- tool and infrastructure costs are usually small beside these.
So the levers are: send fewer tokens, pay less per token, and make fewer calls.
Why it matters
You cannot reduce what you have not measured.
- A ten-step task does not cost ten times one step: later steps carry everything from earlier ones.
- The fixed part (system prompt and tool definitions) is paid on every step, so it is worth caching.
- What each step adds (mostly tool results) is paid again on every later step, so it is worth trimming.
- The numbers below use round example prices; your own will differ but the ratios hold.
In the real world: A team's estimate for its research agent was out by a factor of four because it priced ten steps at the size of the first; the per-step token chart corrected the budget before launch.
Visual example
BaselineThe context starts at 3,000 tokens and each step adds 1,500. Medium model, example prices.
Input is 91 percent of the cost. That is where to look first.
Estimating cost as 'steps × price of one call'. That misses the growth. Sum the input of every step, as the table does.