The Hidden Quadratic Math of Multi-Step Tool-Calling Agents
If an agent starts with 3,500 tokens of system prompt and MCP tool schemas and adds 1,200 tokens per tool response over 12 iterations, a single task sends over 120,000 cumulative input tokens. Enabling prefix caching on the static preamble and pruning raw JSON tool responses down to essential fields routinely cuts agent run costs by 65%–80% with zero quality drop.
Three Mandatory Circuit Breakers for Every Autonomous Agent
Never deploy an unattended agent loop without three hard ceilings: (1) max_steps (typically 8–12), (2) max_run_usd (e.g., $0.25 per job), and (3) duplicate-call detection that immediately terminates and alerts if the agent invokes the same tool with identical arguments twice in a row.
Questions developers ask
Why do AI agents cost 5x–15x more per task than normal chat prompts?
Each tool-calling iteration re-sends the full prompt preamble, all tool definitions, and every prior tool output—multiplying cumulative input tokens quadratically unless prefix caching and payload trimming are active.
Which models offer the best cost/performance split for agent loops?
Use fast low-cost models (DeepSeek V3.2 or Gemini Flash) for routing, extraction, and schema formatting, and escalate to Claude Sonnet 4.5 or GPT-5 only for high-stakes planning or code synthesis.
How do I migrate off shut-down hosted agent builders without lock-in?
Use our free OpenAI Agent Builder → Agents SDK & Promptfoo Migrator at /tools/openai-agent-builder-to-agents-sdk-promptfoo-migrator to export clean Git-tracked code and eval suites.
Can I estimate agent costs without signing in or pasting API keys?
Yes—100% of calculations and config exports run locally in your browser.