Routing Requests in an AI Product

Routing Requests in an AI Product

user avatar

by me1afon

14 minutes ago


AI tools helped gather research and write the first draft of this article. I edited it and checked every quote and figure against the source page listed at the end, read on 1 December 2026. The cover illustration is AI-generated. Details at the end.

A chat box accepts anything: a question about a fee, an instruction to send money, a pasted error, a request to explain a word. Behind it the product has several places that could answer: a help article, an account lookup, a payment flow, a cheap model, a strong model. Routing is the decision that picks one. Make that decision as early and as cheaply as the request allows, make the choice visible in your logs, and make a wrong choice recoverable. The rest of this article is about how.

An earlier article on this site, "When a Workflow Is Enough—and When You Need an Agent", asked when a fixed workflow is enough and when a system needs an agent. This one starts after that choice: several paths exist, and each request must go down one. It is about design and evidence, not a ranking of routing products.

Three things called routing

The word covers at least three different decisions.

Routing to a branch. Anthropic's engineering post on building effective agents describes routing as a workflow that "classifies an input and directs it to a specialized followup task" [1]. The post says this allows "separation of concerns, and building more specialized prompts", and that "without this workflow, optimizing for one kind of input can hurt performance on other inputs" [1]. Its examples include sending different customer service queries "into different downstream processes, prompts, and tools" [1]. LangChain's documentation describes the same pattern: process the type of question first, then route to specific processes for pricing, refunds or returns [2].

Routing to a model. The same Anthropic post lists a second use: sending easy and common questions to smaller, cost-efficient models and hard or unusual ones to more capable models [1]. Two research papers study this directly [3][4].

Letting the model pick a tool. Here no separate router exists. You give the model a list of tools and it decides whether to call one. Both Anthropic's and OpenAI's API documentation expose controls over that choice [5][6].

The first two put a decision in front of the model; the third leaves it inside, with guardrails.

When routing to a branch works

Anthropic states a condition: routing "works well for complex tasks where there are distinct categories that are better handled separately, and where classification can be handled accurately, either by an LLM or a more traditional classification model/algorithm" [1]. Both halves matter: if the categories blur, a router keeps guessing, and a wrong guess lands in a specialised branch where the mistake is harder to see.

The post also notes that much of the tooling it describes has changed since December 2024 [1]; read the routing definition as a pattern, not as current API guidance.

LangChain's example shows how little machinery a first router needs: a model call returns a structured value naming the next step, and its sample comment calls that value "routing logic" [2]. The model produces a label; ordinary code does the dispatch, so the label can be logged, tested and overridden.

A fictional example: Ledger Helper

The following example is invented. Ledger Helper is a made-up chat assistant in a made-up wallet app, and the table is a proposal.

Four requests arrive in one afternoon:

  1. "What does it cost to send USDT?"
  2. "Send 50 USDT to Ana."
  3. "Why is my last transfer still pending?"
  4. "Explain what staking means, and also stake 20 for me."

A routing table for this product could look like this:

Request type Path Why
General knowledge or fee question Retrieval from help pages, small model Answer comes from published text; low risk
Question about this user's account Read-only account lookup, then a model to explain Needs the user's own data; cannot change anything
Instruction to move money or change settings Confirmation flow, no direct model action Changes state; needs the authority check described below
Unclear or mixed Ask one clarifying question, or split Guessing is the expensive option

Requests 1 and 3 are both questions, but they need different data and permissions. Request 2 is not a question at all. Request 4 mixes a knowledge question with an instruction, so the table sends it to the last row.

A fictional routing table for Ledger Helper: four invented requests, each with an arrow to its path. A fee question goes to help-page retrieval with a small model, a money instruction to a confirmation flow, a pending-transfer question to a read-only account lookup, and a mixed message to one clarifying question or a split.

Put the cheap layers first

Anthropic names two kinds of classifier: an LLM, or "a more traditional classification model/algorithm" [1]. That wording leaves room for a layered design, which is my proposal here and not something the post prescribes.

  1. Rules. Some routes are already known from the interface. A button labelled "Send" is not an ambiguous request. A message that contains only a wallet address is probably not a request for an essay. These checks cost nothing and are easy to test.
  2. A small classifier or fast model. For free text, a cheap component picks among a short list of labels, ideally with a confidence value.
  3. The expensive path. Anything the first two layers cannot place goes to the stronger model or to a human-readable clarifying question.

Earlier layers are easier to inspect than later ones, so a request that a rule can place should never reach a model.

Routing to a model: what the research shows and does not show

RouteLLM, a paper by authors from UC Berkeley, Anyscale and Canva, studies routing between one stronger and one weaker model. Its abstract proposes "efficient router models that dynamically select between a stronger and a weaker LLM during inference", trained on human preference data, and reports that costs fall "by over 2 times in certain cases-without compromising the quality of responses" [3]. The paper was published at ICLR 2025 [4].

