Model selection and routing

Step 8 of 14. Store Assist handles very different requests, and not all of them need your strongest model. This step covers choosing the simplest reliable path for each request type and proving the choice with evidence.

Model routing in 60 seconds

  • What: routing sends each request to the cheapest path that reliably meets the quality and safety bar, which is often code and not a model.
  • Start simple: begin with rules based on request type, action and permissions. Add a model-assisted router only if tests show it pays.
  • Cascade: try a cheaper path first, check the result against a rule, and escalate only the cases that fail.
  • Do not trust confidence: a model's own certainty is a weak signal. Use observable checks such as sources found and validation passed.
  • Judge by cost per success: a cheap model that fails often can cost more per resolved question than a capable one.

The problem it solves

It is tempting to wire every request to the strongest model available. The design is simple, and it costs more, answers more slowly than needed, and ties the whole product to one provider. It also wastes capability. The model that untangles a three-system fault does not need to tell a colleague how to restart a scanner.

Store Assist sees a wide spread. A colleague might want a short procedure, a digest of a lengthy incident write-up, a ticket raised, or help with a problem that crosses stock, devices and the point of sale. These are different jobs. The better design matches the path to the job.

The options you can route to

  • Deterministic code: the right home for calculations, validation, permission checks and fixed business rules. It is exact, free and fast.
  • Classical classifiers: small trained models for plain categorisation, such as sending an incident to one of a fixed set of support queues.
  • Smaller language models: good for intent detection, query rewriting, field extraction and short summaries, as long as your evaluation shows the quality is enough.
  • More capable language models: worth their price for vague questions, multi-step reasoning, combining several sources and hard troubleshooting.
  • Specialised services: speech recognition, optical character reading of a photographed label, embedding generation and similar tasks, where a purpose-built model beats a general one.

The aim is not to use many models. It is to pick the simplest thing that meets the requirement reliably. Counting the days between two dates should be done by application code, not by asking a model to do arithmetic. Deciding whether a colleague may approve a refund should be a permission check against a rule, never a model reading policy text and forming a view.

A starting routing table

Here is a first routing table for Store Assist. Treat it as a hypothesis. The right entries depend on what you measure for accuracy, speed, context size, provider uptime and price, and they will change.

Request typeRouteLatency budget (p95)Why
Greeting or thanksFixed reply from code50 msNo model is needed for a fixed answer.
Repeated public procedure questionSemantic cache, then fall through150 ms on a hitSee Step 7: Semantic caching.
Scanner troubleshootingRetrieval plus mid-size model1.5 s to first tokenGrounded in a guide, with moderate reasoning.
Long incident report summaryCapable model with a large context window8 s totalLong input and synthesis justify the cost.
Stock or incident statusLive service call, small model to phrase the reply1.5 s to first tokenThe facts come from the service, so little reasoning is needed.
Raise an incident ticketSmall model extracts fields, code validates them3 sExtraction is easy to check against a schema.
Reset my till PINIdentity workflow, no generationWorkflow dependentSensitive. Never improvised by a model.
Refund over £150 or price overrideRules engine and manager approvalApproval dependentAuthority is a rule, not a judgement call.
Photo of a damaged labelText-reading service, then a small model4 sA purpose-built reader is more accurate.
Cross-system fault with unclear symptomsCapable model with tools8 s totalHard reasoning is the reason to pay for capability.
The router picks a path from the request type and permissions, and always has a safe fallback.

Rules first, a model router later

A rule-based router reads facts you already hold: the request type, the action asked for, the colleague's permissions and a rough complexity score such as input length. It is predictable, cheap and easy to debug, because you can read the rule that fired.

A model-assisted router can handle messy, free-form requests that rules cannot sort. It also adds a model call, another thing that can fail, and extra delay before real work starts. So begin with rules. Add a model-assisted step only for the slice of traffic where tests show it improves outcomes by more than it costs, and give it a rule-based fallback if it fails or times out.

The cascade pattern

A cascade tries cheap first and escalates on need. It has four stages.

  1. Run the low-cost path.
  2. Test the result against a stated quality bar.
  3. Pass cases that fail or look uncertain up to a more capable model.
  4. If that still does not settle it, return a safe fallback or ask the colleague a clarifying question.
