Sub topic 13
Judging Models by Cost per Resolved Task
This chapter assumes you can read basic Python and know how input and output tokens are billed. It also assumes you know that an agent loop resends its context on every turn.
Why price per token misleads
A price list gives dollars per million tokens. It does not tell you how many tokens a model uses to finish a job, or how often it finishes at all. A cheap model may need more turns, make more wrong edits, and fail more often. A stronger model may cost more per token but solve the task in fewer steps.
The number that matters is what you pay for each task that ends up solved.
The metric
Cost per resolved task is total spend divided by the number of tasks that were actually resolved. Total spend includes every attempt, failed ones too.
def cost_per_resolved(total_cost_usd, resolved_count):
if resolved_count == 0:
return float("inf")
return total_cost_usd / resolved_count
# Placeholder results from running the same 50 tasks with two models.
cheap = cost_per_resolved(total_cost_usd=20.0, resolved_count=20) # 1.00
strong = cost_per_resolved(total_cost_usd=45.0, resolved_count=40) # 1.125
print(cheap, strong)The strong model spent 2.25 times as much in total. Per resolved task it costs only 12.5% more, because it resolved twice as many tasks. If the strong model resolved 45 tasks instead of 40, it would cost $1.00 per resolved task and tie the cheap one. A small change in success rate can flip the ranking.
How to run the comparison
- Pick a fixed set of tasks that look like your real work. Use the same repository state and the same agent setup for every model.
- Define "resolved" before you run anything. A passing test suite is a good check. "Looks right" is not.
- Record the usage data for every request, including failed runs and retries.
- Sum the cost per model, count resolved tasks, and divide.
Common errors
- Dropping failed runs. If you only price the successful attempts, every model looks cheaper than it is. Failures still consume tokens.
- Too few tasks. With 10 tasks, one lucky or unlucky run moves the result a lot. Use enough tasks that a single outlier does not decide the answer.
- Weak success checks. If "resolved" is judged loosely, a model that produces plausible but broken edits will score well.
- Ignoring latency. Cost per resolved task says nothing about how long a task takes. Record wall-clock time next to cost if waiting matters to you.
- Mixing setups. If one model ran with caching or extra thinking and the other did not, the comparison measures the setup as well as the model.
Using the result
Cost per resolved task also feeds routing. If a small model resolves test-running and summarizing steps at nearly the same rate as a large one, route those steps to it. Reserve the large model for steps where its success rate pays for the higher price. Measure the routed setup the same way, as one system, and compare it to using a single model for everything.
Exercise
Model A costs $30 in total across 60 tasks and resolves 30 of them. Model B costs $48 in total across the same 60 tasks and resolves 48 of them. Which model has the lower cost per resolved task, and what are the two values?
Show answer
Model B. Model A costs 30 / 30 = $1.00 per resolved task. Model B costs 48 / 48 = $1.00 per resolved task. They tie, so on cost alone neither wins. Model B resolves more tasks, which makes it the better choice if latency and unresolved work matter to you.