Chapter 29. Model Selection, Cost and Release Planning
- Approved by
- Panaversity ·
Start here if you skipped Chapter 28
If you read Chapter 28, skip this. These are the words from the chapters before it that this chapter builds on.
| Word | What it means | Where this chapter uses it |
|---|---|---|
| Token, usage | A token is a small piece of text that a model reads or writes. Prices are per million tokens, with one price for input and another for output. Every response reports its usage: how many tokens it read and wrote (21.12) | Everywhere |
| Caching | Keeping the start of a request on the provider's side, so the next request that starts the same way reads it at a fraction of the price (21.12). The usage shows tokens written to the cache and tokens read from it as their own counts | The point, 29.2, 29.6, 29.7 |
| Model pinning | Naming the exact model id in one place, such as src/loop/config.json, so the model changes only when you choose (21.13). The extraction's pin is claude-sonnet-5-5 | 29.3, 29.5 |
| Budget | A hard cap, in dollars, on what one hosted session may spend. When a company pays you a fixed monthly fee, every run is your cost, not theirs (23.5). Cedar Ridge Supply pays Brightline such a fee | Why it matters, 29.9 |
| The morning triage | The worker's scheduled run at 7:10 on each weekday. It is a hosted session with a budget of $0.50, and a check by code tests what it returns (23.16) | The point, 29.4, 29.6, 29.8 |
| The month-end review | Dave's review of the open invoices, on a budget of $1.00, tested by Lab 26's check by code (Chapter 26) | 29.4, 29.6 |
| The extraction step | For each new invoice, before 7:10, the portal's code makes two requests to the Messages API. The first asks for the invoice with the get_invoice tool. The second answers after the tool result (Chapter 25) | Everywhere |
| The three gates | The extraction's checks by code, in order: the stop reason (why the model stopped writing), the schema (the shape of the answer) and the values (each one against the record). An answer that fails a gate is not used (25.10) | Everywhere |
| The 7:10 report | The morning list of every answer the code would not accept, each with its gate and its reason, and a count by gate (25.10) | The point, 29.1, 29.6 |
needs_review | The status of a result that code would not accept. It waits for a person, and is never posted as done (Lab 24) | Everywhere |
| Golden set, suite | The golden set is cases with known answers, labeled by Ana (24.2). The suite runs them. It has 42 cases: 26 questions and 16 extractions | Everywhere |
| Trial, pass^k | A trial is one run of one case. pass^k is the chance that all k trials of a case are right. Before a release, each case runs three trials (24.6) | 29.1, 29.3, 29.5 |
| Chapter 27's table of steps | docs/architecture.md, with one row for each step of a job and who decides it (27.1) | 29.6 |
The point
Tuesday, May 11, 2027, 9:00 in the morning. You are the builder. Dave Kowalski, Brightline's controller, forwards the Console's cost for the week of Monday, May 3 to Sunday, May 9. The Console is the vendor's web page for your account and its bill. Dave adds one question: "What does one invoice cost us, and can it cost less without Ana seeing worse answers?"
The bill cannot answer him. It lists calls and tokens by model. The 7:10 reports list invoices, by gate. Nothing joins the two.
So you join them. Each model call in the week wrote one line to the portal's usage log, usage/week.jsonl, with its step, its company, its model and its usage. You check that the log's total matches the Console's. You set Cedar Ridge's lines apart, because Dave asked about Brightline. Then you divide. What Brightline's new invoices cost goes on top. The invoices that passed every gate and appeared in a posted 7:10 report go below. The result is the cost of each invoice handled right.
By step, the extraction is the largest line. It runs twice for every new invoice. Next you look at how much of its input was read from the cache. That part is its cache share. Anthropic reports that agent loops read a median 84% of their input from the cache, and says: "Below about 80%, look for something breaking the cache."1
10:15. You add two cache breakpoints. A cache breakpoint is a marker that tells the API where to save the start of a request (29.7). One goes after the tools and the rules. One goes at the end of each invoice's first request, so the second request reads it. A rerun of Monday, May 3's invoices raises the cache share. A cache changes the price, not the answer, so you do not run the suite.
10:45. First you try a lower effort on the model you have, because effort changes less than a model does (29.3). You run the 16 extraction cases on Sonnet 5.5 at medium effort, three trials each. You keep the lowest effort whose lowest trial matches high's. A smaller model is tried only when lowering effort stops saving.
11:00. You send the 16 extraction cases as one batch, which means many requests sent together and answered later, at half the price (24.6). Each case runs three times on Sonnet 5.5 and three times on Haiku 5.5, a smaller and cheaper model. Both models use the same output limit and the same effort, which means how hard the model works (29.2). Each request has its own id, such as INV-8340-haiku-t2. An extraction is two requests, so the batch goes in two rounds. When round 1 ends, round 2 goes. Until a round has ended, the result waits.
2:30 p.m. The batch is back, and the keep rule decides whether the smaller model stays. Whatever it decides, it is kept only for now. Next week's gate counts confirm it. You send Dave the headline and two lines, one for the cache and one for the model. A third line, for moving the extraction to an overnight batch, follows on Wednesday. It comes after the batch's first run at 1:00 a.m., with its measured delay.
You have met every piece of this before. In 12.5 you chose a model and an effort for your coding agent. You also read that Chapter 29 shows how to measure what each choice costs. The new thing is the unit. The bill counts calls. Brightline is paid for results.
So before you change anything, answer one question. Last week's bill says what each call cost. What did one invoice handled right cost Brightline, and which change lowers that without lowering what Ana's suite measures? Start with what a call is made of: tokens (29.1).
For managers
An AI Worker's bill counts tokens, the small pieces of text a model reads and writes. Your company is not paid for tokens. It is paid for work done right. This chapter shows a builder how to price that work, and how to lower the price without lowering the quality.
The unit is one accepted result: a piece of work that passed every check that code makes on it. What a step spends, divided by its accepted results, is its cost per accepted result. For Brightline, the invented company in this book, that is one invoice the worker read correctly. Dave Kowalski, its controller, gets one headline each week. It is the week's spend on Brightline's own invoices, divided by the new invoices that passed every check and appeared in the morning report. A cheaper call that sends one more invoice to a person is not a saving. It moves the work to Ana Morales, the accounts payable (AP) analyst who reads the morning report.
The builder works in four steps:
- Group the week by step. Each part of the worker that calls a model is a step: reading invoices, the morning triage, the month-end review. The bill groups cost by model. The builder groups it by step, and finds the step that costs most.
- Match each cost to its lever. A lever is a change that can lower one kind of cost. Repeated text points to caching. Work nobody waits for points to a batch, which costs half as much and answers later. Long answers point to less effort, or a smaller model. Then name the binding constraint, which is the one requirement a cheaper choice must still meet. For reading invoices it is quality. For a batch it is the 7:10 deadline.
- Change one thing, and check it the way it can fail. A change to the price or the timing cannot change the answers. So it is checked by what it can break: the cache, or the deadline. A change to the answers, such as a smaller model, runs the worker's test cases three times, on the old and the new model together.
- Report each change against the same baseline. Each change gets one line, with its saving in dollars a week. Savings are never added up, because two changes together are measured as a run of their own.
Ask your builder five questions:
- What did one accepted result cost last week, and in which step?
- What is the one requirement the cheaper choice must still meet?
- How was the change checked: by the test cases, by the cache, or by the deadline?
- What is the saving in dollars a week, and was it measured alone?
- Which model is pinned, and how do we go back to the old one?
The price of this method is test runs. A change to the answers costs a run of the test cases before anyone knows whether it is a saving. And one part of the worker, Ana's questions in the portal, has no check by code while it runs. It is judged on its test cases alone, and the chapter says so.
Why it matters
Brightline runs its own invoices and Cedar Ridge's for a fixed monthly fee, so every run is Brightline's cost, not Cedar Ridge's (23.5). That includes every run that failed and every run that ran twice. A call can get cheaper while the work gets more expensive. A cheaper call that sends more invoices to needs_review moves the work to Ana's morning. A smaller model that does worse on Chapter 24's suite is no saving that Brightline can use. A batch that finishes after 7:10 misses the morning triage.
Anthropic's own advice for comparing models has the same shape: "Compare on cost per solved task, not per token."1
The chapter never puts a price on Ana's time, because no source gives one. It counts the results stopped at a gate instead, in every report, beside the dollars.
Figure 29.1 shows the week Dave asked about, by step.
Figure 29.1. Last week, by step. Each step has its own spend, its own accepted results and its own cost per accepted result. The suite and the portal questions have no accepted count.
How this chapter works
The chapter has ten concepts and one lab. Read the concepts in order.
Every price on a page is dated 30 November 2026 in its footnote. Prices change, so the book checks them each month, and the lab copies them on the day you run it (F5).2 Where a concept uses a feature in beta, a test stage that can still change, it says so.
Two words are kept narrow. "Accepted" always means passed the step's own checks by code. "Saving" always means a lower cost per accepted result, measured, with the check it passed.
Five subjects belong to other chapters. Caching's basics are 21.12's, and 29.7 adds only where the breakpoints go. Errors by class, and falling back to another model, are 30.4's. Carrying a model change through three environments is 30.6's. Files and images are 30.3's. The cost of serving many companies is Chapter 43's.
After this chapter you can:
- Explain why the same request can pass one run and fail the next, and why the same text counts as more tokens on another model.
- Set effort and the output limit on purpose, and check a change to either on the suite.
- Choose a model for each step by its cost per accepted result, and write down the constraint that decided it.
- Plan a release for a new model: pin it, test it, switch one step at a time, and keep a way back.
- Read a week of usage by step, find the dominant cost, which is the step that spent the most, and match it to its lever.
- Place cache breakpoints by how often each part of a request changes.
- Move work to a batch only where it still meets its deadline.
- Write each saving in dollars a week, with the check it passed.
What you will build
Who's who. You are the builder. Dave Kowalski is Brightline's controller. He owns AP policy and reads the bill. Ana Morales is Brightline's AP analyst. She reads the 7:10 report each morning and labeled the golden set. Brightline Wholesale Supply is the invented wholesale distributor whose AP worker you have built since Chapter 16. Cedar Ridge Supply pays Brightline a fixed monthly fee to run its invoices too.
Where you are. You start from the AP worker at the end of Lab 28, at tag ch28. This chapter uses four of its model steps, all built before Chapter 28. The extraction reads each new invoice in two requests, before 7:10, behind three gates, on claude-sonnet-5-5. The morning triage runs at 7:10 as a hosted session, with a budget of $0.50. The month-end review runs on a budget of $1.00. Ana asks the worker questions in the portal. The suite holds 42 cases, and runs on each pull request. Nothing in the worker yet says what any of this costs for each invoice.
What you build, in Lab 29, from tag ch28 to tag ch29:
- Price the week. Tag each call with its step, and price the usage log at today's prices. Count the accepted results from the five 7:10 reports, and check the total against the Console's. Then find the dominant cost.
- The cache. Place breakpoints on the extraction's requests, rerun one day, and measure the cache share and the saving.
- The batch. Run 20 extractions in realtime and as two batch rounds, and match the results. Send an errored request to
needs_review, and write the rule that runs at 6:45. - A smaller tier. Run the 16 extraction cases on Sonnet 5.5 and Haiku 5.5, three trials each, in one batch, and apply the keep rule.
- The release plan. Write
docs/release-plan.mdfor a new model id.
The lab's page is published once its runs are recorded. 6. The port, for practice. Price the same week on OpenAI and on an open model.
Every task runs from recorded files, so you need no API key. The report you send Dave is docs/cost-report.md. As in Chapters 17 to 27, coding agents write every file and run every command. You specify, check and approve.
In this chapter
| Section | The question it answers |
|---|---|
| 29.1 Tokens, context windows and why output varies | Why can the same request pass the gates one run and fail the next, and why does the same text count differently on another model? |
| 29.2 Thinking and effort | When does more thinking pay, and how do you know? |
| 29.3 Tiers: quality, latency and cost | Which model gives one step the lowest cost per accepted result, without losing a case? |
| 29.4 The binding constraint, and writing the justification | What one requirement decides each step's choice, and how do you write it down? |
| 29.5 Release planning | When a new model comes out, how do you switch without a surprise, and go back if you must? |
| 29.6 Reading a usage report | Where did last week's money go, step by step? |
| 29.7 Caching by how often content changes | Where do the breakpoints go, by how often each part of a request changes? |
| 29.8 Realtime or batch | Which work can wait for a batch and still be ready at 7:10? |
| 29.9 Token budgets, and quantifying a saving | Which limit stops what, and how do you write a saving in dollars a week? |
| 29.10 How today's tools realize it | How do Claude, OpenAI and an open model price the same week, and what do you measure the same way on each? |
| Lab 29 | Five tasks and a port, from tag ch28 to tag ch29, each change checked the way it can fail |
| Check yourself | One open question for each concept, with an outline of its answer |
Sources
- Owner
- Panaversity