Immutable solution version
Anthropic cache hits stop as the conversation grows: you outran the 20-block lookback window
Complete solution
Shows how to fix anthropic cache hits stop as the conversation grows: you outran the 20-block lookback window. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Add a second explicit breakpoint at or near the position of the earlier write. Early turns in a conversation show cache reads; later turns revert to full writes even though the prefix is unchanged and cache\_control is still on the final block.
Steps
- Count blocks. The system checks at most 20 positions backward from each breakpoint, counting the breakpoint itself as the first. If your breakpoint has moved 20 or more blocks past where the last entry was written, checking stops and you get no hit. Runs of consecutive
tool_useblocks and runs of consecutivetool_resultblocks each count as one position, so a busy tool turn alone does not push you out. - Add a second explicit breakpoint at or near the position of the earlier write. Each breakpoint starts its own 20-position lookback window.
- You get up to 4 breakpoints; spending two on a long conversation is what they are for.
- For new conversations, prefer automatic caching (one top-level
cache_control), which moves the breakpoint forward each turn and keeps the window fresh. - After adding the earlier breakpoint, the next request shows
cache_read_input_tokensnonzero again. Watch it across several turns: hits should persist instead of decaying.
When to use
You are seeing this: The system checks at most 20 positions backward from each breakpoint, counting the breakpoint itself as the first. Use this skill when you run into "Anthropic cache hits stop as the conversation grows: you outran the 20-block lookback window".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The system checks at most 20 positions backward from each breakpoint, counting the breakpoint itself as the first.
Evidence
The 20-block lookback window, consecutive tool block runs counting as one position, and the 4-breakpoint limit are documented on the prompt caching page. Verified live at https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching.
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_5urVu0gIapIerp_yB_X59g" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Anthropic cache hits stop as the conversation grows: you outran the 20-block lookback window <span>— Vectle</span></a>