Home / Methods / AI cost / Agent loop cost
Agent loop cost
When the AI works not in one request but in a loop: reads, acts, looks at the result, acts again. This is exactly where the cost creeps up unnoticed.
Or ask in your own words (needs an AI key)
What you need
- steps the agent takes per task
- tokens at the start: instruction plus task
- tokens added per step (the answer plus the tool result)
- tokens the model writes per step
- price per 1M input tokens
- price per 1M output tokens
- discount on the re-sent opening, % (default 0)
- how many such tasks per day
What it calculates
- input tokens sent across all steps together, tokens
- tokens the model writes across all steps, tokens
- what one whole task costs
- what it would cost if the conversation never grew
- share of input tokens that is re-reading old text (%), %
- what it comes to per day
- tokens in the request by the last step, tokens
Examples
A 20-step agent, 8,000 tokens to start, +1,500 a step
| input tokens sent across all steps together | 445,000 tokens |
| tokens the model writes across all steps | 6,000 tokens |
| what one whole task costs | 1.0146 |
| what it would cost if the conversation never grew | 0.57 |
A 50-step agent, 20,000 tokens to start, +3,000 a step, no cache, 200 tasks a day
| input tokens sent across all steps together | 4,675,000 tokens |
| tokens the model writes across all steps | 40,000 tokens |
| what one whole task costs | 6.2438 |
| what it would cost if the conversation never grew | 1.65 |
| what it comes to per day | 1,248.75 |
Example numbers are checked against an independent calculation. The AI in Numo does not compute: it only parses your question; a deterministic engine does the maths.
Careful
The main trap of an agent: at every step the whole previous conversation is sent again. So cost grows not linearly but quadratically with the number of steps. The calculation assumes the context is never trimmed — if the agent compacts it, the real sum will be lower.
Typical mistakes
- Pricing each step alone — the agent resends the whole history every time.
- Not capping the number of steps.