Skip to content

Chapter 6 of 10

Quadratic input growth in agent loops

An agent resends the whole conversation on every call, so a base prompt is billed once per turn while appended tool results accumulate underneath it — total input is n·P + Δ·n(n−1)/2, which is quadratic in turn count. This chapter works the arithmetic against the naive multiple, gives the per-call usage log that turns a stream of requests into a trace grouped by conversation, reads a real twelve-turn coding-agent run where one early file read is 37 percent of the bill, and ranks the available interventions by which term they act on.

Token economics — read the current version at https://daviddominguez.dev/learn/en/token-economics/quadratic-input-growth-in-agent-loops

Back to top