How to Reduce Token Usage in AI Agents (Measured)
How to Reduce Token Usage in AI Agents (Measured)
A replay of a 40-step coding session through the OpenRouter API across six context setups found that a timestamp at the top of the system prompt broke prompt caching and made the same session cost 7.8 times more ($0.658 vs $0.084). Capping each tool result once when it enters the history was the cheapest setup at $0.054, with input down 36% and 95% still cached, while re-trimming old tool outputs on every step cut input tokens by 60% but cost 3.1 times more because editing old messages broke the cache. Chunked compaction shrank the final prompt from 260K to 63K tokens, but re-summarizing an earlier summary dropped accuracy to 1 of 4.
The piece pairs concrete cost and cache-hit measurements with practical rules for agent context handling, making it useful for teams tuning agent spend.
Source: OpenRouter Announcements · openrouter.ai