{
  "id": 2396334,
  "title": "Claude Prompt Caching: Why Agent Loops Miss the 20-Block Lookback",
  "url": "https://urgent.news/2026/08/21/claude-prompt-caching-why-agent-loops-miss-the-20-block-lookback",
  "topic": "ai",
  "section": "AI",
  "published": "2026-08-21T15:25:29.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/ji_ai/claude-prompt-caching-why-agent-loops-miss-the-20-block-lookback-d36"
  },
  "original_language": "en",
  "account": "Claude Prompt Caching can fail when an agent is looping, due to a 20-block lookback window. Each turn appends 1 thinking block, 1 text block and N tool_use blocks. For an agent with 8 parallel tool calls, that's 18 blocks per round trip. Two turns make 36 blocks past the cached point, causing a silent miss.\n\nThe issue isn't with the prompt itself - cache lookup is limited to 20 blocks. If the previous block is more than 20 blocks away, the cache lookup fails and the API treats the request as cold. Chat apps don't see this because they don't have loops.\n\nTo fix this, place multiple breakpoints throughout the message list, spaced about 15 blocks apart. Use 4 breakpoints total across tools, system and messages, spending 1 on the system block and rotating the other 3. Each breakpoint acts as both a write and a read point, ensuring a prior entry is always found within 20 blocks.",
  "summary": "Your agent starts a run with cache_read_input_tokens at 40K and climbing. Twelve tool calls later, reads drop to zero and cache_creation_input_tokens jumps to the full conversation length — on every single turn. Nothing in your prompt changed. No timestamp, no reordered tool, no model switch. The prefix is byte-identical. You just hit the 20-block lookback window, and it is the single most…",
  "key_points": [
    "Claude Prompt Caching limited to 20 blocks",
    "Agent loops exceed 20-block lookback window",
    "Breakpoints spaced 15 blocks apart fix issue"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}