Click any words you think contain an error. Click again to unmark.
The snippet shoves growing tool results into the system prompt, which destroys prompt caching and dumps tool outputs into the lost-in-the-middle trough at the same time.
Picture a noticeboard at a coffee shop with a sign that says 'this stays the same all day.' If the barista starts pinning every customer's receipt to that board as the day goes on, two things break. The 'stays the same' promise is gone, so any system that was relying on it stops working. And the board fills up so fast that the original menu, the thing customers actually need, is buried under three months of receipts. The system prompt is that noticeboard. Tool results are the receipts. They belong in a different place, and old ones should come down when they are no longer useful.
Detailed answer & concept explanation~6 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
State both errors and their interaction. Error one: appending to the system prompt destroys the cache key, so the cache-rate claim is structurally impossible. Error two: tool results in the system block push real conversation into the lost-in-the-middle trough. Add the third issue, missing eviction, and explain the summarize then evict pattern. Close with the right structural design: byte-stable system prompt, tool results threaded in the conversation tail, eviction at the wrapper or reducer layer.
Real products, models, and research that use this idea.
- Anthropic's Claude tool-use format threads tool_result blocks directly into the conversation, with the system prompt reserved for stable persona and tool schemas.
- OpenAI's Responses API places tool_calls and their outputs as separate message events in the response stream, never as system-prompt content.
- LangGraph stores tool observations in typed state with explicit reducer functions for eviction, separating durable state from prompt text.
- Letta (formerly MemGPT) exposes memory-management tools the model can use to move observations between in-context and out of context tiers, rather than letting the prompt grow.
- Cursor and Claude Code summarize older tool results into compact references once subsequent steps no longer need the raw output, freeing budget for new observations.
What an interviewer would ask next. Try answering before peeking at the approach.
QIf you wanted some tool results to be durable across many turns, what is the right way to do it without breaking the system-prompt cache?
QWhat goes wrong if you fix the caching issue by adding a cache breakpoint after the mutating section?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Conflating 'I want this content to be cached' with 'put it in the system prompt', caching only works while the block is byte-stable, which a growing tool log never is.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.