How-to

How to Route Coding Tasks Across Three Model Tiers—and Measure the Savings

November 28, 2026

How to Route Coding Tasks Across Three Model Tiers—and Measure the Savings

A coding agent may format a file, implement a routine change, or investigate a hard cross-service bug. Sending all three to a frontier model can waste spend; sending all three to the cheapest model can create failed calls, retries, and more work for developers.

A three-tier workflow routes tasks to fast, balanced, or frontier models according to the work they require. The objective is not to avoid paying for failures. It is to reduce the cost of a completed task while keeping quality, latency, and developer effort within acceptable bounds.

There is a useful but bounded real-world example. In LangChain’s Open SWE router write-up, the team describes an A/B test across 973 threads, split about evenly between a three-tier router and a control that always used its top-tier model. Median cost per thread was $0.94 for routed threads versus $2.61 for the control. The routed group sent 34% of threads to fast, 56% to balanced, and 10% to performance. The result is specific to Open SWE’s traffic and compares routing with an expensive default, not with a well-chosen mid-tier model. 1

The quality results need equally careful reading: merged PR rates were 29.2% for routed threads and 27.3% for the control, with no statistically significant difference (p = 0.49). PR open rates were also not significantly different. That does not establish that quality was identical. In a follow-up test, LangChain stopped sending all tasks to the fast model within a day after users complained about output quality. 1

The lesson is not “always route.” It is to test whether your workload has enough variation in difficulty to make routing worthwhile—and to keep a stronger tier available for the work that needs it.

1. Define tiers by the work

Treat tiers as cost-and-capability policies, not permanent model names. Models and prices change; the types of work your coding agent handles are a better starting point.

TierTypical coding workExample starting rule
FastFormatting, narrow transformations, or a test for clearly specified existing behaviorStart here when the task is bounded and the expected change is easy to verify.
BalancedRoutine bug fixes, test generation, or a scoped feature in one serviceStart here when the task changes behavior but has clear acceptance criteria.
FrontierAmbiguous root-cause analysis, cross-service changes, architecture, or high-consequence workStart here when the task requires broad judgment or the cost of an incorrect change is high.

A short prompt is not necessarily an easy task, and a long prompt is not necessarily a hard one. Route on task type, risk, and evidence from your own workload—not token count alone. For sensitive work, set a minimum tier rather than leaving the decision to a classifier. One AWS Builder Center example uses keyword rules so a request mentioning a “threat model” cannot be routed to its cheapest tier. Its accompanying test used 120 synthetic prompts, evenly divided among tiers; those results show how that router behaved on its test set, not how it will perform on your traffic. 2

The table should come from evaluation, not intuition. LangChain’s guidance for its router was to build tier criteria from the team’s task analysis and provider descriptions of model strengths:

“Write each tier's criteria from two sources: your own task analysis, and what each provider says its models are best at.”

— Sydney Runkle and Eugene Yurtsev, LangChain 1

2. Build evaluations before assigning traffic

Use traces or logs to identify the coding tasks your agent actually handles. Group them into categories such as bug fixes, feature requests, test generation, and code review, then sample real examples from each. LangChain used Open SWE traces to understand its task mix before writing its routing criteria. 1

For each category, define a quality bar that reflects the consequence of failure. A formatting task might require a clean diff and passing checks. A change to authorization or payment logic may need tests, review, and a stricter acceptance threshold.

Run candidate models on the same examples. Assign a task type to the least expensive model that clears its quality bar, and keep the resulting routing table in configuration so you can update it without scattering model choices through application code. 3

“Route each task to the cheapest model that clears its bar, record the decision in configuration rather than in code, and re-run the evaluation whenever models or prompts change.”

— Frontier Engineering 3

If task types are predictable, begin with deterministic rules and metadata. Add a classifier only when the request’s content or difficulty makes rules insufficient, and evaluate the classifier separately from the coding models. LiteLLM, for example, supports mapping multiple tiers to the same model while teams test whether their candidate models separate meaningfully. 4

A classifier can misroute tasks and may add a model call, latency, and another failure mode. Start with the simplest approach that performs well on your evaluation set. LangChain’s model-routing discussion, covered by 1 Minute Signal, also argues for testing model performance on the task rather than relying on brand preference; treat that as a reason to evaluate blindly where practical, not as evidence that models are interchangeable. 5

