Route AI agent tasks to the right model
Does every step of your AI agent need the biggest model? Param Harrison explains why most teams send every request to a big model and pay for it. Planning is often the creative part, and the rest is close to deterministic. So split the work: a small model for simple steps, a bigger model where you need more. In browser automation, try a lower model first and escalate after a few failures. From his own eval, his pick is a low effort model, then high effort on failures. He also covers planning with Opus and building with Sonnet. Then teacher and student models. Do not cut output tokens unless your evals check the quality. After this lesson you can route each task to the right model.
What this covers: big and small models, splitting work, escalating on failure, and effort levels. It also covers Opus and Sonnet, golden sets, teacher and student models, and output limits.
Full session: Cut AI Agent Costs with Token Economics
#aiagents #llm #aicost
Chapters
- Not every call needs the big model
- Low effort first, high on failure
- Plan with a big model, build with a smaller one
- Teacher and student models
- Limit output tokens only with evals
Transcript
Not every call needs the big model
Now most teams send every request to the bigger model, yeah. Like that's good actually. when they are actually sending to bigger model, their output quality will be good. But at what cost? Since not every call need to be on bigger model, this is one of the findings. Like if you are using just Opus for all your tasks, you will be burning a lot of token, but what you achieved might be the same. Of course, there are tasks where those models will excel very well. For example, Fable for deep research and Opus for you know task which is more creative, but then most of the time our tasks are going to be only the plan is going to be creative, and after that, all the execution is going to be very very much like deterministic. So then you don't need entire entire model to be on only one model, which is costlier. Rather, you can split like okay, what goes to small model and what goes to big model. This depends on what kind of task we are doing, and based on that, yeah, a classic example is like in your chatbot, you have you know you are you are asking for a webs web web fetch, and web fetch will find what is the value for that, or like user asked for some details, and your chatbot is asking web to find out what is the grounded information for that, and it is responding to that. Now, the response summary can be done by Haiku, but the actual web fetch can be done by a bigger model like Sonnet. That way, you can able to split half of the work where you know the case higher capabilities are required, you can do it with higher capability, and then the lower capability can be done. This this is very useful in browser automation where you can try with lower model, and then if multiple iterations it is failing, you put a threshold and then you you go for you escalate to a bigger model instead of directly going into larger model for everything, then your cost will accumulate quite fast. oftentimes these Hermes or OpenClaw they do research on every day and they post in your Slack or things like that. If you put only single model for every task, then your cost will be unmanageable. But when you are actually choosing, picking and choosing, like okay, for this task, go for this model. And if if multiple iterations it is not going to be solvable, then go for escalated model. That way you can able to control the cost accordingly. Let's see it in real numbers.
Low effort first, high on failure
Like when your quality floor is 95%, which effort do you think or do you ship low on every step, high on every step, low, then high on failures. So my pick in such cases is lower model, then high on failures. This is one of the one of the learning I have done and I have utilized in my not just for coding tasks but also for agentic tasks as well. So when you are running every step to a high effort model, then what happens is like you will be able to achieve 95.3 percent, for example. and extra high will be even better, like 96.7. But the surprising part is when you are picking low, then high on failure. So if your agentic loop is optimized enough that first run low, second run low, and the third run go for higher model. In most cases, most of the task in your eval suite the golden set, you will be able to achieve in low itself, and then some of the task will go for low, then high on failures, then you will be able to achieve you know the average cost, which is a bit higher than low, but it is still comparatively lower than middle.
Plan with a big model, build with a smaller one
That is where you know one of the bigger recommendations for coding agent by anthropic is like most of the companies doesn't need high or extra high effort. They can pick medium effort and they can pick you know Opus plan. Opus plan is more than enough for any anyone who provides a very clear spec. So if your spec is very detailed enough on what to verify in your coding agent, it is better to you know go for Opus plan so that because your planning is already done almost, so you just need to translate the product spec into your engineering spec, and then you need to like de decompose that task into granular task. That is the only thing which requires brain to be done, and that brain can be Opus, and then the execution can be deferred to Sonnet. Anything which requires deeper research beyond, you know, you don't know what is the what is the final output. For example, UIUX, where you are actually experimenting that hey, can you show me multiple versions of this UI UX which which is inspiring from these UX patterns or so, then that is a very different question where the output is not deterministic, you are expecting your research to be done at that point. You can go for all in with more higher model. So that is where it is better to pick and choose based on your task, you need to evaluate whether this task recures requires money or not. this task requires this model like bigger model, bigger money or smaller model, smaller money to be spent.
Teacher and student models
One of the bigger patterns usually you can follow is teacher student model in your AI agent. Most of the time, if you pre if you are already preparing your golden set with your evaluation, so this is where the product manager's role will come into picture more and more in agentic development where they will be focusing on you know best cases, worst cases, and in their eval suite, and if you can deterministically know what kind of eval you are going to do, and of course, when you are actually operating, after that, also you need to find the traces and you need to you know enrich your golden set, then you will be able to create your model in such a way for specific flows, you can pick low model for specific flow, so you can create your own routing that can able to eliminate. So I'm not saying in your version one itself you will arrive at, but as you operate, as you operate and traces those, your next versions can actually be able to go better and better.
Limit output tokens only with evals
So here this is also a main thing you need to consider, like sometimes like we try to minimize the output token just because the output token cost is so high, so I will minimize that, but you need to check at what cost, unless and until your evals are actually able to find what is the quality of the output, you can't even say these numbers. In this case, anthropic is actually measuring what is the evals and whether the quality is good or not. So if you are reducing the max tokens without knowing what will be the end result, then you are in a guessing game that okay, I I reduced my cost, but at what cost? So that you need to be very careful at.
This lesson comes with Pro, $149 a year: Get Pro. This lesson is cut from the free Lightning session Cut AI Agent Costs with Token Economics. The Live Labs build the same system with you, free, on Thursdays: see the Live Labs.
