基础设施 4.0 · 优秀 2026-11-21 · 文章

Why output caching doesn't work

Sean Goedecke 把缓存 LLM 输出省钱的直觉算了账:动机成立(agent 会重复贴代码片段引用证据文档,输出 token 比输入贵得多),但他统计自己的 agent 历史发现输出 token 约 50% 是推理 token44% 是工具调用,真正可见输出只占 6%;即便乐观省掉三分之二可见输出,按 Amdahl 定律也只省 4% 总量真正可省的是那 94% 不可见部分,取决于模型能力由此解释了更贵的模型反而更便宜:单价 5 倍但所需 token 少 6 倍,总账更低替代方向是让模型输出引用由 harness 展开,只能优化可见层

打开原文回到归档

Why output caching doesn't work

Why output caching doesn't work LLM inference economics depends on caching 1 model inputs, to prevent the entire conversation history being recomputed on each message 2 . Should we cache model outputs in the same way? As it turns out, no. Why cache outputs? First, here’s why we might think caching outputs is a good idea. We cache inputs to prevent repeated work, but LLMs do a lot of repeated work in their output as well: When I get agents to write PRs I often ask them to repeat and explain relevant code snippets in the conversation Long-running agent investigations produce lots of evidence docs, but also need to quote from those docs when they respond to the user Every time I’ve played around with automated AI research I’ve asked the agent to repeat some sample model outputs so I can make my own qualitative check In all of these cases 3 I could go and read the files myself, but I don’t. Agents produce such a volume of output, and reading agent output is tiresome, so it’s better to simply ask for the key points. It’s an obvious waste of tokens 4 to repeat all of this content. In fact, it’s worse than the input caching situation, because it’s a waste of output tokens, which are significantly more expensive to produce 5 than input tokens are to ingest. How could we cache outputs? If you want to prevent this, you’d have to get the model to avoid repeating itself. For instance, you could fine-tune or prompt a coding model to output “src/script.py:12-15” instead of simply regurgitating those lines of the file. More generally, you could fine-tune a model to reference segments of its own conversation history instead of repeating them. The harness could then trivially expand those references with the actual content, so all of this is transparent to the user. Why caching outputs is probably a bad idea Unfortunately none of this is a good idea, because it only optimizes visible output . I don’t think models repeat themselves often in their internal chain of thought 6 . I can’t read frontier chains of thought, but my sense from open models and general principles is that they shouldn’t need to, because that information is already available to them. So optimizing repetition only optimizes the segment of model output that is visible to the user. How much is that? Based on my own agent histories, it’s about 6%. 50% of output tokens are reasoning tokens, and the remaining 44% are tool calls 7 . So we’re running headlong into Amdahl’s law : even if you can save two-thirds of the tokens in visible output (a ridiculously optimistic estimate), you’re still only saving 4% of total output tokens. How to save output tokens If you want to save output tokens, you need to reduce the 94% of output tokens that are invisible, which largely depends on intelligence . The smarter the model 8 , the fewer reasoning tokens and tool calls it needs to get to the right answer. This is why we see a strange phenomenon 9 where more expensive models are actually cheaper to use: they might be 5x more expensive per-token, but they can get to the right answer with 6x fewer tokens, so the overall cost is less. In the KV cache. ↩ Including tool calls. ↩ Coding agents often used to repeat tokens in tool calls (e.g. by re-outputting the entire file content for each edit) but I think this behavior has mostly been replaced with more efficient find-and-replace editing tools. ↩ I’m pretty sure that most mature inference providers already do speculative decoding based on previous ngrams in the input, which would at least exploit output repetition to deliver a speedup. ↩ The reason, broadly speaking, is also the reason why transformers are so important: because of the attention mechanism, input tokens can be ingested in parallel, while output tokens must be generated one-at-a-time. ↩ I’m only moderately confident about this. Some open-source reasoning models (particularly early ones) do, but those models also use way more tokens than frontier models for the same output, so my guess is that powerful frontier models don’t loop in their chain of thought very often. ↩ It’s possible that tool calls involve some repetition as well, if agents are composing content in the chain of thought and then repeating it in the tool. Any readers who have done a lot of coding with open-source models (or who work at a frontier lab) and thus know the answer to this, please email me if you can — I’m curious. ↩ And the better the harness, though I remain convinced that there isn’t that much comparative advantage in harness quality because everyone can copy each other. ↩ This applies to real life too, and is the reason why you shouldn’t hire the cheapest plumber you can find. ↩ If you liked this post, consider subscribing to email updates about my new posts, or sharing it on Hacker News . Here's a preview of a related post that shares tags with this one. Glue work is still harmful in the age of AI I am not a believer in glue work. Processes that can only be sustained by the unrewarded sacrifice of engineers ought to die. Now that LLMs are writing most of our code, does that free human engineers up to do more glue work ? No, it doesn’t. I think glue work is actually less important to companies than it was in the 2010s. Let’s go through four reasons why. Continue reading... Search seangoedecke.com Search

Obsidian 证据: OpenClaw定时任务/AK-RSS-Digest(89源精选)/2026-11-21-AK-RSS-Digest.md