Why coding agents reread context
A coding agent does not simply take one prompt and return one answer. It reads a codebase, calls a tool to search files, adds the tool’s results to the context and sends that context back to the model. It may then run tests, receive an error, call another tool and repeat the process. If a task makes T tool calls and begins with N tokens of context, the model’s cumulative input reads can grow on the order of N×T. Longer sessions and more frequent tool calls drive up the total. That means a high token count does not necessarily represent newly generated code or answers. Diogo Almieda, Typesafe’s co-founder and CEO, built a simulator using Fable 5 pricing and replayed real coding traces from NVIDIA’s Open-SWE-Traces. In that simulation, output tokens used to generate code and replies accounted for 9% to 18% of the total bill. Developer Martin Alderson simulated a 100-turn Opus 5 session with a 60,000-token context and found that about 76% of the bill came from cache reads. The article says that, in real coding-agent workloads, most token consumption can come from repeatedly reading recent conversation history.How KV caching changes inference costs
The first stage is prefill. When a model initially reads a codebase, GPUs perform matrix operations that turn the text into intermediate states, or activations. Those states are stored in memory as a KV cache. If the same context is supplied again, the model can reuse the cached information instead of repeating the original computation. The second stage is decoding, when the model generates output tokens. The article says this stage involves relatively little computation but requires substantial data movement from high-bandwidth memory, or HBM. Memory bandwidth, rather than raw compute, becomes the bottleneck. It links this constraint to API pricing, where output tokens often cost five times as much as input tokens. The third stage is a tool call. When an agent pauses generation to run grep or execute a script, its calculated KV cache remains in memory. The article argues that keeping those bytes in memory for a few seconds uses neither compute nor memory bandwidth. Yet once the agent resumes, an API can charge for reading that cache by token. Almieda described the charge as a pricing decision rather than a technical necessity. The article also points to Claude API documentation, which excludes cache-read tokens from input rate limits. It interprets that policy as evidence that cache reads consume relatively little of the provider’s constrained compute resources. OpenAI, it adds, offered automatic prefix caching for free for more than a year before introducing a 1.25-times premium for cache writes with GPT-5.6. That distinction helps explain Mihalcea’s $100,000 figure: it is an API-list-price equivalent, not a measure of Anthropic’s actual hardware costs. The article calls the fee charged for cache reads after tool calls a cache tax for customers paying by API usage. Subscribers, by contrast, pay a fixed $20 or $200 per month. Still, subscriptions are not costless to serve. SemiAnalysis estimated in October that subscriptions represented about 10% of Anthropic revenue but consumed more than 40% of its inference compute. The article says heavy users who reach their plan limits may still cost the provider more than they pay.Speculative decoding puts idle compute to work
KV caching reduces the work involved in repeatedly reading input, but output generation still faces a memory-bandwidth bottleneck. The second technique Orosz cited is speculative decoding. A fast, smaller model or a dedicated predictor proposes several upcoming tokens. A larger model checks those guesses together in one forward pass. Accepted tokens can be used immediately; incorrect predictions must be generated again. Because decoding is limited by memory bandwidth, a GPU’s compute cores may not stay fully occupied. Speculative decoding uses some of that otherwise idle capacity to verify several candidate tokens at once. The article says code is particularly suitable for prediction: it has fixed syntax, recurring variable names, function signatures that can be reused from context and small, structured edits to existing code. If predictions are accepted, generating code can require fewer rounds of memory movement. Taken together, the techniques offer one explanation for the gap between subscription allowances and API-equivalent prices. KV caching reduces the cost of repeatedly processing input context; speculative decoding can improve the efficiency of generating code. The article’s broader point is that token totals and API list prices alone do not capture the cost of serving an inference workload. Cache reuse and generation efficiency also matter.Different cost strategies for users and companies
For individual developers, the article argues that a flat-fee subscription can remain attractive. Whether the plan costs $200 a year for Pro or $200 a month for a top tier, providers may trade low marginal serving costs for retention and engagement with their ecosystems. A dashboard showing billions of tokens does not mean the provider incurred an equivalent amount at API list prices. Teams building AI agents should be cautious about smart routing: sending difficult tasks to Opus and simpler steps to the cheaper Sonnet. KV caches cannot be shared across different models. In the article’s example, an Opus 5 session has a 100,000-token context and needs to generate only 1,000 more tokens. Switching models still requires writing that entire context into the new model’s cache. The cited calculation says the supposedly cheaper step can cost nearly three times as much, while also using a less capable model. For long-context coding agents, the cheapest model by token price may not yield the cheapest task. Cache loss from each model switch is part of the bill. The article’s proposed alternative is to use subagents for work that does not need to inherit the main agent’s context. For instance, a subagent could search 50,000 tokens of logs in a codebase and return a distilled 200-word report, limiting growth in the main context. For companies running agents at scale, the article discusses open-weight models, self-hosting and specialist inference clouds. Almieda’s argument is that companies running large volumes of agents through APIs may be handing closed providers the savings created by KV caching. The article says several technology companies have cut costs or moved toward their own infrastructure over the past year: Uber reduced per-token costs by 50% through architectural optimization, AT&T by 56%, and Pinterest by 90%. Fintech company Revolut instead bought 56 NVIDIA B200 bare-metal servers to run models itself. It also names Modal, Fireworks and Baseten as inference-cloud providers used by teams running open-weight models, including DeepSeek 4.1 Flash, GLM 5.3 and Kimi K3.1 Pro. The article’s position is that controlling the inference stack gives companies a way to retain savings from cache optimization rather than passing them to a closed API provider.Cache-read prices move lower
The article says Fable 5.1 cut cache-read pricing from $1 per million tokens to $0.25. Fable 5.2, released on November 9, lowered the price again, to $0.20. Measured against the Fable 5 era, the cited prices represent an 80% decline in cache-read costs in just over two months. Anthropic has said that lowering cache-read prices alone could reduce overall usage costs for complex coding and agent tasks by up to about 45%. The figure highlights the importance of caching for coding agents that repeatedly call tools and reread context. The article concludes that inference engineering is becoming practical knowledge for software engineers, which could narrow the advantage firms gain from an information gap. The source article was written by Solomon and published by the WeChat account Xinzhiyuan. Its listed references include posts by Gergely Orosz and Vlad Mihalcea on X, two articles in The Pragmatic Engineer about inference engineering, and an article by CompleteSkeptic: https://x.com/GergelyOrosz/status/2123795984002232634 https://x.com/vlad_mihalcea/status/2123753559191617993 https://x.com/CompleteSkeptic/article/2097738214589215173 https://newsletter.pragmaticengineer.com/p/inference-engineering-for-software-engineers https://newsletter.pragmaticengineer.com/p/what-is-inference-engineering

This article was originally published by Bit.Fan. For more cryptocurrency news and market insights, visit www.bit.fan.


