Loop Engineering Cost Calculator
Estimate per-run, daily, monthly, and worst-case token cost for an agent loop — then get optimization tips before you schedule it. Pricing presets are examples only.
- This loop looks budget-aware. Keep the stop rule, retry limit, and human approval gate in place before scheduling it.
Turn this estimate into real stop conditions. These map to continuous-claude flags ($1.00 per-run cap ≈ 1.5× the per-run estimate). Verify before use.
# continuous-claude caps derived from this estimate — verify before use--max-runs 8--max-cost 1--max-duration 1h
How Loop Costs Are Calculated
Cost is per-iteration token cost multiplied by iterations, retries, runs per day, and days. The worst-case figure assumes a retry multiplier of at least 1.5 so you can size a budget cap for a bad day.
costPerIteration = (inTokens / 1e6) * inputPrice+ (outTokens / 1e6) * outputPricecostPerRun = costPerIteration * (maxIterations * retryMultiplier)dailyCost = costPerRun * runsPerDaymonthlyCost = dailyCost * 30worstCase = costPerIteration * maxIterations * runsPerDay * 30* max(retryMultiplier, 1.5)
Token-Rich vs Token-Poor Loop Engineering
Token-rich loops pass large context into every iteration. They are easier to implement but more expensive and more likely to hit context limits.
Token-poor loops pass only summaries, recent observations, or retrieved memories. They are cheaper and faster but require better memory and state management.
Loop Budget Optimization Tips
- If input tokens are large, switch to summary or retrieval memory and pass only the last few relevant observations.
- If iterations are high, add a hard stop condition and require a report after repeated failures.
- If the retry multiplier is high, improve validation and fallback before scheduling the loop.
- If monthly cost is high, require human approval before long-running loops and add budget caps.