Topic 72

The Cost Model

Cost

Cost per resolved ticket is the number that decides whether an agent is a product or a demo. Sundry's support agent started at $0.41 and ends this book at $0.06, and not one cent of that came from a cheaper model or a better deal with the provider.

Read the chain before the arithmetic, because the headline hides where the work happened. Prefix caching took 41 cents to 14 in Chapter 5. Routing by task type took 14 to 11 in Chapter 7. The triage split in Chapter 10 then put 11 back up to 12 on purpose, buying handle time with money and saying so. So this page starts at twelve cents and takes six off — not thirty-five — and those six are the hard ones, because everything obvious has already been done.

The chain is not monotonic improvement — one step went up on purpose, and this page starts at twelve cents rather than forty-one
$0.41where Chapter 1 left it
CACHING$0.14Chapter 5 · the prefix stops being re-billed
ROUTING$0.11Chapter 7 · routing by task type
UP 11% · NOT A SAVING$0.12Chapter 10 · the triage split, on purpose
SIX LEVERS, JOINTLY$0.06this chapter · the hard six

The Unit Is a Resolved Ticket

A ticket that ran twelve turns, hammered track_parcel nine times, hit the loop limit and escalated cost $0.34 and settled nothing. Chapter 8 tells that story as a control-flow failure; on a cost report it is worse than that, because per-call and per-ticket averages both absorb it silently. Only the per-resolution figure treats it as what it is: money spent, work not done, and a person still needed.

So the denominator is resolutions, not tickets, with escalations left in the numerator where they belong. At 4,200 tickets a week and 88% resolution, six cents a ticket is $252 of model spend against 3,696 resolutions — 6.8 cents each. On the twelve-cent figure this chapter starts from, the same arithmetic gives 13.6 cents. That is the number to put next to what a person costs, and it is the only one that survives contact with somebody who asks what happens to the other 12%.

Where twelve cents go — and the foundation of the stack is the row most cost work is spent inside
Tool results, re-sent every remaining turn · 4.4 cents · 37%
A tool result is not a return value that disappears. It is context, so a fat result arriving on turn 3 of a nine-turn ticket is billed six more times — which is why shaping two results at the boundary returned 2.2 cents, the largest lever on the page.
Prefix that missed the cache · 2.6 cents · 22%
What the growing history costs on the turns it is billed in full. Holding the hit rate at 94% instead of 86% returned 1.1 cents and changed no behaviour.
Retrieved policy passages · 1.6 cents · 13%
Two passages instead of five, and none at all on the status class, returned 0.8 cents — and the same change makes the remaining passages easier for the model to read.
Deliberation output tokens · 1.3 cents · 11%
Thinking out loud is billed like any other output. Restricted to decision turns on both specialists, it returned 0.3 cents without moving the trajectory score.
Triage classification and handoff envelopes · 1.2 cents · 10%
The bill for the split two chapters back, paid on the 45% of tickets that leave triage. It is not waste and it is not a saving either — it is what fifteen seconds of handle time cost.
Final replies, system prompt and schemas · 0.9 cents · 7%
The smallest row in the breakdown, and where most cost-reduction effort in this field goes. A fortnight of careful prompt editing works entirely inside these nine tenths of a cent, for about 4% off a number nobody notices.

Where the Money Went

Nobody can optimize a number they cannot decompose, so this topic follows tracing rather than preceding it. Once every model-call span carries its token counts, tagging each one with what the tokens were spent on — schemas, history, tool results, retrieved passages, deliberation, the final reply — turns the invoice into a breakdown. Here is Sundry's, at twelve cents a ticket, blended across the whole queue.

Where the tokens wentCents per ticketShare
Tool results, re-sent every remaining turn4.437%
Prefix not served from cache2.622%
Retrieved policy passages1.613%
Deliberation output tokens1.311%
Triage classification and handoff envelopes1.210%
Final replies, system prompt, schemas0.97%

The top row is the one that surprises teams and should not. A tool result is not a return value that disappears — Chapter 3 established it as context, re-sent on every remaining turn of the run, so a fat result arriving on turn 3 of a nine-turn ticket is billed six more times. The bottom row is where the system prompt lives. It is 7% of the bill, and it is where most cost-reduction effort in this field goes, which is how a fortnight of careful prompt editing ends up worth 4%.

The Levers, Ranked by What They Actually Returned

Every lever below already exists in this book. What Chapter 13 added was not a technique but the breakdown, which said where to point the techniques next. Each row was measured on its own against the same replayed week of production traffic, so the numbers are comparable to each other rather than to a plan.

LeverBuilt inCents returned
Shaping track_parcel and search_orders results at the boundaryChapter 32.2
Model routing per task, not per agentthis topic1.5
Holding the cache hit rate at 94% instead of 86%Chapter 51.1
Two passages instead of five, and none on the status classChapter 60.8
Turn limits and the thrash guardChapters 7 and 80.5
Deliberation on decision turns only, on both specialistsChapter 70.3

Two things about that table are worth more than the ordering. It sums to 6.4 cents and the measured result of shipping all six together was 6.0, because the levers overlap — tokens removed by shaping are tokens the cache no longer has to hold, and a run that ends four turns earlier stops paying for everything at once. Report the joint figure, not the sum. And the largest row is a technique Chapter 3 taught nine chapters ago, applied to two tools it never got around to: get_order was shaped early because it was obvious, while the carrier's full scan history — around 1,100 tokens for a parcel with a long journey — went straight into context untouched until the breakdown pointed at it. Trimmed to the last three scans plus the delivery state, it is 150 tokens.

Model Routing

