PRODUCTION · 4 MIN READ
The real cost of an agent run
Count the loop, the tools, the storage, and the failures.
Account for every step
A run may contain several model calls, tool calls, searches, and memory operations. Record usage and duration at each boundary. Include retries and unsuccessful runs when estimating the cost of a completed task.
Use a useful denominator
Cost per successful task is usually more informative than cost per request. Separate fixed infrastructure costs from variable model and service costs. Keep prices configurable rather than hardcoding a comparison that will become stale.
Set a budget in application code
Use limits for turns, wall-clock duration, tool invocations, and estimated spend. A stopping rule should return a useful partial result and a clear reason. Test a tool that repeatedly fails so the loop cannot spend indefinitely.