Agent costs are driven by repeated prompts, and prompt caching is often lost by accident
Most of an AI agent's token spending goes to resending the same prompt, including instructions, tool definitions, and conversation history, on every model call. Providers offer a discounted rate for this through prompt caching, but it only works if the start of the prompt is identical to the previous request. Common mistakes such as embedding a current timestamp, rewriting task counters, reordering tool definitions, or trimming history each turn break the cache and force full-price processing. The article points to an open issue in OpenClaw's tracker where heartbeat wake-ups rewrote the cached prefix, making each one cost a full cache write. Its recommended fixes are keeping the system prompt byte-identical, only appending to history, compacting long conversations once rather than every turn, and avoiding polling loops, with an example suggesting roughly 85% savings on repeated input.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.



Discussion (0)
Log in to join the discussion and vote.
Log in