Why does token cost grow super-linearly with agent step count, and what architectural decisions reduce it?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Explain why token cost in an agent loop grows faster than linearly with the number of steps. Describe the asymptotic growth in the worst case, and name three architectural levers that reduce it.
Each step re-sends the whole growing transcript, so per-step cost rises with step count and total cost is quadratic; pruning, summarisation, and step caps tame it.
Imagine taking notes during a long meeting, but with a strange rule. Before you write each new line, you must first re-read every line you already wrote, out loud, from the very top. Line two costs you one re-read. Line three costs two. By line fifty you are re-reading forty-nine lines before adding anything new. The work to finish the page is not fifty units, it is closer to fifty times fifty divided by two. An agent loop has the same rule. Every turn it must re-read the entire conversation so far before deciding the next move, because the model has no memory between turns. So a longer agent run does not just cost a bit more, it costs dramatically more. Fixes are obvious once you see it. Stop re-reading the old lines, or shrink them into a short summary first.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
State why statelessness forces a full re-send each turn, derive the triangular sum to show quadratic growth, separate slope-changing levers from the step cap, then add the retry, sub-agent, prefix-caching, and cheaper-model multipliers that show up in real production loops.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Saying cost is linear in steps because there are N calls. That counts the calls but ignores that each call re-sends a context that itself grows with the step count.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.