Open-source extension for pi-coding-agent

Every turn, the right model.

Everyday coding runs on a cheap, fast model. Hard problems get the smart one. And when a provider stumbles, the router switches — automatically, mid-turn, so your work never stops.

Multi-provider auto-switch keeps your task running No extra servers runs inside your Pi process Open source MIT zero runtime deps
pi-shift-router — in pi
status bar · toasts · auto
router: MiniMax-M3
tier: fast
mode: auto
judge ⚖ judging…
window 4/5 fast
🦾 [MiniMax-M3] → fix the failing test
judging…
🧠 [kimi-k3] ← upgraded for the architecture question
⚠️ MiniMax-M3 429 → switching to deepseek-v4-flash — retry in 1m
🦾 [deepseek-v4-flash] ← same-tier failover (v0.6.0)
See how
Quick Start

Up and running in three steps

Install it and nothing changes — routing only starts once you pick your models. Fully reversible, no lock-in.

  1. 01 / 03

    Install

    One command. pi registers it in your settings and loads it on the next launch — no rebuild, no config files to touch.

    Install command
    pi install npm:pi-shift-router
  2. 02 / 03

    Pick your models

    Run /router config and choose one fast model and one smart model — the pair you already use. Save to user or project scope.

    Configure
    /router config
  3. 03 / 03

    Watch it work

    /router status shows your setup; the next turn runs the first classification. From there it's automatic — tune later with /router quiet and /route-force when you want control.

    Verify
    /router status
How it works

One simple idea

Every task has a difficulty. Every model has a price. pi-shift-router matches the two — automatically.

Think of it like a team: the Programmer writes code fast and cheap; the CTO steps in when the stakes are high. Same task, two minds — the router decides which one you need before you even finish typing.

Routine work stays cheap

The judge only upgrades when a task actually needs depth — everyday coding keeps running on your budget model, and expensive flagships are reserved for what matters.

The deciding is nearly free

One tiny classification call — a few thousand tokens at your cheapest price, 200ms–2s. The savings from skipping unnecessary smart turns dwarf it.

Keeps working when a provider hiccups

If a model 429s or times out, it cools down and the next healthy model in the same tier takes over — mid-turn, no action needed from you.

Fast 🦾 Your daily worker

Programmer

Your everyday coder. Fast on routine work — writing code, running tests, fixing bugs — so you don't waste a flagship model on a rename or a refactor.

  • Day-to-day coding and fixes
  • Tests and mechanical changes
  • Routine, low-stakes work
Smart 🧠 For the hard stuff

CTO

Your architect for the hard stuff — architecture, design review, security, multi-step plans, irreversible changes. It doesn't just review; it does the work.

  • Architecture and design decisions
  • Reviews that need real judgment
  • Risky, ambiguous, or deep tasks
LLM Judge

A tiny call decides

One small classification — by the fast-tier model itself — reads your request and picks fast or smart. No heavy reasoning, no delay you'll notice.

judgeTimeout: 5000
Downgrade gate

No flip-flopping

Upgrades are instant when you need depth. Downgrades wait for a clear trend — fast votes in 5 of the last 5 classified turns — so the router never flickers between models mid-flow.

window: { size: 5, threshold: 0.6 }
Runtime failover

Failures, handled

When a provider rate-limits or errors, that model cools down (1m → 30m) and the next healthy one in the same tier takes over — you keep working through the outage.

cooldown: 1m → 2m → 4m → 30m
FAQ

Questions, answered

Straight from the README.

What if I don't configure any models?

Nothing changes. Both tiers start empty — the router does nothing and pi keeps using your default model. Routing only begins once you run /router config and pick your models.

Does this actually save money?

Yes. Routine turns stay on your cheapest model instead of burning a flagship on every request. The judge itself costs a few thousand tokens at your fast-tier price — the savings dwarf it.

Is it safe to try?

Completely. The router does nothing until you configure it, it is pure TypeScript with zero runtime dependencies, and /router off disables it instantly. No lock-in.

What exactly does the smart tier do?

It's the architect role — for complex work it drives the whole turn: architecture, design review, security, multi-step plans, irreversible changes. It doesn't just advise or review; it writes the code and does the work itself.

Does the Judge add noticeable latency?

No. The classification call is a few thousand tokens and takes about 200ms–2s. You'll see ⚖ judging… in the status bar during the call — most users never notice it.

What if my primary model 429s or times out?

You keep working. The failed model enters a short cooldown (1m → 2m → 4m … capped 30m) and the next healthy model in the same tier takes over automatically — even mid-turn. A successful response clears the cooldown.

Can I force a specific model for one turn?

Yes. /route-force <tier> pins Smart or Fast for the next turn; /route-force <provider>/<model> pins an exact model. /route-force auto clears the override.

Does it work with models from different providers?

Yes — mix freely. Each tier is an ordered list of {provider, model, priority} pairs, so your fast tier can be DeepSeek and your smart tier Kimi, all from one config.

How is it different from pi-model-router and pi-smart-router?

They solve different problems and can be used together: pi-shift-router is an LLM-as-classifier with zero runtime deps and runtime failover; pi-model-router adds 3 tiers, USD budget and keyword rules; pi-smart-router does local ONNX ML inference.