Quadratic Context Growth from Self-Correction

Naive agent loops and redundant self-correction cause token costs to compound quadratically, as the entire conversation history, including reasoning traces and tool outputs, is resent with every iteration, significantly inflating bills. [3, 9, 10, 12, 18, 28]

The top 3

  1. Why Self-Correction Explodes Context Quadratically: The quadratic growth stems from the self-attention mechanism in LLMs, where each token must compare itself to every other token in the context. In self-correction loops, the entire accumulating interaction history (n tokens) is re-processed with each new step, leading to O(n²) computational demands.
  2. Top 3 Computational Costs of Quadratic Context: Quadratic context growth primarily inflates API token consumption, leading to higher operational expenses. It also causes significantly slower processing speeds and increased inference latency, along with excessive memory usage due to storing large amounts of intermediate data.
  3. Agent Tasks Most Vulnerable to Quadratic Context: Complex planning, multi-turn reasoning, and iterative debugging tasks are highly susceptible to quadratic context growth, as agents frequently backtrack, refine outputs, or retry actions. Agentic loops that involve continuous monitoring, planning, and self-correction can generate dozens or hundreds of API calls, rapidly exhausting token budgets.

Sources

Open the full topic