← Back to field notes
Cost engineering2026-07-179 min read

How to measure AI coding cost without hiding the trade-offs

A practical guide to request cost, harness efficiency, model choice, context growth, cache reuse, and allocation—with a clear boundary between observed evidence and illustrative scenarios.

Cost allocationHarness efficiencyMetricsFinOps
A luminous request signal splitting across model lanes and selecting an efficient route
mix / measure / save

A lower model bill can come from several different interventions: a more efficient agent harness, a better-fit model, a smaller context, an exact-cache hit, or a hard limit that prevented low-value work. Combining those into one “saved” number makes the result impossible to audit.

Policate separates the levers. The live dashboard reports request and allocation evidence it actually receives. Marketing scenarios are labeled illustrative, and harness comparisons require a controlled task benchmark rather than a guess applied to production traffic.

A cost flow showing separate model, context, cache, and control paths.
Savings are useful only when the baseline and intervention remain visible.

Start with one evidence chain

For a Gateway request, Policate can connect the selected model, provider-reported or estimated usage, price snapshot, policy revision, cache outcome, fallback, latency, and sanitized allocation tags. That produces a request receipt rather than an unexplained invoice line.

The baseline must be explicit. It can be the originally requested model, an approved fixed-model comparison, or a prior-period route mix. Changing the baseline after the result is known invalidates the comparison.

Inspect one Gateway receipt
$ policate trace req_84f2 --json

The live manager metrics

These are the metrics available from current request metadata. Actual provider cost is preferred; the estimate remains visible as a fallback. Raw prompts and responses are not needed for any of them.

Policate spend and operating metric definitions
MetricWhat it meansWhat to do with it
Requests and tokensRequest count plus input, output, and cached tokens by model and provider.Find volume growth and output-heavy workflows.
Actual and estimated costProvider-reported cost when present, otherwise the transparent catalog estimate.Reconcile invoices without making partial receipts disappear.
Cost / request and / 1M tokensNormalized unit economics for the selected date range.Compare teams and routes with different volumes.
Routing shift and fallback rateHow often policy selected a different model or used a fallback.Review expensive defaults and provider instability.
Exact-cache reuseShare of eligible Gateway requests served without another provider call.Find safe repeated workloads and low-reuse routes.
Latency P95Tail latency across completed requests.Catch slow providers or costly fallback chains.
Attribution coverageShare of spend carrying project, work-item, or session metadata.Close allocation gaps before setting project budgets.
Member concentrationRole-scoped spend distribution across active members.Detect support needs or unusual usage without exposing prompts.

Measure the harness separately

Harness efficiency is not the same as choosing a cheaper model. A controlled benchmark should run the same representative repository tasks, model, prompt, and success criteria on both harnesses. Report successful-task cost, input and output tokens, tool-result tokens, retry loops, elapsed time, and pass rate across repeated runs.

Policate’s local workflow can reduce waste through bounded reads, summarized tool results, context ceilings, automatic compaction, managed defaults, and fewer failed edit loops. The production dashboard does not pretend to infer that causal saving from a request receipt. Publish a harness saving only after the comparative task suite produces it.

  • Same task fixtures and repository state
  • Same model, temperature, and provider region
  • Success criteria checked independently
  • At least three runs per task
  • Tokens and retries per successful task
  • Failures reported instead of discarded

Allocate spend without reading prompts

Policate rolls Gateway evidence up by organization, team, project, work item, session, member, model, and provider. Developers can tag a session explicitly; bounded local metadata detection can normalize a branch or Jira/GitHub-style reference without resolving the remote issue or uploading repository paths.

Direct mode keeps provider traffic local, so central request allocation is intentionally incomplete unless compatible usage metadata is explicitly reported. It can still preserve local receipts and session labels. The dashboard must not present Direct evidence as equivalent to an authoritative Gateway trace.

Attach privacy-bounded allocation metadata
$ policate session tag --project billing-migration --work-item PLAT-1842

Read the illustrative chart correctly

The landing-page $10,000 scenario is a teaching model, not a customer promise. It shows four separate levers—harness efficiency, cost-aware model choice, context and compaction, and exact cache plus limits—and the components add exactly to the displayed saving.

For a real workspace, replace every illustrative component with observed request receipts or a controlled harness benchmark. Keep the untouched baseline, measurement window, workload mix, and calculation method available next to the result.