Conversation sent to the model
Tokens per request
What just happened
Same order, different design
| Design | Calls | Tokens / order | $ / order | $ / month | $ / month, no cache |
|---|
Every time an AI agent calls a tool, the whole conversation goes back to the model. Watch the tokens and the cost pile up for an order-processing agent, and see what prompt caching does and doesn't save.
AI models are stateless. They remember nothing between calls. So when an agent loops (think, call a tool, read the result, think again), it has to send the whole conversation back to the model every time. Each tool call makes the next request bigger, and the cost compounds.
↺ Then the whole conversation, including every earlier result, goes back to the model, until the agent is done.
A fictional order-processing agent is asked to process a 10-line sales order. With one tool call per turn it makes 13 model calls:
get_order.get_order_line once per line. Each call resends everything before it.submit_fulfilment and splits the order across two warehouses.| Prompt tokens | Every token sent to the model, across all calls: the whole conversation, every time. It splits two ways: input (the new bit) and cache read (everything sent before). |
| Input tokens | The new bit of each request: what was added since the last call (the model's last reply plus the new tool result). Not in the cache yet, so billed at the full input price. |
| Cache read | Everything that was already sent on the previous request. The provider serves it from its cache, billed at a fraction of the input price (0.1× by default, editable on the Simulator tab). |
| Output | Tokens the model generates: its reasoning text and tool calls. Priced higher than input, but small in an agent loop. |
| Total tokens | Prompt tokens + output for the whole order. Caching does not change this number: cached tokens are still sent and counted, they are just billed at a lower price. Caching changes the cost, not the token count. |
| Cost this order | What this one order cost, with the no-cache cost underneath for comparison. |
| Conversation panel | Each message card lights up when it is resent. The coloured left edge shows whether that message was read from cache or sent as new input on the latest request. |
| Tokens per request | One bar per model call. The bars get longer each call: that is the compounding. |
| Amplification | Tokens billed ÷ unique content. On average, how many times each token in the conversation was paid for. |
In your telemetry (OpenTelemetry spans, API usage logs) you will usually see the new bit as input tokens and the rest as cached tokens. The simulator uses the same split:
| Simulator | What you typically see in usage data |
| Input tokens | Uncached input: the new bit added since the last request. Anthropic-style APIs report it as input_tokens. |
| Cache read | Tokens served from cache. cache_read_input_tokens (Anthropic-style) or prompt_tokens_details.cached_tokens (Azure OpenAI / OpenAI). |
| Prompt tokens | Input + cache read. Azure OpenAI reports this total as prompt_tokens, with cached tokens as a subset of it. |
| Output | output_tokens / completion_tokens |
gen_ai.usage.input_tokens includes cached tokens, so check whether your spans carry separate cache attributes. Hover any bar on the Simulator tab to see the split for that request.Fetching each order line in its own turn means 11 trips round the loop. Asking for all 10 lines in one turn cuts the agent to 4 model calls. It's the same lesson as chatty vs. coarse-grained APIs.
Each request starts with everything the previous request sent, so the provider serves that part from cache and only the new bit is billed at full price. Over a whole run, every token is billed as input exactly once; every resend after that is a cache read. Caching makes the resend cheaper, but it does not make it go away: the tokens are still sent and still counted. The prefix must match exactly, so anything that changes early (a timestamp in the system prompt, for example) breaks the cache for everything after it.
Every token a tool returns is paid for again on every later call. Passing a raw API response (links, audit trails, metadata) straight to the model can multiply the cost of the whole run.
Select/Compose or a Function to return only the fields the agent needs.get_order_with_lines tool beats 11 round trips.Space play/pause · → step · R reset| Design | Calls | Tokens / order | $ / order | $ / month | $ / month, no cache |
|---|
I cover this kind of thing on the podcast and in the playbook. If it was useful, share it with whoever owns your AI bill.