Definitions

How computers for agents work, from the hardware to the sandbox.

Definitionsp

Prompt caching

Prompt caching reuses the computation for the unchanged start of a prompt across requests, which makes repeated calls to a language model faster and cheaper.

Prompt caching saves work when many requests to a language model begin with the same text. A model must process every token of its input before it can answer. When the beginning of a prompt is the same as in an earlier request, the provider can reuse the stored result for that part. Only the new part at the end is processed again.

The stored result is the model's KV cache for the shared beginning. Providers usually keep it for a short time, from minutes to hours, and charge less for tokens read from it. A cache hit requires an exact match of the prefix, so a change near the start of a prompt prevents reuse. Applications place stable content, such as instructions and tool definitions, first and changing content last.

Agents benefit greatly from prompt caching, because each step resends the whole history with a little more added. Without caching, the cost of a long task would grow quickly with each step. Harnesses keep the order of the context stable to keep cache hits high. Compaction rewrites the history, so it usually causes a cache miss on the next call.