FIELD GUIDE

AI Agent Cost Tracking: Budgets, Tokens and Cost per Task

Use the completed task as the unit of value, and keep the cost of every attempt visible.

NOV 5, 2026 · EmperorClaw · Malecu s.r.o.
QUICK ANSWER

Track each agent run’s model, token usage, cost basis and task ID, then aggregate all attempts into cost per accepted task. Separate runtime-reported costs from estimates and unpriced usage. Use agent budgets to govern new work and provider-side limits where you need enforcement at the model service.

Record costs where work happens

A provider invoice tells you the account total. It does not necessarily tell you which client report or project consumed it. Link each run to the agent, model, task and project it actually served. Leave general chat identifiable as chat rather than assigning it to a convenient client.

Record input and output tokens separately, together with duration, outcome and tool use. Capture cached or other separately priced usage when the runtime provides it. Keep the currency, reporting period and cost basis consistent before combining totals.

Distinguish reported, estimated and unknown cost

BasisMeaningQuestion to ask
ReportedThe runtime supplied a cost value.Does it include every charge you need to allocate?
EstimatedUsage was priced using a model price table.Does the table match the provider, model and relevant token types?
UnpricedUsable pricing is missing.Which usage still needs a price before totals are meaningful?

Do not treat an unknown price as free usage. Subscription-backed runtime reports also need interpretation: a token-based estimate can describe equivalent API usage without being the amount charged to that subscription.

EmperorClaw labels cost bases in its Costs workspace. Its pricing table is instance-wide and editable by instance admins. For model-call instrumentation in another stack, Langfuse’s cost-tracking documentation explains reported usage and model-price configuration.

Calculate the cost of the result, including retries

Illustrative example, not model pricing: one report takes a $0.60 research run, a $0.40 draft and a $0.50 revision. A failed first attempt used another $0.30. The accepted report consumed $1.80 of recorded model cost, not just the final revision’s $0.50.

Recorded cost per accepted task =
  sum of attributable run costs / accepted tasks

Example: ($0.60 + $0.40 + $0.50 + $0.30) / 1 = $1.80

If a weekly batch consumes $18 across ten accepted tasks, the average is $1.80. Keep incomplete tasks and unpriced runs visible alongside that figure. It is a model-cost measure, not total business cost: hosting, paid tools and human review may be separate.

Understand where a budget is enforced

A dashboard, an alert and an enforced spending limit solve different problems. Before running overnight, ask whether the system only reports spend, refuses the next run, interrupts active work, or asks the provider to reject more usage. Test the boundary with a small controlled assignment.

EmperorClaw’s monthly agent budget warns at 80% and blocks new runs at the limit. Work already in progress can exceed it. Use provider-side limits when you need control enforced by the model service, and review whether your provider’s limit has its own delay or scope.

For runtime-level protection, configure bounded retries, execution time and tool access where the runtime supports them. A monthly agent budget does not set those limits automatically.

Review by client, project, model and agent

  1. Choose one date range for the comparison.
  2. Inspect unpriced usage and resolve missing model mappings.
  3. Group by client and project to see where work is allocated.
  4. Drill into expensive tasks and include unsuccessful attempts.
  5. Compare results before changing the model or adding agents.

In EmperorClaw, Costs provides these breakdowns, daily trends and CSV export. Timeline helps connect long runs and handoffs to the task story. The records support allocation and investigation; verify them against provider billing before treating an export as an invoice.

Common questions

Are fewer tokens always cheaper?

No. The model, provider and token types affect the price. Compare consistently priced usage and accepted outcomes rather than raw token counts alone.

Does a monthly budget guarantee the bill cannot exceed it?

Only if the relevant enforcement mechanism provides that guarantee. EmperorClaw blocks new runs at its budget boundary; an active run can continue spending.

Can I measure cost per client?

Yes, when runs are correctly attributed to tasks and projects belonging to that client. Keep unattributed chat and missing-price usage visible rather than hiding them in allocations.

Make the next run measurable

Choose one recurring task, confirm its project and client, inspect the first run’s usage and outcome, and set an agent budget you can review. Add automation after the task attribution is dependable.

See EmperorClaw budgets and cost reporting or the multi-agent operating workflow for the surrounding process.

GUIDES← All articlesGet startedInstall EmperorClaw →