Get 2,500 events tracked for freeSign up now

Glossary

Cost per run

Cost per run is the total LLM spend attributed to one execution of an agent task, summed across every call, model, and agent that execution triggered.

Why it matters

Provider billing is call-centric: a dashboard shows API calls, but an agent task is not one call — it is a cascade of them, often across several agents and tools. Per-call numbers can all look reasonable while the run that contains them is wildly expensive, because the cost lives in the multiplication, not in any single call.

Example

A research task fans out to a planner, three retrieval agents, and a summariser, making 40 calls in total. Each call costs a fraction of a cent; the run costs dollars. Asking "which call was expensive" has no useful answer — the unit that maps to business value is the run.

How it's measured

By propagating a run or session identifier through every call the task triggers and summing attributed costs over it. In Capsera this is what session tagging exists for: a session ID set once flows to every call made under it without per-call plumbing.

Questions this page answers

What is cost per run?
Cost per run is the total LLM spend attributed to one execution of an agent task, summed across every call, model, and agent that execution triggered. It is the unit that maps to business value, because a run is one piece of work a user asked for. Per-call cost can look reasonable while the run containing forty of those calls is expensive.
How do I track cost per run instead of per call?
Propagate one run or session identifier through every call the task triggers, then sum attributed cost over that identifier. In Capsera this is what session tagging is for: set a session ID once and it flows to every call made under it without per-call plumbing. The run total, not the call total, is then the number you compare across agents and over time.
How do I calculate cost per agent run?
Sum the cost of every call carrying the same run identifier, including calls made by sub-agents the run spawned. Include input, output, and cache tokens at the exact per-model rate rather than a blended average, because cache reads are priced around a tenth of base input and blending hides that. Divide by completed runs, not attempted ones, if you want a figure you can compare week to week.
How do I cap the cost of a single agent run?
Set a budget whose scope matches the run and whose action is block, so the pre-call check refuses the next call once the run has consumed its allowance. This bounds the worst case: a loop inside a $5 run ceiling costs at most $5, regardless of how long it spins. Capping the run rather than the key is what keeps one misbehaving run from stopping every other agent sharing the same credential.
How do I measure cost per completed task?
Attribute spend to the run, mark the run as completed or failed when it finishes, then divide total attributed cost by completed runs only. Counting abandoned and failed runs in the denominator flatters the number; counting their spend in the numerator is correct, because you paid for it. The gap between cost per attempted run and cost per completed run is itself a useful signal about reliability.
How do I measure cost per resolved ticket / completed task?
Tag the run with the business object it resolves — a ticket ID, an order, a document — and let cost accumulate against that tag. Cost per resolved ticket is then attributed spend for those runs divided by the number actually resolved. This is the form of the number a finance team can use, because it has a denominator they already recognise.
Why does the same task cost a different amount each run?
Because agent execution is non-deterministic in length: the model may take more reasoning steps, retry a failed tool call, or accumulate more conversation history before finishing. Cost therefore varies with the path taken rather than the task requested. Track the distribution — p50 and p95 cost per run — rather than an average, since the tail is where budget surprises live.