Model routing seems like a simple task. But only until production

18 Aug 2026

Problem

Teams running LLM agents try to save money by sending easy requests to a cheap model and hard ones to an expensive model. In agent loops this breaks down. The model is called dozens of times with a growing context. Token prices, caching, trajectory length, queues and company rules all change the real cost and latency. In the authors' test, a router that only predicts difficulty reached similar accuracy at a higher cost.

Example from the article: IBM Research ran one CodeAct agent on 417 AppWorld tasks. GPT-4.1 has cheaper tokens than Claude Sonnet 4.6 but cost $155 against $79 for the full run.

Solution in brief

Treat routing as a system optimization, not request classification. Measure the cost of a completed task, search for router configurations that give different cost, latency and accuracy mixes, and let the system owner pick one point on that frontier. Re-check the router whenever models, prices or infrastructure change.

Questions this case answers
  • How to route requests among several models of different price and quality when cost per completed task, not per token, drives the budget and the workload is a multi-step agent loop
  • How to pick a model-routing policy that trades off cost, latency and accuracy when task difficulty cannot be known before execution
  • How to choose which LLM handles each request or task in an agent system when cost, latency and quality all matter?
  • How to estimate the real cost of an LLM agent per completed task instead of comparing token prices?

Tools and methods

  • Model routing — choose a model per task or per step across cost, latency and accuracy.
  • CodeAct agent on AppWorld — the test setup: 417 multi-step API tasks, code-writing agent.
  • Claude Sonnet and Opus, gpt-oss-120b — the models mixed by the router in the figure.
Continue reading — it's free

Google or a one-time email code. No password.