Cost per agent, per run, per customer, with budgets enforced inline. Computed from the chain you already have rather than a second pipeline — which is the difference between a figure you can defend and one you have to reconcile.
Bolt a FinOps tool alongside the audit log and the two will eventually disagree — different retention, different sampling, different idea of what a retry is. The disagreement surfaces in the one meeting where it cannot be explained away, and at that point neither number is evidence.
Cost is already in the chain. Every model call we record carries its model, provider, token counts and cache splits. Spend is a rollup over rows we already hold — not a second source of truth, because there is only the one.
And a spend limit is a compliance control wearing a different hat. “This agent may not move more than $X without sign-off” is a budget rule, a human-oversight measure and a delegation-of-authority control at once. One engine, one record, two buyers.
SELECT e.session_id,
e.actor->>'id' AS agent,
e.on_behalf_of->>'end_user' AS customer,
sum((e.cost->>'total')::numeric) AS run_cost_usd,
bool_and((e.cost->>'attribution_complete')::bool)
AS cost_trustworthy,
bool_or(e.outcome = 'blocked') AS hit_policy,
bool_or(e.action_type='human_override')
AS needed_human
FROM audit_events e
WHERE e.log_id = $1 AND e.ts >= $2 AND e.ts < $3
GROUP BY 1, 2, 3;A run is a session: its model calls, tool calls, wall clock, cost, and whether it tripped a policy or needed a human.
The unit a CFO and a CCO can both read. Same rows, different column.
Rolled up from the identity already on every event — no join to a second system, so no rows that exist on only one side.
Per-customer margin stops being a quarterly spreadsheet exercise.
Spend against ceiling over a window, utilisation, and spend-per-minute against baseline.
The ceiling reports the damage. The burn rate is what stops it.
A total that cannot be decomposed back to the calls that produced it is a number nobody can check.
A clean run is one that tripped no policy and needed no human. It is the only unit-economics figure that means anything, because average cost per run quietly averages together the runs that worked and the runs that cost you a person's afternoon.
When there are no clean runs, it reports that there are none. It does not return zero, or infinity, or a dash that could mean either — a broken number on a compliance dashboard is indistinguishable from a lie, and there is a test that says so.
Set a ceiling and a window for the fleet, or for one agent. The agent's own budget wins over the default. Spend is summed from the chain at decision time, so an agent cannot understate what it has already spent.
An unset budget enforces nothing. Shipping a product that starts refusing a customer's traffic because they haven't opened the budgets page is the same mistake as arming a policy rule on install — and the dashboard says the budget is unset rather than showing a number nobody chose.
Budget changes and the kill switch are recorded in the chain with a name attached. “Who raised the ceiling the day before the overspend” is a question that gets asked, and a config table nobody audits is where that answer goes missing.
POST /v1/decide
{ "agentId": "loan-underwriter",
"action": "model_call",
"dailyTotal": 0 } ← the agent's claim
{ "effect": "deny",
"policyId": "cost-velocity",
"reasons": ["spend 0.0182 exceeds ceiling 0.005"],
// what it was actually judged on
"evaluatedAgainst": {
"dailyTotal": 0.0182,
"tenantHalted": false,
"approvalId": null } }Gateways price from a static model table. A custom deployment, or a model released last week, is not in it. The failure is logged below the default log level, the request returns 200, and the call shows up costing nothing.
Inheriting that would mean publishing a number we know is wrong, in a document whose whole value is that it can be trusted. So every event carries whether its cost is complete, every summary counts the calls that weren't priced, and the flag travels with the total wherever it goes.
{
"totalUsd": 0.0777,
"runs": 5,
"cleanRuns": 3,
"costPerCleanRun": 0.0259,
// one call could not be priced upstream —
// the total above is therefore incomplete
"unpricedCalls": 1
}Two endpoints disagreed about the same fact: one counted unpriced calls by looking for a null total, but an unpriced call stores zero. It reported that everything had been priced on exactly the log where something hadn't. Fixed, and covered by a test that fails if the two ever diverge again.
That is the whole product: record it, check it before it happens, price it from the same rows.