3. Use an explicit validation and escalation rule

Here is a concrete rule for a routine but behavior-changing task: “Fix the null-handling bug in this one service and add a regression test.” Start it in the balanced tier because the change affects behavior but has a defined scope. Require the focused test, relevant existing tests, and lint or type checks to pass. If the same validation still fails after one repair attempt—or the work expands into another service—escalate to frontier. If the task is an ambiguous cross-service root-cause investigation from the outset, start at frontier instead.

Task exampleStarting tierValidation gateEscalation trigger
Format a file or add a test for specified existing behaviorFastFormatting and relevant tests pass; diff stays within scopeThe task requires a behavior change or the checks fail after a repair
Fix a scoped bug with clear acceptance criteriaBalancedFocused and regression tests pass; lint or type checks passThe same gate fails after one repair, or the change expands in scope
Investigate an ambiguous cross-service failureFrontierIntegration checks and appropriate human reviewDo not start lower simply to create an opportunity to escalate

These are starting rules to validate, not universal thresholds. A two-consecutive-failure threshold is one example of escalation logic; teams should set their own based on task risk and evaluation results. Bound attempts and tool-call iterations, too. A cheap model stuck in a loop can cost more than a stronger model that finishes. 6, 7

Do not confuse a provider outage with a model-quality failure. Use provider failover for a temporary service error; escalate tiers when the task is proving too difficult or failing its quality gate. Record the selected tier, validation outcome, escalation reason, and final result for each task. 8

1 Minute Signal coverage of The Pragmatic Engineer’s interview with Satya Nadella emphasizes the growing importance of verification as code generation gets cheaper. That is useful context for this workflow, not a measured result about model routing. 9

4. Keep switching costs in the calculation

Coding agents often make multiple calls within one task. Switching models can lose prompt-cache value or require context to be resent, so do not reclassify every message by default. A practical starting point is to choose a tier at the beginning of a task, keep it pinned through tool calls, and allow a switch when a defined validation or difficulty signal justifies the cost.

“Routing decisions must account for the cost of cache misses due to switching models.”

— Applied Compute 10

LangChain’s Open SWE router selected a model from the first human message and used it for the thread; its write-up notes that mid-thread rerouting was deferred partly because of possible cache-miss costs. Per-request routing can adapt when a task becomes harder, but the switch should be worthwhile after accounting for cache and context costs. 1, 10

Model choice is not the only cost lever. Separately from routing, Cloudflare’s AI code-review write-up discusses call count, context size, and caching as drivers of review cost. Its figures concern that specific reviewer and are not evidence of what a three-tier router will save. 11

5. Measure completed tasks and know when not to route

Before rollout, run the proposed policy in shadow mode alongside the current route. Compare by task category, not just in aggregate. Track completion and review outcomes, latency, retries, escalations, and cost per completed task. Include classifier calls, failed attempts, validation, and follow-up model calls in the cost calculation; a cheaper first response is not a saving if it needs repeated repairs. 3, 12

Compare against a realistic baseline. LangChain’s result is a useful case, but its control always used the most expensive model. Your own comparison should also test whether a fixed, well-chosen mid-tier model would perform nearly as well with less routing overhead. And remember that merged PR rate is a proxy for outcomes, not a complete measure of long-term code quality. 1

Routing may not be worth building for a low-volume workload, a system with essentially one task type, or traffic where nearly every task is equally difficult. If there is little work to route down a tier—or no reliable way to evaluate whether a cheaper model succeeds—the engineering and classifier overhead can outweigh the savings. 3, 6

For a live rollout, monitor escalation rate alongside cost per task and quality. A rising escalation rate may mean traffic has changed, a lower tier has regressed, or the routing criteria need updating. Version the routing table for each task, roll out gradually, and keep a rollback path if quality or latency deteriorates. 3, 7

A three-tier router is a hypothesis about your workload, not a guaranteed discount. Keep it only if your evaluations and production outcomes show that the least expensive suitable tier completes more tasks at lower total cost—without shifting the bill into retries, review, or developer time.

Share this

Tags

Written by: 1 Minute Signal Editorial Team