Shorter Prompts Cost More: The Prompt Caching Trap in Coding Agents Deleting an obsolete block from the middle of a warm coding-agent session multiplies the next turn's input cost by 5.7x to 8.0x and takes 37 to 97 more warm turns to earn back, because prompt caches from OpenAI, Anthropic and Google match strictly from token zero, according to an analysis of late-2026 frontier API pricing. A November 2026 study of 20,000+ coding-agent runs on SWE-bench Verified, SWE-bench and Loc-Bench found that dropping old tool outputs saved 19% to 36% without a cache discount but increased cost by 38% to 116% with one, while an October 2026 study measured 98% to 99% prefix-cache reuse when histories stay append-only. The break-even formula (S / D) * (w / r - 1) - 1 yields 47 turns for GPT-6.2 Sol, GPT-6.2 Astra, Claude Sonnet 5.5 and Claude Opus 5.5, 97 turns for Claude Fable 5.2 and 37 turns for Gemini 4 Neon in an 80,000-token session. A coding agent reads a 20,000-token failing build log, patches three files, and gets the tests passing. You ask for the next change. Deleting that obsolete log cuts 25% of the prompt and looks like free savings. It usually backfires. On late-2026 frontier APIs, deleting an old block from the middle of a warm session multiplies the next turn's input cost by 5.7x to 8.0x - and takes 37 to 97 more warm turns to earn back. Prompt caches across OpenAI https://developers.openai.com/api/docs/guides/prompt-caching , Anthropic https://platform.claude.com/docs/en/build-with-claude/prompt-caching and Google https://aistudio.google.com/docs/caching match strictly from token zero: cut the middle, and every surviving token after the cut loses its cache hit. Why editing the middle multiplies the bill why-editing-the-middle-multiplies-the-bill Coding agents are overwhelmingly read-heavy. Manus reported an average ~100:1 input-to-output token ratio https://manus.im/blog/Context-Engineering-for-AI-Agents-Lessons-from-Building-Manus and called KV-cache hit rate the single most important metric for a production agent. An October 2026 study of coding-agent runs https://figshare.com/articles/preprint/Break Later or Never Prefix-Preserving Context Compaction for Coding Agents/34791231 measured 98% to 99% prefix-cache reuse when histories stay append-only. Today's pricing makes breaking that prefix far harsher than older 10x cache tiers. Frontier cache reads now cost 0.05x to 0.025x base input, while cache writes add a 1.25x surcharge on OpenAI's 30-minute cache https://developers.openai.com/api/docs/guides/prompt-caching and Anthropic's 5-minute cache https://platform.claude.com/docs/en/build-with-claude/prompt-caching . Invalidating a surviving block does not move it from 0.1x to 1x - it swings every token 20x to 50x higher. The break-even math across frontier models the-break-even-math-across-frontier-models Delete D tokens ahead of S surviving cached tokens, with cache-write rate w and cache-read rate r . The edit adds S w - r - D r on that turn, while each later warm turn saves only D r . Total prompt size and dollar price cancel out completely: break-even turns = S / D w / r - 1 - 1 Only two ratios decide the outcome: how much surviving context follows the cut S / D , and the provider's rewrite-to-read spread w / r . For our 80,000-token session S / D = 2 : | Model | Read / M | Rewrite / M | Ratio | Next turn keep → cut | Break-even | |---|---|---|---|---|---| | GPT-6.2 Sol | $0.10 | $2.50 | 25x | 1.76¢ → 11.16¢ 6.3x | 47 turns | | GPT-6.2 Astra | $0.40 | $10.00 | 25x | 7.04¢ → 44.64¢ 6.3x | 47 turns | | Claude Sonnet 5.5 | $0.10 | $2.50 | 25x | 1.76¢ → 11.16¢ 6.3x | 47 turns | | Claude Opus 5.5 | $0.20 | $5.00 | 25x | 3.52¢ → 22.32¢ 6.3x | 47 turns | | Claude Fable 5.2 | $0.20 | $10.00 | 50x | 5.52¢ → 44.32¢ 8.0x | 97 turns | | Gemini 4 Neon | $0.15 | $3.00 | 20x | 2.34¢ → 13.44¢ 5.7x | 37 turns | Standard short-context rates checked November 29, 2026 OpenAI https://developers.openai.com/api/docs/models/gpt-6.2-sol , Anthropic https://platform.claude.com/docs/en/about-claude/pricing , Google https://aistudio.google.com/docs/pricing . Uses default write TTLs: 30m 1.25x on OpenAI, 5m 1.25x on Anthropic, implicit 1x on Google. Extended TTLs 12h OpenAI at 2.5x, 1h Anthropic at 2x raise break-even to 97 and 77-157 turns. Every deeper cache discount makes mid-prompt editing more expensive, not less. What the 2026 benchmarks show what-the-2026-benchmarks-show - Pruning flips from savings to a loss under caching. In a November 2026 study of 20,000+ coding-agent runs https://arxiv.org/abs/2611.22238 on SWE-bench Verified, SWE-bench and Loc-Bench, dropping old tool outputs saved 19% to 36% without a cache discount - yet increased cost by 38% to 116% with a tenth-price cache, partly because pruned agents took extra steps to recover lost context. - Clean prefixes dominate cost and latency. Across 500+ multi-turn runs on OpenAI, Anthropic and Google, a January 2026 agent caching evaluation https://arxiv.org/abs/2601.06007 found intact prefixes cut API cost by 41% to 80% and time to first token by 13% to 31% . - Batching beats per-turn trimming. The October 2026 prefix-preserving compaction study https://figshare.com/articles/preprint/Break Later or Never Prefix-Preserving Context Compaction for Coding Agents/34791231 found periodic batched masking preserved 95% to 98% prefix reuse, cutting serving cost up to 18% and completion time up to 21%. When trimming actually pays when-trimming-actually-pays 1. Leave stale logs alone on short tails. If only a few turns remain, append to the warm prefix and keep the cache hit. 2. Compact at rare boundaries, not every step. Pay the rewrite penalty once so dozens of warm turns amortize it, as Anthropic's context engineering guide https://www.anthropic.com/research/effective-context-engineering-for-ai-agents recommends. 3. Keep volatile fields at the tail. Editing tools, system text, or timestamps near token zero wipes everything after them Anthropic invalidation rules https://platform.claude.com/docs/en/build-with-claude/prompt-caching ; OpenAI prefix rules https://developers.openai.com/api/docs/guides/prompt-caching . 4. Override cache math only for hard limits. Trim immediately when you hit the context ceiling, approach a long-context pricing cliff like OpenAI's 272K-token tier https://developers.openai.com/api/docs/models/gpt-6.2-sol , where rates double , or see stale noise hurting accuracy. Verify it in your own responses: track cached tokens and cache write tokens on OpenAI https://developers.openai.com/api/docs/guides/prompt-caching , cache read input tokens and cache creation input tokens on Anthropic https://platform.claude.com/docs/en/build-with-claude/prompt-caching , or total cached tokens on Google https://aistudio.google.com/docs/caching . In a cached agent loop, shorter only means cheaper when the prefix survives. Sources and pricing snapshot sources-and-pricing-snapshot Primary sources and pricing were checked on November 29, 2026 . The worked example uses published standard short-context rates, not proprietary TheGitAI telemetry. - Provider docs & pricing: OpenAI prompt caching https://developers.openai.com/api/docs/guides/prompt-caching , GPT-6.2 Sol https://developers.openai.com/api/docs/models/gpt-6.2-sol , GPT-6.2 Astra https://developers.openai.com/api/docs/models/gpt-6.2-astra · Anthropic prompt caching https://platform.claude.com/docs/en/build-with-claude/prompt-caching , API pricing https://platform.claude.com/docs/en/about-claude/pricing · Google Gemini caching https://aistudio.google.com/docs/caching , API pricing https://aistudio.google.com/docs/pricing - 2026 empirical studies: Context Has a Price arXiv:2611.22238 https://arxiv.org/abs/2611.22238 · Break Later or Never Oct 2026 https://figshare.com/articles/preprint/Break Later or Never Prefix-Preserving Context Compaction for Coding Agents/34791231 · Don't Break the Cache arXiv:2601.06007 https://arxiv.org/abs/2601.06007 - Agent engineering notes: Manus: Context Engineering for AI Agents https://manus.im/blog/Context-Engineering-for-AI-Agents-Lessons-from-Building-Manus · Anthropic: Effective context engineering for AI agents https://www.anthropic.com/research/effective-context-engineering-for-ai-agents Try TheGitAI Every frontier model with a frontier harness. Use OpenAI, Anthropic, Google, xAI and more in one desktop app and CLI, zero config. Code, drive your browser and computer, and keep your files and memory local. Keep reading FrontierCode vs. Terminal-Bench vs. SWE-Bench: Why No Single Model Wins Compare FrontierCode, Terminal-Bench, and SWE-Bench for coding agents. See why scores differ and how to choose an LLM. No, Stanford’s NCM Won’t Kill LLMs Yet Here’s the Engineering Catch Stanford's Next-Concept Modeling promises faster generation. See what the NCM results show, what they do not, and the coding-agent tests still needed.