cleandataengineering.aiAgent Harness, drawn simply
You are here: Tech stack › L13 · Cost accounting

Agent Harness Tutorial · Tech stack

L13 · Cost accounting

Spend measured per unit of business work. Family: See · around every turn.

AZURE OPTIONSCost Management✓ used: the billAPIM token metrics✓ usedOUR CHOICEOur meter + budgets$0.50 a turn, agent.cost.usdAPIM token metricnamespace claims-fnol$10/month budgetbudget.bicepOPEN-SOURCE OPTIONSLangfuse cost· considered: reference agent onlyOwn meter✓ used: chosenWHO DOES THE WORKAzure gives 30% · we code once 60% · each agent team still does 10%
Dark boxes are what we run. Solid boxes are used or planned; dashed boxes were considered or dropped (crossed). The bar: grey is what Azure gives, dark is what we code once, hatched is what each agent team writes.
Why our choiceAzure bills by resource. Only our meter can tie spend to one registered claim.
OptionWhere fromVerdictWhy
Our meter + budgetsours✓ chosen$0.50 a turn, agent.cost.usd
APIM token metricours✓ chosennamespace claims-fnol
$10/month budgetours✓ chosenbudget.bicep
Cost ManagementAzure✓ usedthe bill
APIM token metricsAzure✓ used
Langfuse costopen source· consideredreference agent only
Own meteropen source✓ usedchosen

How it works inside the harness: When it stops.

Compared: How is cost measured and capped?

Own Meter + cost fram…ourschosenAPIM token metricsAzurechosenLangfuse cost trackingopen sourcealternativeHeliconevendornot evaluatedAzure Cost ManagementAzurechosen
Dark: what we chose. Crossed and dashed: rejected or not for us. Added here (not a Series table).
OptionFromVerdictGrainStops a turnSourceStatus
Own Meter + cost frameworkourschosenper step, turn, successful taskyes: $0.50 per turnprice table × tokensbuilt (framework v0)
APIM token metricsAzurechosenper API and subscriptionno: Consumption lacks itgateway token countsbuilt
Langfuse cost trackingopen sourcealternativeper trace and generationnoits model price tablelisted open source option
Heliconevendornot evaluatedper request via its proxyrate limits onlyits price tablenot evaluated
Azure Cost ManagementAzurechosenper resource, per dayno: alerts onlythe Azure billbuilt: $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: name
PRICES: 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")),
}