Trimming your agent's context saves 19–36% — until you price the cache, and then it costs up to 116% more
Zerui Yang, Miaomiao Dong, Quan Xue, Chaorui Zhang, Xuanyu Zheng, Xiyuan Wang, Haolin Ruan, Xueyan Niu, Guangcheng Song, Weixi Zhang, Wei Han, and Bo Bai treat context management as a measurement problem and run more than 20,000 agent executions with open models on SWE-bench Verified, SWE-bench, and Loc-Bench, accounting separately for uncached input, cached input, and output tokens. Three findings come out. First, injecting retrieved code into the agent's context reduced read and search commands by 18–34% but increased total cost by 33–42% when cached input is priced at one tenth of uncached input, with no measurable improvement in task resolution. Second, removing old tool observations cuts both ways: the same technique saves 19–36% with no cache discount but increases cost by 38–116% once a tenth-price cache is in play, because editing the history invalidates the prefix everything after it was reusing. Third, shorter prompts do not guarantee cheaper runs, since agents respond to a thinner context by taking more steps. The authors add a methodological warning that lands squarely on anyone benchmarking this themselves: concurrent experiments can share cached prefixes, which distorts cost comparisons between conditions.
Why it matters
Nearly every context-management technique in circulation — summarize the history, drop old tool outputs, prune the transcript — was designed against a mental model where tokens cost one price. With prefix caching at a tenth of the rate, the economics invert, because every edit to the middle of a conversation throws away the cached prefix for everything downstream. The sign of the effect flips, not just the magnitude, and a 38–116% increase is not a rounding error on a technique teams adopt specifically to save money. The retrieval finding is the one that should sting: injecting the right code genuinely reduced the agent's searching by up to a third and still cost more without resolving more tasks, which means "the agent did less work" and "the run was cheaper" have come apart. And the shared-prefix warning explains a class of confusing benchmark results people have been quietly attributing to noise.
What to do
Re-measure every context-trimming technique you run against your provider's actual cached and uncached rates, because if you validated it before prefix caching was priced in, you validated it under economics that no longer hold. Prefer append-only context management — add at the end, avoid rewriting history — since anything that mutates the middle of the transcript invalidates the cache for everything after it. Stop treating prompt length as a cost proxy and measure dollars per resolved task, given that shorter prompts here routinely produced more steps. And when you run comparisons, isolate conditions in time or in separate accounts so concurrent runs cannot share a cached prefix and make one arm look cheaper than it is.
More from November 21, 2026
- Thinking Machines ships a 26.4B looped transformer that runs in 20GB — the middle layers execute three times per token
- Gemini API keeps tool schemas out of context until the model asks — names and descriptions stay, parameters do not
- LangChain puts every agent tool call behind one URL — identity, deny policies, approval gates, and a trace per call
- Databricks watched 80,000 pipeline incidents and found over half need company-specific knowledge to triage
- OpenAI bills idle voice sessions at $0.02 a minute — but only over WebRTC, and only while inference is paused
- AMD and Unsloth route 100+ agentic apps to an NPU — the CPU and GPU stay free for everything else
- Models saturate the evaluations they write for themselves 65% of the time — and still fail the held-out task
- Claude closed a 23-year-old black hole calculation — six weeks of background agents, then verified in Lean
- GAO got viable attack plans out of all four major chatbots in under 12 hours — using publicly known bypass techniques
Related
- Token caps cost 20 points of task resolution — and telling the agent about its budget buys nothing at all November 19, 2026
- Put cyclomatic complexity in the agent's context and it refactors on its own — tests passing was never the whole signal November 20, 2026
- OpenAI publishes its own agent numbers: 46% on two-to-four-hour tasks, 79% on monitoring, 25% on serving code November 20, 2026