Every chapter's agent loop resends the whole growing conversation on each turn with no cache_control mark anywhere in the repository, so on Anthropic nothing is ever read from the prompt cache.
The compaction chapter teaches how to shrink context but never shows that the unchanged part of it can be reused at a tenth of the price.
- What to change
- Mark the end of the tools, the end of the system prompt and the newest message, on copies made at send time (a ten-line helper). Put it in s08, where context cost is the topic, and say in its README why it is safe next to compaction.
- Why it matters
- Without marks each turn pays the full input price for the system prompt, the tools and all earlier turns, although the model saw them seconds ago. A coding-agent loop returns within seconds, so a mark pays back after the first read.
- Overlaps
- Finding 2, 3 loses some of the same tokens; the totals count the larger once.
- Estimate
- about 7.7M prompt tokens per 1,000 loop calls not served from cache (estimate)
What the estimate assumes
default Anthropic target (claude-sonnet-4-6, .env.example), 9,000-token average call: about 2,000 for system plus tools and 7,000 of history (s08 compacts at 50,000 characters, about 12k tokens); about 1,000 new tokens per turn; calls seconds apart; first turns under the 1,024-token minimum lose nothing. The Anthropic-compatible hosts listed in .env.example (MiniMax, GLM, Kimi, DeepSeek) cache by their own rules: unknown, check each provider's docs. Figures are per 1,000 loop calls of one chapter run by a learner.