Quadratic Cost Growth from Repeated Context
AI agents re-send the entire conversation history and accumulated tool outputs with nearly every step, causing tokens from earlier interactions to be re-processed and billed repeatedly, leading to a quadratic, not linear, increase in costs.
The top 3
- Self-Attention's O(N²) Bottleneck: Transformer models' self-attention mechanism computes similarity scores between every pair of 'n' tokens in a sequence, forming an N×N matrix. This fundamental operation leads to quadratic (O(N²)) computational and memory complexity, making it the primary bottleneck for processing long contexts.
- Doubling Context Quadruples Compute Costs: Due to the quadratic scaling of self-attention, simply doubling an AI agent's context window length results in roughly four times the computational cost and memory usage. This non-linear growth makes "context stuffing" prohibitively expensive for long-running agent tasks.
- VRAM's Quadratic Burden: Memory Bottleneck: Beyond processing time, the memory footprint—particularly GPU VRAM—for storing attention matrices and intermediate activations in Transformer models also scales quadratically with context length, making memory capacity a critical bottleneck for deploying AI agents with extensive historical data.
Sources
Open the full topic