Multi-Turn AI Agent Token Snowball & Cost Simulator
Every tool call in an autonomous agent re-sends the growing conversation history—creating O(K²) cumulative input billing across K steps. Simulate exact per-task agent costs, prompt-prefix cache savings, and context compaction strategies across illustrative open-weights and generic rate profiles.
📈 Models Quadratic History Growth, Prefix Caching & Context Compaction
Cumulative Tokens / Task184.5K7.7× single-pass naive sum
Why Agent Loops Cost 5×–12× More Than Chatbots—and How to Fix It
In an append-only K-turn loop where each step appends Δ tokens of tool stdout and assistant reasoning on top of S static system/tool tokens, cumulative billed input tokens scale as K·S + Δ·K(K−1)/2. Combining deterministic prompt-prefix ordering (never mutating timestamps inside the system prompt!) with sub-agent isolation or 8-turn rolling summarization routinely cuts monthly agent bills by 65%–82%.