Pick a model per job and degrade sensibly when one fails — a quality bar per call site, candidates compared on the same task set, a readable routing rule, and an explicit retry-versus-fallback path with pinned model ids. Use when cost or latency has become a problem, when adding a cheaper or larger model to an existing system, or when a fallback fires silently and quality drops without anyone noticing. Not for prompt authoring, not for retrieval tuning, and not for capacity or infrastructure planning.
Routing is a claim that one job needs less than another. That claim is either measured or it is a
guess with a billing line attached. The expensive mistake is not picking the wrong model — it is
switching models and having no way to notice what got worse.
When this fires
A system calls more than one model, or is about to, and someone needs to decide which call goes
where and what happens when a call fails. It also fires when a fallback exists and nobody can say
how often it triggers. It does not fire for a single call site with no cost or latency pressure —
there, one capable model and no routing layer is the correct design.
Procedure
Enumerate the jobs, not the models. Each call site is a job with its own latency budget,
output shape, error tolerance, and whether a human sees the output before it has an effect.
Routing decisions belong per job; a single global "which model do we use" question has no
answer.
Write the quality bar for each job before looking at any candidate. What output counts as
acceptable, and how that is checked: exact match, schema validity, a rubric, a graded sample,
human spot check. Without a bar, "the cheap one is fine" is an opinion that cannot be argued
with or refuted.
Do not build a routing layer before there is a measured problem. One capable model
everywhere, instrumented for cost and latency per job, is the right starting point. Routing
added on anticipation is a permanent source of drift for a saving nobody has sized.
Build a task set per job — 20–50 real inputs with known-acceptable outputs, drawn from
production traffic where possible, including the awkward ones. Every candidate is judged on the
identical set; a candidate evaluated on its own examples proves nothing.
Run each candidate against it and compare in this order: pass rate against the bar first,
then latency, then cost per accepted output. Cost per token is the wrong unit — a cheap model
that fails a third of the time and needs a retry, a repair pass, or a human is not cheap.
Re-tune the prompt per candidate before concluding. A prompt shaped around one model's
habits can fail on another for reasons that have nothing to do with capability. If you did not
re-tune, say the comparison is provisional.
Route on observable properties of the request: input size, whether structured output is
required, whether tools are called, whether the result is user-facing, whether a human reviews
it. Keep the rule as a readable table mapping condition to model. Do not add a classifier to
choose a model until the table has been measured and found wanting.
Pin model identifiers explicitly and record them with every result. Moving aliases drift
under you, and an evaluation whose exact model id and date were not recorded cannot be compared
with anything later. Check the provider's current documentation for the id rather than
recalling one.
Separate retry from fallback in the failure path. A rate limit, timeout or transient
overload is a retry against the same model with backoff and jitter. A refusal, a persistently
failing validation, or a provider outage is a fallback to a different model. Wire the retry
mechanics from the idempotency-and-retries skill; a retried call with a side effect needs an
idempotency key regardless of which model answered.
Validate the fallback's output the same way you validate the primary's. The common
production failure is a fallback that returns quickly, passes no check, and is served.
Make degradation visible. Every response records which model answered, whether it was the
fallback, and whether validation failed first. Alert on fallback rate, not only on errors — a
silent fallback converts a quality regression into a mystery weeks later.
Cap the chain. A budget per request and per session, a maximum number of hops, and a
defined behaviour when the cap is hit: refuse, queue, or ask the user. An unbounded fallback
chain turns one bad request into an unbounded bill.
Keep the routing rule in configuration, so a bad route is a config change rather than a
deploy. One table, one place — not a per-call-site conditional scattered through the codebase.
Re-measure after the routing change lands, per job: pass rate, cost per accepted output,
latency, and fallback rate. An average that improves while one job's pass rate halves is a
regression that the average is hiding.
Checklist
Jobs enumerated with their own latency, structure and review requirements
A written quality bar and a check method per job
One task set per job, used unchanged for every candidate
Prompts re-tuned per candidate, or the comparison labelled provisional
Candidates compared on pass rate, then latency, then cost per accepted output
Routing rule expressed as a readable table on observable request properties
Model ids pinned and recorded with every measurement and every response
Retry and fallback distinguished, with backoff and jitter on the retry path
Fallback output validated with the same check as the primary
Which model answered, and any fallback, is recorded and alertable
Budget and hop caps set, with a defined behaviour at the cap
Post-change per-job measurements taken, not just an aggregate
Failure handling
A candidate wins on average but loses on a subset — that subset is a job. Split it and route
it separately; do not average it away.
The task set is too small to separate two candidates — say so and report the result as
inconclusive. A five-example difference is noise, and shipping on it is how quality drifts.
The cheaper model passes but the outputs are subtly worse — the bar is too loose. Fix the
bar before re-running; a check the bad output passes is not a check.
Fallback rate is high — treat it as a capacity or provider problem first. Routing more
traffic to the fallback hides the signal instead of resolving it.
Switching a production route — that changes what users receive. Propose it with the numbers
and ask; roll it out behind the config from step 13 so it can be reverted without a deploy.
A provider's published numbers are the only evidence — they are not comparable across
vendors and were not measured on your task. Cite them as context, never as the result.
Evidence to report
The job table with each job's quality bar; the task set size and where its inputs came from;
per-candidate pass rate, latency and cost per accepted output, with exact model ids and the date
run; whether prompts were re-tuned per candidate; the routing rule as written; the retry and
fallback paths with their caps; and, after the change, per-job before-and-after numbers plus the
observed fallback rate. "We route the easy ones to the small model" with no task set and no model
ids is a preference, not a measurement.
1---2name: model-routing3description: Pick a model per job and degrade sensibly when one fails — a quality bar per call site, candidates compared on the same task set, a readable routing rule, and an explicit retry-versus-fallback path with pinned model ids. Use when cost or latency has become a problem, when adding a cheaper or larger model to an existing system, or when a fallback fires silently and quality drops without anyone noticing. Not for prompt authoring, not for retrieval tuning, and not for capacity or infrastructure planning.4---56# Model routing78Routing is a claim that one job needs less than another. That claim is either measured or it is a9guess with a billing line attached. The expensive mistake is not picking the wrong model — it is10switching models and having no way to notice what got worse.1112## When this fires1314A system calls more than one model, or is about to, and someone needs to decide which call goes15where and what happens when a call fails. It also fires when a fallback exists and nobody can say16how often it triggers. It does not fire for a single call site with no cost or latency pressure —17there, one capable model and no routing layer is the correct design.1819## Procedure20211. **Enumerate the jobs, not the models.** Each call site is a job with its own latency budget,22 output shape, error tolerance, and whether a human sees the output before it has an effect.23 Routing decisions belong per job; a single global "which model do we use" question has no24 answer.252. **Write the quality bar for each job before looking at any candidate.** What output counts as26 acceptable, and how that is checked: exact match, schema validity, a rubric, a graded sample,27 human spot check. Without a bar, "the cheap one is fine" is an opinion that cannot be argued28 with or refuted.293. **Do not build a routing layer before there is a measured problem.** One capable model30 everywhere, instrumented for cost and latency per job, is the right starting point. Routing31 added on anticipation is a permanent source of drift for a saving nobody has sized.324. **Build a task set per job** — 20–50 real inputs with known-acceptable outputs, drawn from33 production traffic where possible, including the awkward ones. Every candidate is judged on the34 identical set; a candidate evaluated on its own examples proves nothing.355. **Run each candidate against it and compare in this order**: pass rate against the bar first,36 then latency, then cost per *accepted* output. Cost per token is the wrong unit — a cheap model37 that fails a third of the time and needs a retry, a repair pass, or a human is not cheap.386. **Re-tune the prompt per candidate before concluding.** A prompt shaped around one model's39 habits can fail on another for reasons that have nothing to do with capability. If you did not40 re-tune, say the comparison is provisional.417. **Route on observable properties of the request**: input size, whether structured output is42 required, whether tools are called, whether the result is user-facing, whether a human reviews43 it. Keep the rule as a readable table mapping condition to model. Do not add a classifier to44 choose a model until the table has been measured and found wanting.458. **Pin model identifiers explicitly and record them with every result.** Moving aliases drift46 under you, and an evaluation whose exact model id and date were not recorded cannot be compared47 with anything later. Check the provider's current documentation for the id rather than48 recalling one.499. **Separate retry from fallback in the failure path.** A rate limit, timeout or transient50 overload is a retry against the same model with backoff and jitter. A refusal, a persistently51 failing validation, or a provider outage is a fallback to a different model. Wire the retry52 mechanics from the idempotency-and-retries skill; a retried call with a side effect needs an53 idempotency key regardless of which model answered.5410. **Validate the fallback's output the same way you validate the primary's.** The common55 production failure is a fallback that returns quickly, passes no check, and is served.5611. **Make degradation visible.** Every response records which model answered, whether it was the57 fallback, and whether validation failed first. Alert on fallback rate, not only on errors — a58 silent fallback converts a quality regression into a mystery weeks later.5912. **Cap the chain.** A budget per request and per session, a maximum number of hops, and a60 defined behaviour when the cap is hit: refuse, queue, or ask the user. An unbounded fallback61 chain turns one bad request into an unbounded bill.6213. **Keep the routing rule in configuration**, so a bad route is a config change rather than a63 deploy. One table, one place — not a per-call-site conditional scattered through the codebase.6414. **Re-measure after the routing change lands**, per job: pass rate, cost per accepted output,65 latency, and fallback rate. An average that improves while one job's pass rate halves is a66 regression that the average is hiding.6768## Checklist6970- [ ] Jobs enumerated with their own latency, structure and review requirements71- [ ] A written quality bar and a check method per job72- [ ] One task set per job, used unchanged for every candidate73- [ ] Prompts re-tuned per candidate, or the comparison labelled provisional74- [ ] Candidates compared on pass rate, then latency, then cost per accepted output75- [ ] Routing rule expressed as a readable table on observable request properties76- [ ] Model ids pinned and recorded with every measurement and every response77- [ ] Retry and fallback distinguished, with backoff and jitter on the retry path78- [ ] Fallback output validated with the same check as the primary79- [ ] Which model answered, and any fallback, is recorded and alertable80- [ ] Budget and hop caps set, with a defined behaviour at the cap81- [ ] Post-change per-job measurements taken, not just an aggregate8283## Failure handling8485- **A candidate wins on average but loses on a subset** — that subset is a job. Split it and route86 it separately; do not average it away.87- **The task set is too small to separate two candidates** — say so and report the result as88 inconclusive. A five-example difference is noise, and shipping on it is how quality drifts.89- **The cheaper model passes but the outputs are subtly worse** — the bar is too loose. Fix the90 bar before re-running; a check the bad output passes is not a check.91- **Fallback rate is high** — treat it as a capacity or provider problem first. Routing more92 traffic to the fallback hides the signal instead of resolving it.93- **Switching a production route** — that changes what users receive. Propose it with the numbers94 and ask; roll it out behind the config from step 13 so it can be reverted without a deploy.95- **A provider's published numbers are the only evidence** — they are not comparable across96 vendors and were not measured on your task. Cite them as context, never as the result.9798## Evidence to report99100The job table with each job's quality bar; the task set size and where its inputs came from;101per-candidate pass rate, latency and cost per accepted output, with exact model ids and the date102run; whether prompts were re-tuned per candidate; the routing rule as written; the retry and103fallback paths with their caps; and, after the change, per-job before-and-after numbers plus the104observed fallback rate. "We route the easy ones to the small model" with no task set and no model105ids is a preference, not a measurement.
Run npx skillmds@latest add nahid-sparktales/model-routing in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Pick a model per job and degrade sensibly when one fails — a quality bar per call site, candidates compared on the same task set, a readable routing rule, and an explicit retry-versus-fallback path with pinned model ids. Use when cost or latency has become a problem, when adding a cheaper or larger model to an existing system, or when a fallback fires silently and quality drops without anyone noticing. Not for prompt authoring, not for retrieval tuning, and not for capacity or infrastructure planning. It is listed under AI & ML on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Capability flags: reads secrets. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
nahid-sparktales (@nahid-sparktales) published this skill. Their other Agent Skills are listed on their SkillMD profile.