Open Agent School · Public worked example
Prompt Caching: meaning and example
Welcome! Take one idea with you today.
Prompt caching reuses computation for an unchanged beginning of a rendered prompt. It often preserves compatible key-value attention state from earlier requests. The matching prefix must be exact under the serving system, including relevant instructions, tools and settings. The model still processes new input and generates an output.
Picture it: A synthetic print-shop assistant sends 1,000 stable instruction tokens and 200 new order tokens. Only the first 800 stable tokens match a retained compatible entry. The operator wants to call this an 80% whole-request hit; you need to distinguish prefix coverage from total input coverage.
What is easy to mix up?
A hit reuses compatible input computation, not the final response. All input still occupies context. Sampling, changed suffixes and current instructions can produce different outputs.
Teaching example by Open Agent School. Source: OpenAI - Prompt caching and rendered-prefix identity.