跳至主要内容

Model routing thoughts by AI

Analysis following topic base on materials available from internet in recent two or three months:

It seemed that multiple model service providers are implementing smart/intelligence-level-based model routing in their backend now a days. There's already some level of similar feature embedded in coding clis like claude-code, gemini-cli, opencode, etc.

What is the best place to implement model routing from your opinion? What is the best way to implement it considering about user friendliness, trusting, user-s-cost, user-experience, performance and accuracy.



 I'll check what has been published recently on this first.

What the recent material shows

Routing now happens at several layers, and the layers behave quite differently.

  • Gateways and routers: LLM Gateway added "smart routing" in late September. The organization picks up to 30 candidate models and a classifier, and it does not quietly fall back to a model you did not approve. Hosted routers such as OpenRouter add roughly 25 to 50 ms of overhead.
  • Inside the product: One Cursor user describes the "Auto Balanced" router as a learned model that reads your recent conversation, predicts how well each candidate will do and what it will cost, then picks within a budget.
  • Client-side routers: A community package for coding harnesses persists every routing decision with its reasons so it can be replayed, and demotes cheap-but-flaky models using escalation and error rates from your own traffic.
  • Harness to backend hints: Codex merged a change in August that sends an x-codex-routing-hint header with the model and service tier, only on Codex-backend authentication. This suggests the client and the backend are starting to share routing signals.

The recurring problems are about trust, not technique:

  • A user on OpenAI's forum reports requesting a thinking model and being served a mini model.
  • An OpenRouter issue describes an "opus-latest" alias silently walking down to older models that were billed at a higher price.
  • A Cursor user asked for a justification of each routing choice after a session jumped unexpectedly to Opus 5.
  • Reported savings of up to about 85% only hold with a quality floor. Without one, cost routing silently degrades output and nobody logs it.
  • A Hacker News commenter objected that a proxy breaks the control loop. The router doesn't know that a cheap model just failed, and it may not know that re-fetching context with a smaller model can cost more than staying on the parent.

My opinion: where it should live

I'd split the decision by who holds the information, rather than pick one place.

  1. The agent harness (the CLI or app) should own the decision. It sees the task phase, tool results, test failures, context size, cache state, and whether you retried or undid something. That lets it escalate on actual failure instead of only predicting difficulty up front. It can also show you what it chose and let you override it.
  2. The provider should supply signals and safe levers, not silently swap models. It knows fleet load, pricing, and capabilities. It can offer things that don't change the model you picked, such as effort or thinking budget, serving tiers, and a clearly labelled "auto" alias. Swapping the model behind an explicit selection is where the trust complaints come from.
  3. A gateway is best for organization policy. Budgets, allowed-model lists, failover, audit, and compliance fit there. It is blind to the agent loop, so it shouldn't make the fine-grained quality calls.

One caveat: when the harness and the provider are the same company, as with Claude Code, the harness-versus-backend split matters less. The trust rules below still apply.

How I'd implement it

  • Make auto opt-in and separate. Use a distinct "auto" choice. Never reroute a model the user explicitly selected. Report the model actually used, and bill by that model, in every response and usage log.
  • Route by phase and role first. Planning and hard debugging go to a strong model. Search, mechanical edits, summarization, and subagents go to a cheap one. This is more reliable than classifying every prompt in isolation.
  • Use cascades with verification. Go cheap-first for cheap, reversible work and strong-first where a retry is expensive. Escalate on concrete signals such as failing tests, tool errors, or user retries.
  • Set a quality floor and give the user one policy knob (cost, balanced, or quality), plus a budget and hard capability constraints like context length and tool support.
  • Be cache-aware. Switching models mid-session loses the prompt cache. Switch at natural boundaries, and count a full re-dispatch as a real cost of escalating.
  • Keep the router fast. Use heuristics first, then a small classifier, and call an LLM classifier only when uncertain. It should add tens of milliseconds, not seconds.
  • Make decisions explainable and overridable. Show a one-line reason, keep a decision log, and let the user pin a model per turn.
  • Measure cost per solved task, not per token. Sample shadow comparisons against the strong model, track escalation and retry rates, and refresh the router as models change, since a hard-coded model list goes stale quickly.
  • Mind privacy. A third-party router sees every prompt and your code, so it needs the same trust level as the model provider.

How the placements compare

Criterion Harness Provider backend Gateway
Accuracy Best (rich signals, closed loop) Good if opt-in Limited (blind to the loop)
Trust High if transparent Weakest if silent Good if policy is yours
Cost savings High (cache- and phase-aware) High (fleet view) Medium to high
Latency Lowest Low Adds a hop
User friendliness Best, with override Simple, but opaque Needs setup

Caveats

Much of this material comes from vendors, community forums, and GitHub issues, and some of the benchmark claims (such as router leaderboards) are self-reported. I found little independent evidence about how the major labs' own backend routers work, so my recommendations on that layer rest on the reported user experience, not on documented internals.

In short, the client decides, the provider exposes signals and an honest "auto" mode, and the organization sets guardrails at the gateway. The router should always disclose what it chose and why.

评论

此博客中的热门博文

Use MobaDiff with git difftool

Recently there's an activity in IT that forces the deletion of all unauthorized softwares from all work machines. Unfortunately, kdiff3 is one in the list. As it is generally okay to use vimdiff as an alternative for kdiff3, A gui tool is better suited for desktop workflows. Known that MobaXterm is shipping a gui diff tool named MobaDiff. But it only appears in the windows right click context menu. Find the real application name takes me some time to search in the windows registry. "MobaRTE.exe", which is the one invoked by HKCR\*\shell\MobaDiff. And it was invoked with "-contextdiff" switch to show MobaDiff UI, while when the switch is "-contextedit" it shows MobaTextEditor. Too bad that the "-contextdiff" switch do not support pre-image post-image as other diff tool did, which effectively made it unable to be used as a command line diff utility. Also MobaTech did not mention anything in their document of this Mob...

Emacs 26.2 windows Hunspell setup

 Hunspell failed with default setup With my shining new emacs26.2 setup, I am happy until trying to `M-$’ on a word. I got following error message, it used to be work by just set ispell program to hunspell. Starting new Ispell process hunspell with default dictionary... split-string: Wrong type argument: stringp, nil After some check in my customization setting. nothing found. install a copy of hunspell dictionary At first I think it was caused by no hunspell dictionary. I downloaded en US and en CA hunspell dictionary from wordlist.sf.net project. After put the .aff and .dic files into C:directory I’ve also made a symbolic link from en US ones by running the `mklink’ tool: mklink default.aff en_US.aff mklink default.dic en_US.dic Err… hunspell does not work, still. Time to read code Dig into ispell.el I suprisingly find there’re lots of hunspell specific logic. Originally I was thinking hunspell support involves no elisp work. Acturally ispell did many work to de...

XEmacs 21.5 beta 35 "kohlrabi" has been released.

If you are an old XEmacs user, you may feel happy to see this from https://www.xemacs.org/.    After ten years, XEmacs released a new version 21.5. So there's still many people cares about XEmacs. The XEmacs' source repo have been moved from altassian Bitbucket to https://heptapod.net/. As Bitbucket have been dropped Mercurial support many years ago.