A router predicts the probability that the strong model's answer would win for a query, and a threshold turns that into a decision: below it the query goes to the weaker model, above it to the stronger one. The paper says a higher threshold "enforces stricter cost constraints by favoring weak models more often" [4]. The threshold is the knob that trades quality against cost.

On the MT Bench benchmark the paper's table reports a score of 8.8 at one setting, which it describes as 95% of GPT-4's score [4]. But the same paper says routers trained only on its chat-preference data "perform poorly" on MMLU, which it attributes to "most MMLU questions being out-of-distribution", and its conclusion reports poor performance on GSM8K as well [4]. Performance improved after the training data was augmented with in-domain examples, even when those made up under 2% of the data in the MMLU case [4]. The authors' conclusion is that "the greatest performance gains occur when the training data closely resembles the evaluation data" [4].

The limitations section is direct: real-world applications "may have distributions that differ substantially from these benchmarks"; the work covers two models, not many; and different routers trained on the same data "can vary widely on the same benchmark without a clear explanation" [4].

So the paper supports a cautious statement: a trained router can cut cost on a benchmark while keeping most of the quality, and it needs data that resembles your own traffic. It does not show what a router would save in a particular chat product.

FrugalGPT, an earlier paper, proposes an LLM cascade that learns which combinations of models to use for different queries; its abstract reports that it can "match the performance of the best individual LLM (e.g. GPT-4) with up to 98% cost reduction" in its experiments [7]. A cascade combines models for a query instead of choosing one up front, and the figure comes from 2023 experiments. It is a reason to test the idea, not a number to plan a budget around.

Letting the model choose the tool

Many products skip a separate router and give the model a set of tools. Both vendors' documentation offers controls over how much choice the model has. OpenAI's function-calling guide lists the options: "auto" (the default) lets the model "call zero, one, or multiple functions"; "required" means call one or more; a forced function means call exactly one named function [6]. It also describes an allowed_tools setting that restricts calls to a subset of the tools, so the list passed to the model need not change between requests [6]. Anthropic's documentation describes forcing tool use through its tool_choice field for cases where "you might want Claude to use a specific tool to answer the user's question, even if Claude would otherwise answer directly" [5]. It also notes that not every model and setting supports forced tool use [5].

This gives three levels of control:

  • Rule-selected, forced. Your own rule or classifier decides the route; the call is forced to that tool. The model fills in arguments but does not pick the path.
  • Restricted choice. The model picks, but only among the tools allowed for this kind of request.
  • Open choice. The model picks from everything. This is the least controlled and the hardest to test.

Anthropic's guidance on tool definitions also bears on routing. It calls detailed descriptions "by far the most important factor in tool performance" and asks that each description say "when it should be used (and when it shouldn't)" [5]. It suggests that "fewer, more capable tools reduce selection ambiguity", and that prefixing names with the service, such as github_list_prs and slack_send_message, "makes tool selection unambiguous as your library grows" [5]. Read as routing advice: when two tools could answer the same request, the model has to guess, so overlapping tools are a routing bug waiting to happen.

Routing is not permission

A route says where a request goes. It does not say what the request is allowed to do. The two decisions should stay separate.

In Ledger Helper, request 2 goes to the confirmation flow because it changes state, but the flow, not the router, checks who is asking, what is being sent and to which address. If the router takes an instruction for a question, it reaches a read-only path that cannot move money. If it takes a question for an instruction, the user sees a confirmation screen they can dismiss. Each wrong route should land somewhere harmless.

This ties to a sibling article in this series, "Separating Conversation From Actions". The point here is narrow: a classifier's output is a suggestion about the path, never an authorisation for the action. Forcing a tool call, as the documentation allows, controls what the model may call; it does not decide whether the user may do the thing [5][6].

Mixed and unclear requests

A message like request 4 breaks Anthropic's condition of accurate classification into distinct categories [1]. Three options exist, and the right one depends on what the paths can do:

  • Ask. One short question when the paths differ in risk: "Do you want an explanation, or should I start a stake?"
  • Split. Handle the knowledge part now and put the action behind its own confirmation, as separate steps.
  • Default to the safest path when the paths differ only in cost, and offer to go further.

The product should not silently pick the highest-privilege reading. Whichever option you choose, record it.

A fictional trace for one Ledger Helper message: the request, the rule check that found nothing, the classifier's two competing labels, the decision to ask a clarifying question, and the route that was logged.

Testing a router

