Lesson 8.1: Cost, latency and choosing a model for each step
Learn how to cut an agent's cost and delay by matching the model to each step, and why the cheapest model per call is not always the cheapest per finished task.
By the end of this lesson you will be able to break an agent run into steps and price each, choose a model for each step by what the step needs, route easy steps to a small model and hard ones to a large one, count the cost of failures along with the cost of calls, and cut delay by removing waits. You will work out that sending the seven easy steps of a ten-step run to a small model cuts the cost of a run from ₹10 to ₹3.70 and the time from 60 to 32 seconds, and that after counting what failed runs cost to repair, the cheaper design costs ₹34.80 per task against ₹30.87 for the dearer one, unless the small model is as accurate on easy steps as the large one, when it costs ₹24.60. You should have read Lessons 6.4, 7.1 and 7.4, and, if you can, Lesson 8.1 of the AI Engineering track on cost and latency. No code is needed. The mathematics is weighted averages and powers.
Module 7 made agents safer and more reliable. Module 8 is about running them, day after day, at a cost the organisation will accept. An agent that works in a demo can be too slow for a user who is waiting, or too expensive to run ten thousand times a day. The AI Engineering track covered cost and delay for a single model call: caching, batching, shorter prompts. An agent adds something new. It makes many calls in one run, and they are not all alike. Some are hard and some are trivial. That opens a powerful lever: use a different model for each kind of step.
An agent run is many different jobs
Look at what a typical run involves. A support agent receiving a request might: classify the request, look up the customer, read the policy, reason about whether a refund applies, write a reply, check the reply against a rubric and format it for the channel. Those are seven jobs. Classifying a request into one of six kinds is easy, and a small, fast model does it well. Formatting needs almost no thought. Deciding whether an unusual refund applies under a subtle policy is hard and may need the strongest model you have.
If you use one model for everything, you pay the price of the hardest step for all of them, and you wait for it every time. Two things follow. For easy steps you are overpaying and waiting needlessly. For hard steps, a model that is too small will make mistakes. The skill is to give each step the cheapest model that does it well enough.
The price of a model
Models differ in three ways that matter here.
Price per token. Large models can cost ten or more times as much per token as small ones from the same family. Prices change, so check your provider's list. This lesson uses example figures.
Speed. Small models usually respond faster, both in time to the first word and in words per second. A call that takes 6 seconds on a large model may take 2 on a small one.
Ability. Large models are usually better at hard reasoning, long instructions, subtle judgment and unusual cases. On easy, well-defined tasks, the gap is often small.
The practical consequence is that the right model depends on the step, not on the agent.
Pricing a run step by step
The first task is to know where the money goes. For a real agent, take a sample of traces and, for each step, record the tokens in and out, the model used, the cost and the time. Lesson 8.2 explains how to collect these. Then ask three questions of the table.
Which steps are most numerous?
Which steps cost the most in total?
Which steps are easy, meaning a small model would likely do as well?
A common finding is that a few steps account for most of the cost, usually the ones with large contexts, and that many cheap-looking steps are easy ones that do not need the large model. Another is that the final steps, such as formatting, are an easy target.
Matching model to step
A rough guide for choosing:
Step kind · Needs · SuitsClassify or route · Pick among a few labels · Small model, with a few examples
Extract fields · Read text, fill a schema · Small or medium model, with schema checking
Format, rewrite, translate · Follow a template · Small model
Summarise · Faithful condensing · Small or medium, check on long inputs
Plan a task · Break a goal into steps, anticipate problems · Larger model
Decide between tools with subtle differences · Judgment and context · Medium or large
Reason through an unusual case · Careful multi-step logic · Large model
Check or critique · Spot errors in another's work · Medium or large, ideally a different model
This is a starting point, and the only reliable way to know is to test. For a given step, run the same fifty or so real examples through each candidate model, grade the results as in Lesson 7.1 and compare quality, cost and time. You will often find that the small model matches the large one on a step you assumed was hard, and fails one you assumed was easy.
Routing: choosing at run time
There are two ways to choose a model for a step.
Fixed assignment. You decide in advance: step 1 uses the small model, step 4 uses the large one. This is simple, predictable and easy to test. Use it where the step's difficulty is known.
Dynamic routing. A cheap check decides at run time. The classifier step might label a request "routine" or "unusual" and send the unusual ones to the large model. Or a small model tries first, and the system uses a confidence signal or a check on its output to decide whether to try again with a larger model. This is called a cascade: try the cheap one, escalate if it looks wrong. It saves most when most cases are easy, and it needs a reliable way to tell when the small model has failed. A cascade whose "is this good?" check is weak will let the small model's mistakes through.
Lesson 5.3 discussed routers for choosing between agents. The same ideas apply to choosing between models: a router must be measured, and it needs a fallback when unsure.
The arithmetic of routing
Take a ten-step run. Seven of the steps are easy, and three are hard. A large model costs ₹1.00 a step and takes 6 seconds. A small model costs ₹0.10 a step and takes 2 seconds.
All large: cost 10 × ₹1.00 = ₹10.00, time 10 × 6 = 60 seconds.
Routed, with the seven easy steps on the small model and the three hard on the large: cost 7 × ₹0.10 + 3 × ₹1.00 = ₹0.70 + ₹3.00 = ₹3.70, time 7 × 2 + 3 × 6 = 14 + 18 = 32 seconds.
Routing cuts the cost by 63 per cent and the time by 47 per cent. That is a large saving for a change that touches only the easy steps. But look at what the figures leave out.
The trap: cheap calls are not cheap tasks
A small model is usually a little less accurate than a large one, even on easy steps. Suppose, on an easy step, the large model is right 99 per cent of the time and the small one 98 per cent. On a hard step, the large model is right 98 per cent of the time. The chance that the whole run is right is the product of the step accuracies, as Lesson 6.4 showed.
All large: 0.99⁷ × 0.98³ = 0.9321 × 0.9412 = 0.877, or 87.7 per cent.
Routed: 0.98⁷ × 0.98³ = 0.98¹⁰ = 0.817, or 81.7 per cent.
A one-point loss per easy step has become a six-point loss per run, because the losses compound. Now count what failure costs. Suppose a failed run must be repaired by a person, costing ₹150 of their time plus ₹20 of handling, so ₹170. The cost per task, including repairs, is the call cost plus the failure rate times ₹170.
All large: ₹10.00 + 0.123 × ₹170 = ₹10.00 + ₹20.87 = ₹30.87.
Routed: ₹3.70 + 0.183 × ₹170 = ₹3.70 + ₹31.10 = ₹34.80.
The routed design is cheaper per call and dearer per task. The saving of ₹6.30 in calls is more than eaten by the extra ₹10.23 of repairs. This is the central lesson: price the finished task, not the call. Where a failure is costly to repair, a more accurate model is cheaper.
The picture changes if the small model is as accurate as the large one on the easy steps. Suppose it is right 99 per cent of the time on them too. Then the routed run succeeds 0.99⁷ × 0.98³ = 87.7 per cent of the time, as with all large, and costs ₹3.70 + 0.123 × ₹170 = ₹24.57, saving ₹6.30 per task over all large. So the answer depends on the accuracy gap on the easy steps, and you can only know it by measurement.
Predict first: routing the seven easy steps to a small model cuts the call cost from ₹10 to ₹3.70, but lowers the chance of a correct run from 87.7 to 81.7 per cent. If a failed run costs ₹170 to repair, which design is cheaper per finished task? Decide before reading on.
The all-large design is cheaper, at ₹30.87 against ₹34.80. If repairs cost only ₹20 instead of ₹170, routing would win, since it would cost ₹3.70 + 0.183 × 20 = ₹7.36 against ₹10 + 0.123 × 20 = ₹12.46. The break-even is where the failure cost makes the extra failures worth more than the call saving.
Cutting delay
Delay matters when someone waits, and it comes from sources other than the model. Look at where a run's time goes.
Model time. The sum of every call. Small models help here, as above.
Tool time. A slow database query, a web search or an external API. Often the biggest part.
Sequential steps. Steps that could overlap but run one after another.
Waiting. For a person's approval, a queue, a rate limit or a retry.
Hidden thinking. Models that reason at length before answering take longer. Use extended reasoning only for the steps that need it.
Seven practical remedies:
1. Run independent steps in parallel. Three lookups that do not depend on each other can run together, as in Lesson 5.4. Elapsed time is the longest, not the sum.
2. Use small models for easy steps, as above.
3. Shorten the prompt and the output. Tokens in and out both take time. Ask for a short structured answer and not an essay.
4. Cache what repeats. The fixed prompt and tool definitions can be cached by the provider, and repeated tool results, such as a policy lookup, can be cached by you.
5. Stream the output to a waiting user, so they see the start while the rest is produced.
6. Cut the number of steps. Combining two tools into one, or letting a step return more of what the next will need, saves a whole model call. Lesson 6.1's advice on task-shaped tools helps here.
7. Do the slow work in the background where the user need not wait, and tell them it will follow. Lesson 8.3 covers this.
A caution on parallel work: it does not reduce cost, and it can raise it if you start several attempts and keep the first, a technique called hedging. Use it for the delays that matter most.
Controlling the cost of context
Lesson 7.2 of the AI Engineering track showed that an agent's cost grows faster than its steps, since each step re-sends the history. In a model-per-step design this matters even more, because the cost of a step is also set by how much it must read. Three habits help.
Give each step only what it needs. A formatting step needs the final text, not the whole history. A routing step needs the request, not the tool results. Building a small, tailored input for each step, instead of passing the whole conversation to every model, cuts tokens and often improves accuracy, since there is less to distract.
Trim and summarise, as in Lesson 4.3.
Limit tool results, as Lesson 7.4 advised.
A cost model for your agent
Build a simple spreadsheet or script that predicts cost and time per run from a handful of numbers.
For each step kind: tokens in, tokens out, the model, the price and the time.
How often each step occurs per run, on average and at the high end.
The success rate per step and per run, and the cost of a failure.
Runs per day.
From it you can read the cost per task, the daily bill, and what happens to both if you change a model, cut a step or double the traffic. Check it against the real bill from time to time. A model of cost that is never checked against the invoice will drift from the truth. Set a budget per task from the value of the task: if a task saves ₹150 of human time, an agent costing ₹35 a task is a good deal, and one costing ₹140 is not.
Three worked examples
Example 1: a classification step
A triage agent used a large model for every step, at ₹6 a run. Traces showed that 40 per cent of the cost was a first step that classified the request into one of eight kinds. The team tested a small model on 200 labelled requests and found it matched the large model 97.5 per cent of the time against the large model's 98 per cent. They moved only that step. Cost per run fell from ₹6.00 to about ₹3.84, time fell by 3 seconds and the overall success rate moved by less than a point. They left the other steps alone.
Example 2: a cascade that did not pay
A team tried a cascade for a contract-review step: a small model reviewed each clause and a large one rechecked those the small one flagged. The flag check was weak. The small model missed 12 per cent of the problem clauses and did not flag them, so the large model never saw them. Recall on problem clauses fell from 96 to 86 per cent. A missed clause costs a lawyer's time later and sometimes much more. The team went back to the large model for the review step, and used the small one only to split the contract into clauses.
Example 3: latency from tools, not the model
A scheduling agent took 22 seconds per request, and users complained. The first reaction was to change models. The trace breakdown showed 3 seconds of model time, 14 seconds in three calendar lookups run one after another, and 5 seconds waiting on a slow availability service. The team ran the lookups in parallel, cached the availability data for two minutes and cut the run to 8 seconds. The model was never the problem.
A checklist for cost and delay
1. Record tokens, model, cost and time for every step in a sample of real runs.
2. Find the steps that dominate cost and time, and the ones that look easy.
3. For each candidate step, test two or three models on 50 or more real examples. Compare quality, cost and time.
4. Choose fixed assignment where difficulty is known and a cascade only if a reliable check exists.
5. Price the finished task: calls plus the expected cost of failures. Do not judge by call price.
6. Give each step only the input it needs.
7. Cut delay: parallel steps, fewer steps, short outputs, caching, streaming and background work.
8. Build a cost model, compare it with the bill and set a budget per task from the task's value.
9. Retest when models or prices change.
Common mistakes
One model for every step. You overpay for easy steps.
Judging by price per call. Failures cost money too.
Assuming the small model is as good. Measure it on your steps.
Cascades with a weak check. Small-model errors slip through.
Passing the whole history to every step. It costs tokens and distracts.
Blaming the model for delay. Look at tool time and waiting first.
Using extended reasoning everywhere. Use it only where a step needs it.
A cost model nobody checks. Compare it with the invoice.
Choosing once and forgetting. Models and prices change.
Key takeaways
A run has many jobs of different difficulty. Match the model to the step: small for classifying, extracting and formatting, large for planning and hard judgment.
Choose by fixed assignment where difficulty is known, or by cascade where a reliable check exists.
Routing seven of ten steps to a model a tenth of the price cuts a run from ₹10 to ₹3.70 and from 60 to 32 seconds.
Price the finished task. Small errors multiply across steps, and with ₹170 repairs the routed design cost ₹34.80 a task against ₹30.87, but ₹24.57 if the small model was as accurate on easy steps.
Delay comes from tools, sequential steps and waiting as well as models. Parallelise, shorten, cache, stream, cut steps and move slow work to the background.
Give each step only the context it needs.
Build a cost model, check it against the bill, set a budget from the value of the task and retest when things change.
Check yourself
1. Why use different models for different steps of one agent?
Steps differ in difficulty. Easy steps do not need the cost and delay of a large model, while hard steps may need it.
2. A run has 8 steps, 5 easy at ₹0.10 on a small model and 3 hard at ₹1.00 on a large one. What does it cost?
5 × ₹0.10 + 3 × ₹1.00 = ₹0.50 + ₹3.00 = ₹3.50.
3. Each of 10 steps is right 98 per cent of the time. What is the chance the run is right?
0.98¹⁰ = 0.817, about 81.7 per cent.
4. Why can a cheaper model make a task dearer?
If it fails more often, the extra failed runs, each needing repair, can cost more than the saving on calls.
5. Name three ways to cut delay that do not involve changing models.
Any three of: run independent steps in parallel, shorten prompts and outputs, cache repeated work, stream output, cut the number of steps and move slow work to the background.
6. What is a cascade, and what does it depend on?
A cascade tries a cheap model first and escalates to a larger one if the result looks wrong. It depends on a reliable check for when the cheap model has failed.
Try this
Set aside seventy-five minutes.
1. Take one real or imagined agent run. List its steps, and for each note the tokens, the model and the time.
2. Mark each step easy, medium or hard, and say why.
3. Pick the two steps you would try on a smaller model. Write the test: 50 real examples, the grader and what accuracy you will accept.
4. Use the simulator with your own prices, times and accuracies, and a realistic cost to repair a failure. Is routing worth it?
5. Draw where the delay comes from: model, tools, waiting. List the three biggest remedies.
6. Decide what each step really needs as input, and shrink the context for two of them.
7. Set a budget per task, based on the value of the task, and note how you will check actual cost against it.
A good result is a cost and delay plan for one agent: a step table, model choices with test results, a per-task cost with failures counted, and a list of delay fixes. Lesson 8.2 supplies what this lesson needs and what every operator needs: seeing what the agent did.
Tags: Agentic AI Model selection Cost Latency Agent operations