Sentience concept · Cost and context

Context cost

Last reviewed
2026-10-12

Context cost is the portion of an agent’s model usage cost attributable to supplying accumulated context, such as conversation history, instructions and tool results, across successive turns. Cached inputs may reduce the price of repeated context, but they do not eliminate its cost.

A model call is priced per token, and a single call is cheap. An agent does not make a single call. It makes dozens, and each one carries everything the agent has accumulated so far: its instructions, the tool definitions, and every earlier step and result. The model has to be given that material again on every request, because it keeps nothing between calls. Context cost is the price of that re-reading.

Why it compounds

Suppose each step of an agent adds a fixed amount of new material to its context. The first request carries the instructions. The tenth carries the instructions plus nine steps of history. The twentieth carries nineteen. Billing is linear in tokens, but the tokens sent grow with every step, so the total sent over a run grows roughly with the square of the number of steps. Most of what an agent pays for on a long run is material the model has already seen.

That is a statement about billing, not about computation. How hard the model works on a long input is a separate matter, and it is not what a provider’s invoice measures.

Caching changes the price, not the existence

Model providers offer prompt caching to make repeated context cheaper. A request that begins with exactly the same content as a recent one can read that content from a cache at a reduced rate instead of paying full price. The details matter:

  • Reads are cheaper, not free. Anthropic’s standard cache read costs a tenth of the base input price, and less on some newer models.
  • Writes cost more. Writing content into Anthropic’s cache costs 1.25 times the base input price for the default five-minute lifetime, and twice the base price for a one-hour lifetime.
  • Caches expire. Anthropic’s default cache lasts five minutes, refreshed each time it is used. OpenAI, which caches automatically, keeps a cached prefix eligible for reuse for 30 minutes on its newer models.
  • Only an exact prefix counts. A cache hit requires the earlier content to be identical. Anthropic’s documentation notes that modifying tool definitions invalidates the entire cache, and a study of caching on long agent tasks found that timestamps, session identifiers and user-specific details in a prompt quietly break it.

The same study measured caching reducing API costs by 41 to 80 percent across providers on long agentic tasks. That is a large reduction, and it is not the same as zero.

A worked example

The run below is illustrative. Prices are Anthropic’s published standard rates for Claude Sonnet 5.5 as of October 2026: $2 per million input tokens, $2.50 per million for five-minute cache writes, $0.10 per million for cache reads and $10 per million output tokens. Everything else is an assumption, stated so it can be changed.

Assumptions: a 20-step run; 5,000 tokens of instructions and tool definitions; each step adds 2,000 tokens of new context; each response is 300 tokens; every request arrives within five minutes of the last.

Without cachingWith caching
New content, sent once (43,000 tokens)$0.0860$0.1075 (written to cache)
Re-supplied context (437,000 tokens)$0.8740$0.0437 (read from cache)
Output (6,000 tokens)$0.0600$0.0600
Total$1.0200$0.2112
Context cost as a share of the total86%21%

Two things stand out. Without caching, most of the run’s cost is re-reading. With caching, the re-read context still makes up 437,000 of the run’s 486,000 tokens, but its price falls by roughly 95 percent at this model’s rates.

Now change one assumption. If the agent waits more than five minutes before step 11, for example for a person to approve an action, the cache expires. Step 11 would have read the 23,000 tokens of accumulated context from the cache for $0.0023. Instead it has to write that same context into the cache again, at the cache-write rate, for $0.0575. Nothing new is added: the extra $0.055 or so is the price of rewriting a prefix the run had already cached instead of reading it at the discounted rate. That one rewrite costs more than all the cache reads in the run put together. A timestamp in the instructions would do the same on every request.

Token share and cost share

The example also shows why the share of tokens and the share of cost can tell very different stories. In the Claude Code sessions Sentience Governor has measured, cached reads usually make up the large majority of all tokens, often well over 90 percent. Because cached reads are cheap, their share of the cost is much smaller. Neither figure is a universal property of agents. Both depend on the workload, the model’s prices and how well the cache is used.

Context cost, context window, context rot

Context window. The limit on how much context fits in one request. Context cost is what the context in every request costs, whether or not the window is full.

Context rot. The tendency of models to use long inputs less reliably. It is a quality effect, not a price. A long context can cost more and also be used less well.

AI agent cost. The total cost of operating an agent, including tools, infrastructure and retries. Context cost is one component of its model usage.

How Sentience Governor measures it

Sentience Governor breaks an agent’s token usage into four classes, cache reads, cache writes, uncached input and output, which reconcile exactly to the total. On Claude Code sessions it reads the session transcript at the end of a run and attributes token usage to each model turn, including the cached context that a turn re-read. It reports tokens, not money: pricing depends on the model and the provider’s current rates.

Where the concept stops

Context cost describes where an agent’s model spend goes, not whether the spend was worthwhile. A run with high context cost may be exactly what the task needed, and a cheap run may have failed. It also covers only model usage. Tools, infrastructure and the people who review an agent’s work are part of AI agent cost, not of context cost.

Often confused with

Related entries

Bridges

See in practice

Sources

  1. Anthropic, Claude API pricing
  2. Anthropic, Prompt caching
  3. OpenAI, Prompt caching
  4. Lumer et al., Don't Break the Cache: An Evaluation of Prompt Caching for Long-Horizon Agentic Tasks
  5. Sentience Governor, source and documentation
Return to the glossary