# Prompt caching

Prompt caching is reusing a model's work on a repeated prompt prefix, so later calls that
start with the same prefix cost less and return faster. The output doesn't change: a cached
request gets the same kind of response it would get without the cache.

It exists because agents resend the same text constantly. Every call in an agent loop carries
the system prompt, the tool definitions, and the conversation so far, and only the end of the
prompt is new. Without a cache, the provider processes that whole prefix again on every call.

The provider stores the processed state of a prefix and reuses it when a later request begins
with exactly the same content. The match runs in order from the start, so a change anywhere
invalidates everything after it. With one provider the order is tools, then the system prompt,
then messages, so changing a tool definition invalidates the whole cache. That is why stable
content goes first and anything that varies, such as a timestamp or user-specific data, goes
last. Some providers cache automatically; others let you mark where a cached prefix ends.
Writing to the cache can cost more than normal input, and reading from it costs much less.
Entries expire after a period without use, and a prompt below a minimum length isn't cached at
all.

Semantic caching is a different thing: it stores a response and returns it for a similar
question, while prompt caching still generates a fresh response. The common failure is a cache
that quietly stops hitting. A value near the top of the prompt changes on every call, the hit
rate drops, and cost and latency rise with no change to what the agent says.

---

Source: https://tessary.ai/answers/prompt-caching
All concepts: https://tessary.ai/answers
From Tessary, agent reliability for AI agents in production: https://tessary.ai
