Cost and latency are not dashboard garnish bolted onto a working agent after the fact — they are correctness criteria in the same sense that giving the right answer is a correctness criterion. An agent that resolves every ticket correctly but costs $4 to do so, or takes ninety seconds when a human would answer in ten, has failed a requirement just as surely as one that gives the wrong answer. The eval suites and trajectory judges from earlier lessons in this course ask “did the agent do the right thing”; this lesson asks “did it do the right thing at a cost and a speed the business and the user can actually tolerate,” and both questions have to pass together before a production agent ships.
The trap is that both numbers look fine in aggregate and hide catastrophic failure in the tail. A dashboard reporting “average cost per resolution: $0.06” or “average latency: 22 seconds” can describe a fleet where the worst 1% of runs are five, ten, or twenty times that — runs that are quietly bankrupting the unit economics or making a handful of users furious, invisible behind a mean that barely moves. Averages are the wrong statistic for exactly the failure mode agents are most prone to: multi-step loops that occasionally spiral, retry, or get stuck, multiplying both cost and latency far past the typical case.
This lesson covers how to attribute cost correctly across five dimensions — per run, per user, per tenant, per tool, and per prompt version — why input and output tokens are priced asymmetrically and why cached tokens change the arithmetic again, how to decompose latency into the pieces that actually drive user perception, why a 10-step agent loop multiplies both cost and latency rather than adding to them, and the difference between stopping a runaway run before it happens and merely being told about it afterward.