| Cost per task | Spend divided by successful outcomes, not by raw token count. |
| Attribution | Assigning cost and latency to a specific agent, step, model or customer. |
| Spend ceiling | A hard limit that stops or degrades work before a budget is exceeded. |
- AI spend is growing faster than usage.
- Several agents or teams share a budget.
- You need to justify ROI with per-feature numbers.
- 01Tag every request with feature, customer and run ID.
- 02Record tokens, model, latency and tool calls per step.
- 03Set per-run and per-feature ceilings with defined degradation behaviour.
- 04Review cost per successful task weekly and route simple steps to cheaper models.
Cost per resolved ticket
- Context
- Several features share one AI budget.
- Problem
- Token totals rise but nobody knows which feature is worth the spend.
- Approach
- Tag each run with feature, customer and outcome, then divide spend by resolved tickets.
- Outcome
- Clear ROI per feature and an obvious target for optimisation.
Traffic spike with a budget ceiling
- Context
- A campaign drives a sudden surge in assistant usage.
- Problem
- Spend would exceed the monthly ceiling within hours.
- Approach
- Degrade retrieval depth first, then switch to a smaller model, and stop only non-critical paths.
- Outcome
- Service continues within budget instead of failing outright.
Cost record for one ticket
{
"run_id": "run-8821",
"feature": "support_assistant",
"customer": "acme",
"model": "pinned-small",
"input_tokens": 4200,
"output_tokens": 310,
"tool_calls": 2,
"resolved": true
}Group records by feature and divide spend by resolved tickets — that is the number that exposes waste.
Ceiling with graceful degradation
run_budget_tokens: 6000
degradation:
- step: retrieval
action: reduce final_passages from 6 to 3
- step: model
action: switch to pinned-small
stop_when: budget_exceeded and not criticalDegrade before stopping. Hard stops should apply only to non-critical paths.
Hard ceilings
Up: Predictable spend
Down: Can block legitimate work
Soft alerts
Up: Flexible
Down: Overspend can still happen
Cheaper routing
Up: Lower unit cost
Down: Requires confidence checks
| Option | Upside | Cost |
|---|---|---|
| Hard ceilings | Predictable spend | Can block legitimate work |
| Soft alerts | Flexible | Overspend can still happen |
| Cheaper routing | Lower unit cost | Requires confidence checks |
- Separate input and output token costs in reporting.
- Attribute cost to steps, not just entire requests.
- Alert on cost-per-success regressions.
- Include retry and tool costs in the total.
| Key | Typical value | Note |
|---|---|---|
| run_budget | per workflow | Enforced at runtime. |
| feature_tag | required | Needed for attribution. |
| degradation | cheaper model | Define before hitting the ceiling. |
| Symptom | Cause | Fix |
|---|---|---|
| Costs spiked without traffic growth | Retries or longer prompts | Inspect step-level traces and token deltas. |
| Attribution incomplete | Missing tags on background jobs | Make tags mandatory in the client. |
What should I measure first?
Cost per successful task by feature. It exposes waste that token totals hide.
Should ceilings stop work outright?
Usually degrade first (cheaper model, fewer passages), then stop for non-critical paths.
More in Inference & production