Don't Break the Cache: An Evaluation of Prompt Caching for Long-Horizon Agentic Tasks
This paper presents a comprehensive evaluation of prompt caching across three major LLM providers for long-horizon agentic tasks, demonstrating that strategic caching techniques—such as excluding dynamic tool results and managing prompt structure—can reduce API costs by 41–80% and improve time to first token by 13–31% compared to naive full-context caching.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are hiring a brilliant but expensive research assistant to solve a complex mystery. This assistant needs to read a massive instruction manual (the "system prompt") before they start working. As they work, they make dozens of phone calls to different sources, get answers, and write them down in a notebook.
Every time they make a new phone call, they have to re-read the entire instruction manual from the very first page to remember what to do. This takes a lot of time and costs a lot of money because the assistant charges by the page they read.
"Prompt Caching" is like giving that assistant a magical highlighter. If the instruction manual hasn't changed, the assistant can skip re-reading the first 90% of the book and jump straight to the new part where the phone call results are. This saves time and money.
However, this paper asks a tricky question: Does this magic highlighter always work, or can we mess it up?
The researchers tested this with three major "assistant" companies (OpenAI, Anthropic, and Google) using a benchmark called DeepResearch Bench, where agents go on long, multi-step web searches to answer hard questions. They tried three different ways of using the highlighter:
- The "Naive" Approach (Full Context): Highlighting everything, including the new phone call results.
- The "Sticky Note" Approach (System Prompt Only): Highlighting only the instruction manual, but leaving the new phone call results un-highlighted.
- The "Clean Break" Approach (Exclude Tool Results): Highlighting the manual and the phone calls, but putting a special "stop" sign after every new result so the highlighter doesn't accidentally grab the next person's messy notes.
What They Found
1. It Saves a Lot of Money (The "Wallet" Win)
No matter which method they used, the magic highlighter saved a huge amount of money. Depending on the company, they saved between 41% and 80% on the bill.
- Analogy: It's like realizing you don't need to buy a new library card every time you walk into the library; you just use the one you already have.
2. Speed is Tricky (The "Traffic" Problem)
While saving money was easy, saving time was harder.
- The Surprise: Sometimes, highlighting everything (the Naive approach) actually made the assistant slower.
- Analogy: Imagine a delivery driver who tries to memorize the address of every single package they deliver. If they try to memorize a package that is only being delivered once and never again, they waste time memorizing it. When the next package comes, they have to "un-memorize" the old one to make room for the new one. This "writing to memory" slows them down.
- The paper found that if you only highlight the stable parts (the instruction manual) and leave the messy, changing parts (the phone call results) alone, the assistant stays fast.
3. The "Don't Break the Cache" Rule
The biggest lesson is about where you draw the line.
- If you put dynamic, changing information (like "Current Time: 2:00 PM" or "User ID: 123") inside the instruction manual, the magic highlighter breaks. The system thinks the manual has changed, so it stops highlighting and starts reading from scratch.
- The Fix: Keep the instruction manual pure and static. If you must include changing info, put it at the very end of the manual, like a sticky note on the last page. This way, the first 99% of the manual is still highlighted and reusable.
The Bottom Line
For companies building AI agents that do long, complex tasks:
- Yes, use prompt caching. It will drastically cut your costs.
- But, be smart about it. Don't just turn it on for everything.
- The Best Strategy: Only cache the stable "instruction manual" (System Prompt). Let the changing parts (tool results) flow freely without being cached. This gives you the best mix of low cost and fast speed.
If you try to cache the changing parts, you might end up paying for the "writing" of the cache without getting the "reading" benefits, which can actually slow your system down.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.