A cascade escalates only the cases that fail a check, and ends in a safe fallback instead of a guess.

A cascade lowers average cost, but only if you can tell when the cheap path was not good enough. That is the hard part, and it leads to the next point.

Confidence is not correctness

Models can be fluent and wrong at once, and a number a model reports about its own certainty is a poor guide to whether it is right. Base routing and escalation on signals you can observe from outside.

  • Did retrieval return relevant sources, and were they cited?
  • Were all required fields extracted, and do they pass the schema?
  • Did the answer pass the groundedness and policy checks?
  • How has this route performed on a representative test set for this request type?
  • Did the colleague rephrase, thumbs-down or ask for a person straight after?

For high-risk actions, an uncertain model opinion is never a substitute for authorisation or human approval. Refunds, price overrides and PIN resets stay on their own paths, whatever a model believes about them.

Evaluate before you optimise

Before you choose a model for any route, build a representative evaluation set from real and synthetic questions. Include common questions, vague ones, unusual phrasing, cases where the manuals are out of date, requests that hinge on permissions, and cases where the right answer is "I do not have enough to say". For each route measure the following.

  • Task success and correctness of the answer.
  • Grounding in the retrieved evidence.
  • Response time, both to first token and in total.
  • Input and output tokens consumed.
  • Cost per successful task.
  • Failure rate and escalation rate.

The last two bullets matter most in practice. A cut-price model can end up dearer per resolved question when its failures need retries, escalations or a person. The goal is neither the cheapest nor the cleverest model. Aim for the least expensive path that still meets quality and safety needs.

Store Assist, worked through

Use the illustrative price of £0.40 per million input tokens and £1.60 per million output tokens for the capable model. At 1,000 input and 250 output tokens, one attempt costs £0.0004 plus £0.0004, which is £0.0008. Suppose a smaller model costs a quarter of that, £0.0002 per attempt. Suppose that on your evaluation set the small model succeeds 70 percent of the time and the capable one 92 percent.

StrategyCost per attemptSuccess rateCost per successful task
Capable model only£0.000892%£0.0008 / 0.92 = £0.00087
Small model only£0.000270%£0.0002 / 0.70 = £0.00029, with 30% of colleagues badly served
Cascade, small first, with a validator that catches 90% of small-model failures£0.0002 + 0.27 x £0.0008 = £0.00041670% + 0.27 x 92% = 94.8%£0.000416 / 0.948 = £0.00044

The cascade costs about half as much per success as the capable model alone, and its success rate is higher than the small model's by 24.8 points. Over 1.08 million requests a month it comes to roughly £449, against £864 for the capable model alone. The weak point is the validator. The 3 percent of cases where the small model fails and nothing notices are the ones that reach colleagues as wrong answers, so the validator's catch rate is what you must measure and defend.

Be careful with the headline. The model bill is far below the £0.03 target for cost per resolved question, so the larger cost of a bad route is a colleague losing minutes, retrying, or calling the support desk. A single percentage point of failures across 36,000 requests a day is 360 colleagues a day. Weigh routes on that, not on tokens alone.

Now a release. A new routing policy sends scanner troubleshooting to a different mid-size model. First run it in shadow: it receives a copy of live traffic and its answers are scored but never shown. If groundedness and latency hold, enable it for 5 pilot stores as a canary, then widen it.

Rule-based router with a cascade and versioned config (illustrative) (python)
import json

ROUTES = json.load(open("routing_v14.json"))   # versioned config, reviewed like code
MAX_ESCALATIONS = 1          # one step up, then fallback
MIN_GROUNDED = 0.95          # quality bar for accepting a cheap answer
DEADLINE_S = 8.0             # whole-request budget

SENSITIVE = {"pin_reset", "refund_over_limit", "price_override"}

def route(request, user, started_at):
    # 1. Sensitive actions never reach a model-chosen path.
    if request.kind in SENSITIVE:
        return workflow_for(request.kind, user)      # placeholder: identity or approval flow

    cfg = ROUTES[request.kind]                        # e.g. {"chain": ["small", "capable"], ...}
    chain = cfg["chain"]
    last_failure = None

    for step, model_name in enumerate(chain[: MAX_ESCALATIONS + 1]):
        remaining = DEADLINE_S - (now() - started_at)
        if remaining < cfg["min_budget_s"][model_name]:
            break                                      # not enough time left for this step

        result = call_model(model_name, request, timeout_s=min(remaining, cfg["timeout_s"][model_name]))
        if result.ok and result.sources_found and result.grounded >= MIN_GROUNDED \
                and schema_ok(result):
            return result                              # observable checks, not self-reported confidence
        last_failure = result.failure_reason

    return safe_fallback(request, reason=last_failure)  # clarify or hand off, never guess

