If your AI agent’s token bill looks like a typo, you are probably paying for amnesia. A recent breakdown from systemdesignsimple reveals that a 30-call agent task can consume 5,467 times the input tokens of a single chat interaction. The culprit isn't the AI's intelligence, but its lack of memory. Because Large Language Models (LLMs) are stateless, every call requires re-sending the entire conversation history, tool definitions, and system prompts. This architectural reality turns linear tasks into quadratic cost nightmares.

The Quadratic Tax on Context

The core issue is that a model computes over the system prompt, tool definitions, and all previous messages on every single call. There is no persistent memory between requests. As noted in the source, call 'k' must process everything that came before it. With constant increments, the total input tokens across N calls grow close to N squared. Even server-side state management saves upload bandwidth but does not shrink the logical context; providers still bill for every previous input token in the chain. In a synthetic lab simulation, a single chat used 158 estimated input tokens, while a 30-call agent task hit 863,762 tokens.

Three Ways to Stop the Bleeding

To fix this, you have to decide what to forget. The first step is shrinking tool results before they enter the history. In the lab, keeping 100 percent of tool output resulted in costs 504 times higher than a single chat at 30 calls. By capping output to 20 percent using line ranges and failure-only test logs, that multiplier dropped to 136 times. The second fix is prompt caching. While this doesn't reduce the token count the model processes, it lowers the bill. The source cites an 82 percent lower illustrative cost by putting static content first, ensuring the prefix remains byte-stable for cache hits.

Managing Context Limits

The third strategy involves clearing or summarizing old tool results as you approach context limits. This caps request size and forces growth closer to linear. However, this breaks the cache for the edited portion, so you must clear in large batches to minimize cache misses. The fixed overhead in the lab was 2,230 estimated tokens per call for the system prompt and 10 tool schemas, meaning the variable history is where the real waste lies.

Key Takeaways

  • Stateless LLMs force agents to resend full context, causing token usage to grow quadratically with conversation length.
  • In a 30-call task, 94.0 percent of tokens were spent re-sending history, not generating new insights.
  • Capping tool output to 20 percent of its original size reduced cost multipliers from 504x to 136x in lab tests.
  • Prompt caching can reduce costs by 82 percent if static content is placed first to maintain byte-stable prefixes.
  • Aggressive summarization or clearing of old results is necessary to cap request sizes and approach linear growth.

The Bottom Line

History is the bill. An append-only loop pays for every past tool result on every future call, so the cheapest agent is the one that decides what to forget. Measure your own re-sent share before you pay for a bigger context window.