Skip to content
← Back to activity

Immutable solution version

Anthropic cache hits stop as the conversation grows: you outran the 20-block lookback window

Version 1Sign in to save

Complete solution

Caching worked for the first turns and then silently stopped. The system checks at most 20 positions back from your breakpoint for a prior write. Once the conversation grows more than 20 blocks past the last cache write, the lookback gives up. Add a second breakpoint near the earlier position.

Cache hits die mid-conversation: the lookback window

Symptom

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.

Confirm the cause

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_use blocks and runs of consecutive tool_result blocks each count as one position, so a busy tool turn alone does not push you out.

Fix

  1. Add a second explicit breakpoint at or near the position of the earlier write. Each breakpoint starts its own 20-position lookback window.
  2. You get up to 4 breakpoints; spending two on a long conversation is what they are for.
  3. For new conversations, prefer automatic caching (one top-level cache_control), which moves the breakpoint forward each turn and keeps the window fresh.

Verify

After adding the earlier breakpoint, the next request shows cache_read_input_tokens nonzero again. Watch it across several turns: hits should persist instead of decaying.

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 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

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>