workflow_for, call_model, schema_ok, safe_fallback and now are placeholders. The route table lives in a versioned file, so each change is reviewed, tested and reversible.

Design decisions

  • Routing as configuration: keep the table in versioned config with an owner, a review step and a changelog, so every answer can be traced to the policy version that produced it.
  • Shadow evaluation: score a candidate route on live traffic copies before any colleague sees its output. Compare success, groundedness, latency and cost against the current route.
  • Latency budgets per route: split the 8 second whole-request budget between stages, for example router 20 ms, retrieval 300 ms and first token by 900 ms, and enforce them with deadlines.
  • Escalation limits: allow one step up the cascade, then a fallback. Unbounded escalation turns a cheap path into the most expensive one.
  • Retirement and fallbacks: every route names a second model. When a provider retires or degrades a model, a configuration change moves traffic, and you have already evaluated the replacement.
  • Provider spread: keep at least two qualified options for critical routes, so a single provider outage does not stop the product. See Step 10: AI gateway and resilience.
  • Permissions before routing: decide the path with the colleague's rights in hand, so a cheaper route never skips an access check.

Measuring it

  • Success by route: correctness on the labelled set for each request type and route, refreshed on every policy change.
  • Cost per successful task: per route and overall, never cost per call alone.
  • Validator quality: the share of bad cheap answers it catches, and the share of good ones it wrongly escalates. These two numbers set the cascade's value.
  • Escalation rate: the share of requests moved up a step, watched for drift after model or prompt changes.
  • Router accuracy: for a model-assisted router, agreement with human-labelled request types, and the cost of its own call.
  • Latency by route: time to first token and total at the 95th percentile, against each route's budget.
  • Shadow gap: the difference between a candidate route and the live one on the same traffic.

When to use it, and how much of it

SituationApproachWhy
One request type, low volumeSingle model, no routerRouting adds parts you do not yet need.
Several request types with clear boundariesRule-based routingPredictable, cheap and easy to explain.
A large share of easy requests and a hard minorityCascade with a tested validatorMost of the saving comes from sending the easy majority to cheaper paths.
Free-form traffic that rules cannot sortModel-assisted router, with rule fallbackPay for the extra call only where it measurably helps.
Sensitive or irreversible actionsDedicated workflow, no model-chosen routeAuthority and verification are rules.

Trade-offs

DimensionEffectWhat to do about it
QualityCheaper routes lose quality on hard cases. Validators and escalation recover most of it.Test each route on the golden set and publish the numbers.
LatencySmall models answer faster, but each cascade step adds time on the requests that escalate.Set budgets per stage and limit escalation to one step.
CostRouting can roughly halve cost per success in the worked example.Report cost per successful task, not per request.
ComplexityMore routes mean more things to test, version and explain.Add a route only when the evidence justifies it.

What this means for your role

Common mistakes

Step checklist

  • Every request type in the catalogue has a named route and an owner.
  • Deterministic code handles calculations, validation and permission checks.
  • Sensitive actions bypass model-chosen routing entirely.
  • The routing table is versioned config, reviewed and recorded with each answer.
  • Each route has an evaluation result: success, groundedness, latency, tokens and cost per successful task.
  • Cascade validators have a measured catch rate and a stated limit on escalation steps.
  • Latency budgets exist per route and per stage, and deadlines are enforced.
  • A shadow run and a canary release precede every routing change.
  • Each critical route has a second qualified model, and the switch has been rehearsed.
  • A deprecation calendar tracks provider model retirements.

Further reading

Good routing is mostly honest bookkeeping: know what each request needs, measure what each path delivers, and move traffic only on evidence. The next step looks at what happens when a request needs to do something, not just say something. Next: Step 9: Tools and human approval.

Search topics

↑↓ to move · Enter to open · Esc to close