In a stateless multi-turn agent loop of N turns, let S be static system and tool schema tokens,U₀ the initial user prompt, ΔU new user/environment tokens per turn, T_tool tool output payload tokens appended per turn, and O assistant output tokens per turn.
Total_Input_Tokens = N·(S + U₀) + [N·(N − 1) / 2] · (O + T_tool + ΔU)
The cumulative tool-payload replay term [N·(N − 1) / 2] · T_tool is isolated so you can see exactly how much of your input bill is caused by re-sending prior tool outputs. When Prefix Prompt Caching is enabled, turn 1 writes the static schema at the provider's cache-write rate and each subsequent turn t ≥ 2 reads the prior prefix I_(t−1) at cachedInputPer1M while paying write/input rates only on the new turn delta.