What follows is my proposal. RouteLLM's results point to the key rule: evaluate on data that looks like your traffic [4].

  1. Collect real requests from your own product, with personal data removed, and label each one with the route a careful person would pick.
  2. Report per-route errors, not one accuracy number. A money instruction sent down the question path and a question sent down the money path are different failures.
  3. Log the route, the rule or label that chose it, and the confidence for every request, so you can replay decisions after a change.
  4. Track the unplaced share. A growing "unclear" bucket means the categories no longer match what people ask.
  5. Re-test after changing the model, the prompt or the tool list. RouteLLM reports routers holding up when the model pair was swapped without retraining, on its own benchmark [4]; your traffic is not that benchmark.

What this article does not settle

It does not say what routing will save in your product: the figures cited come from benchmark experiments on specific models, from 2023 and 2024. It does not compare routing products or vendors, and it gives no confidence threshold, latency budget or safe number of routes. Multi-step agents, retrieval design and structured output are separate questions. The example is invented, and the layered design, the table and the tests are proposals, not findings. Vendor documentation can change after the read date.

How this article was made

Task What the AI did What a person did How it was checked
Research Gathered candidate sources and drafted notes Chose the question and which pages to rely on Every quote and figure checked against the downloaded page or paper, read on 1 December 2026
Draft Wrote the first draft from the notes Edited the text, the example and the table An independent review compares claims with the sources before publication
Images Generated the cover and inline illustrations Chose and checked them Labelled as AI-generated in the disclosure line and alt text
Not done by AI none The decision to publish and responsibility for the text none

Conflicts of interest: none. The author has no commercial relationship with the organisations named here.

Responsible for this article: Dmitriy Lastovka, author. Corrections: contact form.

Sources

Labels: guidance (a vendor's own documentation or engineering post), paper (a research paper; arXiv versions are not peer review). Quotes are as on the pages read on 1 December 2026.

  1. Anthropic, "Building effective AI agents", engineering post, published 19 December 2024 (the routing workflow section; the page carries a note that much of the tooling it describes has changed). https://www.anthropic.com/engineering/building-effective-agents Guidance.
  2. LangChain, "Workflows and agents" (the Routing section). https://docs.langchain.com/oss/python/langgraph/workflows-agents Guidance.
  3. Ong et al., "RouteLLM: Learning to Route LLMs with Preference Data", arXiv abstract page (v4, 23 February 2025). https://arxiv.org/abs/2406.18665 Paper.
  4. The same paper, full text as published at ICLR 2025 (method, tables 1-4, limitations). https://arxiv.org/pdf/2406.18665 Paper.
  5. Anthropic, "Define tools" (forcing tool use; best practices for tool definitions), Claude Platform documentation. https://platform.claude.com/docs/en/agents-and-tools/tool-use/define-tools Guidance.
  6. OpenAI, function calling guide (the "Tool choice" section). https://platform.openai.com/docs/guides/function-calling Guidance.
  7. Chen, Zaharia and Zou, "FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving Performance", arXiv abstract page (v1, 9 May 2023). https://arxiv.org/abs/2305.05176 Paper; abstract only was read, its figures are the authors' own experimental results.

Tier I

Sector: #18291

Sealed Hiding Place Room

Resource Cache

Resource Cache

Tier I

Requires 25% Tier Progress to Claim
Meme Cache

Meme Cache

Tier I

Requires 50% Tier Progress to Claim
Equipment Cache

Equipment Cache

Tier I

Requires 75% Tier Progress to Claim

After collecting, hiding places will be stored in your inventory and can be opened with Keys.

Other articles

What Should an AI Chat Remember?

Memory is not one thing. Sort what a chat keeps by purpose, scope and expiry: vendor docs, GDPR storage limitation, a fictional example and a template.

user avatarme1afon

Separating Conversation From Actions

How to keep an AI chat's talk apart from its actions: what the tool-use docs say, a fictional wallet assistant, five parts of an action layer and four mistakes.

user avatarme1afon

Reading Search Policies on AI-Generated Publishing

What Google's pages say about AI-generated content and scaled content abuse, what Yandex's pages add, why Bing is missing, and a pre-publication check.

user avatarme1afon

Are Separate Fast-Page Formats Worth Maintaining?

What Google, Telegram, Apple and others document today about AMP and partner page formats, what a second page version costs, and a decision test.

user avatarme1afon

What Structured Data Says About an Article

What Article, NewsArticle and BlogPosting markup can say about authors, dates and headlines, what Google documents, and why it promises no ranking.

user avatarme1afon

Measuring Referrals From AI Search

What a visit from an AI answer leaves behind, what GA4, UTM and Referrer-Policy can show, and a fictional weekly table that keeps three counts apart.

user avatarme1afon

Important disclaimer: The information presented on the Dapp.Expert portal is intended solely for informational purposes and does not constitute an investment recommendation or a guide to action in the field of cryptocurrencies. The Dapp.Expert team is not responsible for any potential losses or missed profits associated with the use of materials published on the site. Before making investment decisions in cryptocurrencies, we recommend consulting a qualified financial advisor.