Agent Harness Tutorial · Tech stack
L13 · Cost accounting
Spend measured per unit of business work. Family: See · around every turn.
Why our choiceAzure bills by resource. Only our meter can tie spend to one registered claim.
| Option | Where from | Verdict | Why |
|---|---|---|---|
| Our meter + budgets | ours | ✓ chosen | $0.50 a turn, agent.cost.usd |
| APIM token metric | ours | ✓ chosen | namespace claims-fnol |
| $10/month budget | ours | ✓ chosen | budget.bicep |
| Cost Management | Azure | ✓ used | the bill |
| APIM token metrics | Azure | ✓ used | |
| Langfuse cost | open source | · considered | reference agent only |
| Own meter | open source | ✓ used | chosen |
How it works inside the harness: When it stops.
Compared: How is cost measured and capped?
| Option | From | Verdict | Grain | Stops a turn | Source | Status |
|---|---|---|---|---|---|---|
| Own Meter + cost framework | ours | chosen | per step, turn, successful task | yes: $0.50 per turn | price table × tokens | built (framework v0) |
| APIM token metrics | Azure | chosen | per API and subscription | no: Consumption lacks it | gateway token counts | built |
| Langfuse cost tracking | open source | alternative | per trace and generation | no | its model price table | listed open source option |
| Helicone | vendor | not evaluated | per request via its proxy | rate limits only | its price table | not evaluated |
| Azure Cost Management | Azure | chosen | per resource, per day | no: alerts only | the Azure bill | built: $10 budget alert |
DecisionOur Meter caps every turn and computes cost per successful task, while APIM token metrics and Cost Management give the gateway and bill views. Langfuse or Helicone would only duplicate what the Meter and spans already record.
How it is done: the real code
Cut from the live repositories each time the site is built, so it always matches what runs.
// WHAT IT IS
// A cost budget on the resource group rg-claims-fnol-dev: $10 a month, with an
// email to the owner when actual spend reaches 50% and 80%, and when the month's
// forecast reaches 100%. A budget never stops anything; it only tells you.
//
// WHICH CONCERN IT SERVES
// Cost (architecture deck, slide 53; PLAN.html Tier 3, "a $10 budget alert
// before anything else"). The 12-month free offer is used up, so PostgreSQL is
// the one real cost; this is the tripwire if something else starts billing.
//
// EXPECTED DEV COST
// $0. Budgets are free (Cost Management).
//
// ORDER
// main.bicep makes every other module depend on this one, so ARM creates the
// budget first. Cost data reaches Cost Management with a delay of hours, so an
// alert is never instant.
targetScope = 'resourceGroup'
@description('Budget name.')
param name string = 'budget-claims-fnol-dev'
@description('Monthly amount in the billing currency (USD for this subscription).')
param amount int = 10
@description('Who gets the alert emails.')
param contactEmail string
@description('First day of the budget period, yyyy-MM-01T00:00:00Z (main.bicep: this month).')
param startDate string
resource budget 'Microsoft.Consumption/budgets@2023-05-01' = {
name: namePRICES: dict[str, Price] = {
"openai/gpt-oss-120b": Price(Decimal("0.15"), Decimal("0.75")),
"openai/gpt-oss-20b": Price(Decimal("0.10"), Decimal("0.50")),
"qwen/qwen3.8-27b": Price(Decimal("0.15"), Decimal("0.60")),
}