An agent run’s cost and latency live in its trace: the model id, the latency, the cost signal, the retries and the tool calls. An average across all runs hides the expensive few, and the expensive few are usually the ones stuck in a retry loop or calling a vision model dozens of times. Reviewing per run finds them.
Before you start
Traces that record model id, latency and a cost signal per run, and a way to list runs sorted by cost.
Pull the traces with cost and latency
For each run in the last week, record the model id, the number of model calls, the tool calls, the total latency and the cost signal. If the trace does not carry a cost signal, compute one from the token counts and the pricing page.
Keep the run id and the task type with each row, so a costly run can be traced back to its job.
Sort by cost and by time, separately
Sort the runs by cost and then by latency, and read the top five of each list. A run that is costly but fast is usually a token problem; a run that is slow but cheap is usually a tool or a retry problem.
Check whether the top runs share a task type or a tool: a shared cause means one fix helps many runs.
Fix the top runs first
For the most expensive run, open its trace and find the step that spent the tokens: a retry loop, a long context re-sent every turn, or a vision call per action. Fix that step and re-measure the same task.
Set a per-run cost alert at the level the top runs exceed, so the next expensive run pages someone instead of running quietly.
Practice check: fictional Maple Corner agent, 20 runs last week
The table below is fictional practice material, worked out by hand from the stated trace review. It is the expected result for the practice review, not a run of any agent.
| Run | Cost | Latency | Cause | Verdict |
|---|---|---|---|---|
| R-104 | $0.42 | 184 s | Retry loop, 9 tries | Fix first |
| R-097 | $0.31 | 96 s | Vision call per action | Fix second |
| R-088 | $0.08 | 41 s | Normal run | Pass |
| R-091 | $0.06 | 38 s | Normal run | Pass |
| Median | $0.07 | 40 s | Normal | Pass |
Two runs cost far more than the median of $0.07: R-104 at $0.42 from a retry loop and R-097 at $0.31 from a vision call per action. The other runs are normal, so the fix targets those two causes.
Expected result. UNTESTED: the costs and latencies in the practice table are worked out by hand, not measured by running an agent. Pull your own traces for the last week, sort by cost and latency, and open the top runs to find the cause.
Limits
- An average cost hides the expensive runs: always look at the top runs, not just the mean.
- A cost signal without the trace behind it cannot be fixed: keep the tool calls with the cost.
