pi-shift-router
v1.8.0The original. One command in pi, and it starts deciding. Big jobs can be split across cheap workers.
- No runtime dependencies · ~409 kB
- Judge modes: LLM chain or decision model
- 641 unit tests
A small judge decides. When it cannot, it leaves your model alone.
You name two models: a cheap, fast one and a strong one. Before each message runs, a smaller model reads it and picks which one handles it. The cheap one takes code, tests, and small fixes. The strong one takes architecture, security, and the decisions you would rather not make twice. Judging costs a few thousand tokens and about a second.
Same features, same commands, same defaults. Install one.
The original. One command in pi, and it starts deciding. Big jobs can be split across cheap workers.
Install as a plugin, then set it up in Settings or run /router config.
They release separately, so the DeepSeek Harness version can lag a release.
Those are the only two things you set. Everything after that is automatic, and /router off turns it back off.
One command. pi adds it to your settings and loads it the next time you start.
Run /router config and pick two: one cheap and fast, one strong. Save them for yourself, or just for this project.
/router status opens a dashboard showing what it decided and what it cost. Your next message is the first one it routes.
A cheap model and a strong one can differ by 4× to 50×. So the strong one handles only what needs it.
Simple work sent to the strong model wastes the price difference. Hard work left on the cheap one costs more: you send it again, you pay for the strong model anyway, and you lose an afternoon finding out. So the router leans expensive — roughly one message in three earns the strong model. Below that, it would rather change nothing than guess.
A rename, a new test, a typo. That does not need a frontier model, and the cheap one is faster at it.
One small call, one or two seconds, billed at your cheap model's price. Turn down one strong call and you have covered hundreds of them.
Rate limit, timeout, an account out of credit — the next model you listed for that job takes over, usually within the same message. It never switches to the expensive side on its own.
Code, tests, bug fixes, the same edit across a hundred files. The answer is already decided; someone just has to carry it out accurately. A rename should not cost flagship prices.
Less of your work, and none of it safe to get wrong. Architecture, security, the review that changes what you build next, the decision you would rather not make twice. It runs the whole message, so the code is its own.
A small model reads your message and answers two things: which model, and how sure it is. That number is the chance this message needs the strong one. It is the only decision in the system — after it, the model you picked works at its own level.
judge: { mode: fast-chain | custom | decision } R, default 3, which puts the bar at about one message in three. Turn it up to be stingier, down to be freer. Or take a preset: /router eco, /router default, /router sport.
economics: { reworkPenalty: 3, downgradeMemory: 2 } Rate limit, server error, or an empty balance — that model waits longer each time it fails, and the next model you listed for the job takes over, usually within the same message. If the judge cannot be reached either, it falls back: another judge, then no routing at all. It never invents an answer to keep going.
cooldown: 1m → 4m → 16m → 1h → 4h → 6h
Some work is not a harder version of the same thing. It is several things. There the strong model stops working alone: it plans the job, writes the instructions for one cheap worker on a piece at a time, reads what comes back, and sends it out again if it is not right. Simple messages never go through this.
Take a speed. The presets set the knob for you.
Where it starts. When the two look about equal, it takes the strong one.
By default the decision comes from the cheap model that also does the work. You can change that.
Uses the cheap model you already have for regular work. Nothing to set up.
Let one specific model do all the deciding, separate from the ones doing the work. Useful if you have a model you trust with decisions.
Built to do only this: hand it a typed question, get back the answer and a probability. Nothing to parse, so nothing can arrive broken — about $0.0001 a message. pi 1.8 carries 53 of them.
Decision models are off by default, and that is a decision rather than caution. They are slow right now — 1.4 to 6.6 seconds a verdict, which is the provider still ramping up capacity. They suit batch work and background tasks. For a message you are sitting and waiting on, use the LLM judge. If one stops answering, the router falls back to your LLM judge.
Any mix works. Each side is a list of models, best first.
Two or three models on each side. If one runs out of quota, the next one takes over.
One bill, one set of limits. Their cheap model for the day, their best model for the hard messages.
The cheap model runs on your own machine, the strong one in the cloud. Routine work never leaves the computer, and hard messages still get the best model.
The short answers.
Ordered the way a first-time reader asks them.
Yes. Until you pick two models it does nothing at all and your agent keeps the model it already had. /router off turns it off immediately, and deleting the folder leaves you exactly where you were.
Yes, as long as your work is mixed. Routine messages stop paying flagship prices, and the decision itself costs a few thousand tokens and 200 milliseconds to 2 seconds at the cheap model's price — turn down one strong call and you have paid for hundreds of them. If every message you send is genuinely hard, it will not save you anything.
The same work, with a stronger model behind it. It thinks, calls tools, edits files, and keeps going until the task is done — it writes the code, rather than leaving notes on someone else's. What changes is when it gets used: architecture, security, review, anything you would rather not redo.
Most routers ask an LLM whether a message is hard, then parse JSON out of the reply. A decision model is built for only that: hand it typed questions and it returns the option plus a probability — fast, 0.99. The router compares 0.99 to the bar and moves on. Nothing to parse means nobody has to recover from a model that added a comma, and a missing field means no verdict rather than a guess. A verdict costs input tokens only — about $0.0001 a turn. TypeSafe's Jev started it; OpenAI, Cloudflare and Perplexity followed, pi 1.8 carries the transport for all of them, and /router config lists what your install can actually reach. It is off by default: 1.4 to 6.6 seconds a verdict is slower than the LLM judge, so it suits batch and background work, and it steps down to your LLM judge if it stops answering.
You keep working. A rate limit, a server error, an empty balance, or Codex running out of its usage all count: that model waits — 1 minute for a server error, 16 for the rest, longer each time it fails, up to six hours — and the next model in your list takes over, sometimes mid-message. It never crosses to the expensive side, so a strong-model call stays strong. The judge does not guess either: when it cannot reach a verdict it keeps your current model, then falls back to another judge, then to no routing at all.
On a message the judge calls complex, the strong model stops working alone: it plans the job, gives one cheap worker a piece at a time, reads the result, and sends it back if it is not right. It does not cost more — planning runs on the strong model, the implementing on workers that start with no history (~$0.004 for a narrow job, against $0.06 for copying a 176k-token conversation), and two hard stops keep it bounded. Every worker must hand back a failure note; send the same note twice and the strong model does that piece itself. On by default, needs pi-subagents, and /router orchestrate off turns it off.
Three ways. /router status shows the model in use, the last decision and why, which models are paused, and what each side spent against what the session would have cost on the strong model alone. One number sets how eager it is: R, default 3 — higher is stingier (R=2 for routine work, R=5 for architecture), or take a preset with /router eco, default or sport. To take over for one message, /route-force pins the tier or an exact model and /route-force auto clears it. /router off hands you the wheel for good.
OpenRouter Auto Router optimizes for quality, not your bill — their docs say routing to an expensive model is working as designed — and you do not set the lists, see the decision, or choose the failure mode. Cloudflare AI Gateway is versioned flows with quotas, but you draw the graph and it sees requests, not tasks. Among pi routers, pi-bifrost runs 7-step rules across 4 tiers and saves subscription quota rather than money; pi-smart-router runs a 12-step local pipeline with no LLM and needs a local database. This keeps the decision to one prompt you can read, two lists you can hold in your head, and every verdict visible in /router status.
Yes — dsh-shift-router (v0.7.5), the same router on the harness, with no dependencies of its own. Install it as a plugin, then set both lists in the Settings card or with /router config. Everything here carries over, plus /router allow-workers on, which puts your cheap list in the harness's subagent allowlist so delegated workers really do run on the cheap model. 443 unit tests and a credential-free e2e. To install: add it as a plugin in the app and enter the package name, dsh-shift-router — or the repo address github:green-dalii/dsh-shift-router#v0.7.5, or a local path.