Krishnendu Biswas

Model routing and tiered compute: local gateway with fallback resilience

One gateway on my server in front of several model accounts, with backup models when one fails, and a six-step ladder that sends each task to the cheapest model that holds quality. Plain scripts handle exact computation before any model is invoked. Narrow yes or no and pick-one questions skip this table entirely; they go to my fast decision model.

Gateway
9Router gateway on my server
Routing Strategy
Backup models · six-step ladder, cheapest model that holds quality
Core Invariant
Plain scripts run before any AI model

Problem

Directly binding agent workflows to a single AI provider causes brittle failures when rate limits or upstream outages occur. Furthermore, sending basic data extraction or mechanical formatting tasks to expensive models wastes tokens and increases latency.

What I Built

How the Gateway Pools Models

How a request is routed across modelsA request reaches a hub that only triages and routes. Eight standing domain agents own the work. They spawn short-lived leaf workers. Each task takes the first rung of a six-step ladder that can do it: script, Gemini 3.8 Flash low, Gemini Flash medium behind a script gate, Claude Sonnet 5.5, Claude Opus 5.5, then Fable at maximum effort for consultation only. Models come from a 9router pool, Claude direct, and Fable. An hourly health audit and a monthly Gemini quality audit review the setup. ENTRY AND HUB Request message or scheduled job Hub (depth 0) Triages and routes by task card Never writes a domain artifact 8 STANDING DOMAIN AGENTS, ONE WRITER PER ARTIFACT Academics Career Finance Personal ops Socials Consulting Infrastructure Private EPHEMERAL LEAF WORKERS (DEPTH 2), SPAWNED BY AN AGENT Research and extraction read only Review reads and reviews only Writer sole writer, if used MODEL LADDER: STOP AT THE FIRST YES 1 A script can do it Script, zero LLM calls 2 Bulk read-only or known-shape work Gemini 3.8 Flash, low 3 Edit a script can check Gemini Flash, medium 4 Ungated edit, synthesis, software Claude Sonnet 5.5 5 Critical judgment Claude Opus 5.5 6 Novel or irreversible plan Fable, max, consult only WHERE THE MODELS RUN 9router pool Gemini Flash, with backups Claude direct Sonnet 5.5 and Opus 5.5 Fable max effort, consult only REVIEW OF THE SETUP ITSELF Health audit, hourly checks routing and drift Gemini quality audit, monthly flags defects in Gemini output How a request is routed across modelsA request reaches a hub that only triages and routes. Eight standing domain agents own the work. They spawn short-lived leaf workers. Each task takes the first rung of a six-step ladder that can do it: script, Gemini 3.8 Flash low, Gemini Flash medium behind a script gate, Claude Sonnet 5.5, Claude Opus 5.5, then Fable at maximum effort for consultation only. Models come from a 9router pool, Claude direct, and Fable. An hourly health audit and a monthly Gemini quality audit review the setup. ENTRY AND HUB Request message or scheduled job Hub (depth 0) Triages and routes by task card Never writes a domain artifact 8 STANDING DOMAIN AGENTS One writer per artifact Academics Career Finance Personal ops Socials Consulting Infrastructure Private EPHEMERAL LEAF WORKERS Depth 2, spawned by an agent Research and extraction read only Review reads and reviews only Writer sole writer, if used MODEL LADDER 1 A script can do it Script, zero LLM calls 2 Bulk read-only or known-shape work Gemini 3.8 Flash, low 3 Edit a script can check Gemini Flash, medium 4 Ungated edit, synthesis, software (via Claude Code) Claude Sonnet 5.5 5 Critical judgment Claude Opus 5.5 6 Novel or irreversible plan Fable, max, consult only WHERE THE MODELS RUN 9router pool Gemini Flash, with backups Claude direct Sonnet 5.5 and Opus 5.5 Fable max effort, consult only REVIEW OF THE SETUP ITSELF Health audit, hourly checks routing and drift Gemini quality audit, monthly flags defects in Gemini output
A request reaches a hub that only routes. Eight standing agents own the work and spawn short-lived workers. Each task takes the first rung of the ladder that can do it. The ladder is also written out as a numbered list below.

Dynamic Routing and Complexity Tiering

The policy is simple: the cheapest model that holds quality wins. A task takes the first rung below that can do it and goes no higher.

  1. Script first, zero LLM calls. If a script can answer it, a script does.
  2. Gemini 3.8 Flash, low effort, for bulk read-only work and tasks with a known output shape.
  3. Gemini Flash, medium effort, only when a script gate checks the result.
  4. Claude Sonnet 5.5 for edits with no gate, for synthesis, and for software work, which goes through Claude Code.
  5. Claude Opus 5.5 for critical judgment.
  6. Fable at maximum effort, consulted only, for novel or irreversible plans.

Around the ladder sit a few structural rules. One hub triages and routes and never writes a domain artifact. Eight standing domain agents each own their work, one writer per artifact. They spawn short-lived worker agents for research, review and drafting, and those workers disappear when the job ends. An hourly health audit (I call it medic) checks routing and drift. A monthly Gemini quality audit flags defects in Gemini output.

Measured share of logged tokens: Gemini Flash 68.4%, Claude Opus 18.2%, Claude Sonnet 13.1%. Full table on the token ledger.

How I keep model calls rare and cheap

Large model calls are the most expensive operation in an agent platform. I use an ordered ladder of six techniques so that only tasks requiring deep reasoning reach larger models:

  1. Scripts first: 56 of 57 recurring scheduled jobs run as plain Python or Bash code with zero AI model calls. Exact mathematical sums, ledger arithmetic, and system health checks execute in native code.
  2. Narrow decisions: Narrow categorical choices, relevance checks, and 0-to-1 scoring route to a fast decision model that answers in ~300 ms for fractions of a cent.
  3. Smallest capable chat model: When a task needs natural language or tool use, it takes the lowest rung of the ladder above that can handle it, from Gemini Flash up to Claude Opus.
  4. Prompt caching: Repeated tool definitions, system prompts, and repository context are served from cache (89.9% cache hit rate across prompt tokens).
  5. Context compression: Long conversations are compacted into structured summary nodes by a cheaper model (827 sessions compressed so far), keeping history searchable without sending full raw transcripts. Details are on Memory.
  6. Planner last: The top tier (Fable) is invoked only for high-leverage architectural planning, design direction, and exhaustive fact audits before writing code.

No dollar reductions or token counts avoided are claimed here; these rungs show the technical architecture that keeps large model calls rare.

Outcome

When a provider hits a rate limit, work moves to a backup model instead of stopping. Plain scripts do the bulk filtering on the server, so the models get less to read and the numbers come out the same every time.

Limits

Switching to a backup model can make a reply slower, so each call needs a sensible time limit.

Stack

9Router · Python · Bash · REST APIs · Linux