Prompt Caching
Also called: context caching · prefix caching
Prompt caching is a provider feature that stores the processed form of a repeated prompt prefix so later requests starting with the same content are served faster and at lower input cost.
An agent re-sends a lot of the same text on every turn: the system prompt, tool definitions, project instructions, and the growing conversation history. Processing that text from scratch each time wastes compute. Prompt caching lets the provider keep the intermediate state computed for a prefix and reuse it when a later request begins with exactly the same tokens.
Major model providers offer some form of it, under names such as prompt caching or context caching. Cached input is typically billed at a discount and is faster to process, though the exact discount, cache lifetime, and minimum size vary by provider and change over time, so check current documentation rather than assuming numbers.
For long-running agents this is one of the most effective cost and latency levers, and it changes how you should structure prompts: put stable content first, volatile content last.
How it works
Caching works on prefixes: the request is compared token-by-token from the start against previously processed content, and everything up to the first difference can be reused. Some providers cache automatically; others require you to mark cache breakpoints. Cache entries expire after a period without use. Any edit early in the prompt, such as inserting a timestamp near the top or reordering tools, invalidates everything after it.
Example
A coding agent's prompt is laid out as: system instructions, tool definitions, repository guide, then the conversation so far. Each turn appends new messages at the end, so the first several thousand tokens are identical and served from cache. If someone later adds the current time to the top of the system prompt, every request becomes a cache miss.
Common misconceptions
FAQ
What is prompt caching?
How do I get a higher cache hit rate in an agent?
Does prompt caching change the model's output?
Last checked: 2026-09-20