Asked about The model has no memory

Why does a long conversation get expensive faster than you would expect?

An answer that works

Every turn resends all previous turns, so total tokens grow with the square of the number of turns rather than linearly. Most of that resent text is the model's own previous output, which is typically longer than the user's messages.

Then they push further

Roughly how much faster?

If each turn adds a similar amount, total input over n turns grows with the square of n, because every turn resends everything before it. Twice as many turns costs roughly four times as much input.

What would you do about it?

Cache the stable prefix, trim or summarise older turns, and drop bulky tool results once they are no longer needed.

What gets marked up

Strong answers explain that the API is stateless so the whole history is sent every turn, and can reason about the growth.

Reading an answer is not being able to give one. The section that teaches this is The model has no memory, 2 hours of The Messages API.

Learn this properly