Route by task, not by agent. Sundry's triage agent already ran on a small fast model in Chapter 10; what this chapter added was splitting the specialists' own turns — classification, field extraction and composing the reply for the status class go to the small model, while policy judgement and any turn that can end in money stay on the large one. On the 120-ticket eval set resolution held at 106 of 120, the trajectory score did not move, and the blended saving was 1.5 cents.

The version before that one was greedier and got rejected, which is the more useful half of the story. Sending the whole returns class to the small model saved another 0.9 cents and dropped resolution to 97 of 120 — seven points. Seven points on 4,200 tickets a week is 294 more tickets landing on a person at roughly $2.40 each, about $700 a week, to save $38. Route a class to a cheaper model without running the eval set and that is the trade you are making blind; run it, and the answer takes eleven minutes and costs less than lunch.

Budgets and Alerts

Two ceilings live in code, next to the turn limit from Chapter 1. A per-run ceiling of 50 cents ends the run stuck and escalates with a summary, the same way the turn limit does, because a run that has spent eight times the mean has already failed at something. A per-day budget trips a circuit breaker that routes new tickets to the human queue rather than silently degrading — an agent that quietly stops trying is worse than one that visibly stops.

The alert is on the ratio, never the total. Sundry's total model spend doubled on a Monday afternoon when a seller's consignment went missing and 340 near-identical tickets arrived in three hours; cost per resolution never moved, because nothing was wrong. A regression looks completely different: volume flat, cost per resolution up 25% over a six-hour window against the seven-day median, which is the condition that pages somebody. On total spend those two events are the same graph, and a team that alerts on total spend learns within a month to ignore the alert.

Comparing Honestly

Sundry's support team handles a ticket in about six minutes at a loaded cost near $24 an hour, so the human baseline is roughly $2.40. Six cents against $2.40 is the number that gets put on a slide, and it is wrong by a factor of nearly three, because the agent does not handle the queue on its own and never will.

What the agent actually costs, per ticket in the queueCents
Model spend6.0
Escalations: the 3% a person takes over, at $2.40 each7.2
Approval review: the other 3% of the same 6% queue, about fifteen seconds of a lead's time0.3
Errors and goodwill, measured over a quarter3.0
Total16.5

Sixteen and a half cents against $2.40 is still a large number and it is a defensible one. It survives the first question anybody senior asks, which is what happens to the tickets the agent cannot finish, and the second, which is what it costs when the agent is confidently wrong. State one more thing while the ledger is open: the human baseline carries its own error rate, and at Sundry nobody had ever measured it — so the fair reading is that the agent's mistakes are counted and the team's are not, and the comparison is generous to the agent in exactly one place.

Common Mistakes
  • Reporting cost per model call — the 34-cent run that burned twelve turns and resolved nothing looks like a dozen ordinary calls, and the report says the calls are cheap.
  • Optimizing the system prompt while tool results are 37% of the bill — that is a fortnight of careful editing spent inside the 7% row, for about 4% off a number nobody notices.
  • Routing a class to a cheaper model without an eval run — seven points of resolution costs about $700 a week in escalations to save $38 in tokens, and the trade is invisible until somebody measures it.
  • Alerting on total spend — a Monday volume spike and a genuine regression draw the identical graph, so the alert gets muted and the regression runs for a fortnight.
Best Practices
  • Report cost per resolved ticket with escalations counted in the numerator, and publish the resolution rate beside it.
  • Tag every model call's tokens by category so the breakdown exists before anybody argues about which lever to pull.
  • Measure every routing change on the eval set before it ships, and price the resolution movement in escalations rather than in points.
  • Alert on cost per resolution against a rolling median, and put a per-run ceiling and a daily circuit breaker in code.
Comparable toolsProvider usage dashboards the invoice, undecomposedHelicone per-request metering through a proxyLiteLLM routing and per-key budgetsLangfuse cost attributed per runBraintrust cost per case in the eval report

Knowledge Check

Why does Sundry report cost per resolved ticket rather than cost per ticket or per model call?

  • Runs that spend money and resolve nothing are absorbed silently by the other two units
  • Per-call figures are not available from providers, so a per-resolution figure has to be derived
  • A per-resolution unit smooths the resolution rate out of the report, leaving cost comparable
  • Only a per-resolution unit can separate cached input tokens from uncached ones

In Sundry's twelve-cent breakdown, tool results are 37% of the bill and the system prompt sits in a 7% row. What follows?

  • Remove tools from the surface until the schema block is small enough to stop mattering
  • Lower the turn limit, since fewer turns is the only way to stop paying for tool results
  • Shape the results at the tool boundary, because every one is re-sent on all remaining turns
  • Rewrite the system prompt more aggressively, since it is the part under your direct control

Routing the whole returns class to the small model saved 0.9 cents a ticket and dropped resolution from 88% to 81%. Why was it rejected?

  • The smaller model was measurably slower on policy questions, pushing p95 past the product target
  • Routing money decisions to a second model violates the refund ceiling enforced in the dispatcher
  • Seven points sits inside the eval set noise band, so the measurement proved nothing in either direction
  • Seven points is 294 more escalations a week at $2.40 each, which costs far more than the tokens saved

Total model spend doubles on a Monday afternoon. What tells you whether this is a volume spike or a regression?

  • The error rate over the same window, which rises only when something has actually broken
  • The average turn count per run, which rises whenever the agent is behaving differently
  • Cost per resolution against its rolling median, because volume moves the total and not the ratio
  • The prompt cache hit rate, which falls whenever spend rises for any underlying reason

What belongs in an honest comparison between the agent's six cents and a person's $2.40?

  • The hosting and queue infrastructure the agent runs on, amortized across the weekly volume
  • The engineering time spent building the agent, divided over the tickets it has handled so far
  • The share of the provider's model training and serving infrastructure cost attributable to Sundry's own usage
  • The 6% of tickets a person still handles, the review time on approvals, and the cost of the agent's mistakes

You got correct