This is stage 5 of 5 in a guide to monitoring when AI coding agents do the engineering work. This page covers AI cost management: what changes, what to measure, where your team is on three levels, and which tools cover it.
What changes when agents do this work
Agent spend does not behave like infrastructure spend. It is bursty, it is driven by retries rather than traffic, and a single misbehaving loop can cost more in an afternoon than a month of server bills. Microsoft Research has documented compounding-retry behavior where a request's context grows by orders of magnitude across a session.
The obvious lever is to keep less data when monitoring gets expensive. Resist it here. Agents need raw history, because the useful data is the data nobody thought to query yet, and sampling harder to control cost removes exactly that. Watch the monitoring bill, but do not cut sampling to shrink it.
System prompts are worth checking before anything else: 69% of tokens in a measured workload were system-prompt overhead rather than the user's actual request.
What to measure
Cost per session, not cost per token
Token price is a rate. Session cost is the thing that varies by three orders of magnitude between a good run and a runaway one.
Retry-driven token growth
Context that compounds across retries is the usual mechanism behind a surprise bill. It is visible in the trace long before it is visible on the invoice.
Spend by model, prompt version and team
Routing decisions need attribution. Without it, the only lever available is turning things off.
Your monitoring bill alongside your model bill
Agent-driven work raises how much telemetry you keep. Price that increase deliberately rather than discovering it.
Three levels, from doing it by hand to letting the system do it
Find the level your team is at today. The next one is the step to take.
- 01Manual
You read the invoice
The invoice arrives monthly, in arrears, aggregated. You find out about the runaway loop four weeks after it ran.
- 02Instrumented
Token cost is attributed in the trace
Every span carries model, token counts and cost. Spend is queryable by team, prompt version and session, in the same place as the latency data.
- 03Autonomous
Routing and budgets respond automatically
Requests that tolerate it go to cheaper models, every session gets a hard budget ceiling, and the alert is on token growth rate rather than on the monthly total.
Tools that cover this stage
These are the tools that cover this stage. Each label says whether the tool has an MCP server of its own. The ones with a directory page link to it.