Picking a model is a decision you make once, at the start of a session, and then live with for two hours of work that was never uniform to begin with. Renaming a variable and designing a migration do not need the same model, and they certainly do not need the same reasoning effort.
jev-model-router moves that decision to where it belongs: per task, made by something that is good at deciding and bad at everything else.
Jev is not a chat model
Jev is TypeSafe’s System One decision model. It does not generate text. You send it a state, which is any string or JSON you have lying around, plus one or more typed questions, and it returns calibrated probabilities for each one in a single round trip. Your code does the thresholding. The model never decides anything, it only measures.
There are three primitives, and picking the right one is most of the work:
noul yes or no returns the probability the answer is yes
choice which one returns the pick plus the full distribution
score how much returns a probability weighted value over your levels
The request is one POST to api.typesafe.ai/v1/systemone with model, state and a map of questions. Every question in the map is evaluated in parallel, which is why asking three costs about the same as asking one.
The three questions the router asks
This is the whole classification, straight from hooks/policy.ts:
export function questions(provider: Provider): Record<string, unknown> {
return {
tier: {
type: 'choice',
instructions: 'Which is the cheapest tier that can complete this coding task well?',
criteria: TIER_CRITERIA,
},
effort: {
type: 'score',
instructions: 'How much step-by-step reasoning does this task need?',
criteria: EFFORT_RUBRIC,
},
risky: {
type: provider === 'typesafe' ? 'noul' : 'boolean',
instructions:
'Carrying out this task would itself change production, move real money, or alter data that cannot be restored.',
},
}
}
Three primitives, one per question. tier is a choice across three descriptions of the work: mechanical and local, ordinary engineering, or hard and high stakes. Note what is missing. The decision model never sees a model name. It rates the work, and the mod maps the tier to fastModel, balancedModel or deepModel, which default to haiku, sonnet and opus.
effort is a score on a four level rubric. risky is a noul on TypeSafe's API and a boolean on the Gateway, the same question under two names.
Two bars, because the two mistakes are not symmetric
A router that treats “spend more” and “spend less” as the same decision is a router that will eventually hand a migration to haiku. So there are two thresholds:
-
minUpgradeConfidence, default0.3. Spending more on a task that did not need it costs money. -
minDowngradeConfidence, default0.6. Spending less on a task that did need it costs you the task. -
riskyabove0.7goes to the deep tier with real reasoning, past both bars. That one is not a confidence question.
A backend that reports no confidence at all may only move a request up. Spending less on an unmeasured hunch is the bad trade, so the mod refuses to make it. And every failure, a non 2xx, a timeout past timeoutMs (800 by default), a malformed body, leaves the request exactly as Claude Code built it. The router never blocks a turn.
Where it hooks in, and the one switch that is off
The mod is a plugin built on function hooks, and it registers three events:
prompt.submit classify the prompt before the turn starts
turn.step apply effort (and model, if enabled) to the turn
agent.spawn pick the model for each subagent
Three switches control what it is allowed to rewrite:
routeSubagentModel model of each subagent default on
routeMainEffort effort of the main loop default on
routeMainModel model of the main loop default off
The last one is off on purpose. A subagent starts with its own context, so routing its model costs nothing beyond the classification. Changing the main loop’s model mid session invalidates the prompt cache, and on a long context the re-cache can cost more than the cheaper tier saves. Turn it on after you have measured your own sessions.
With logDecisions on, you see both the raw answer and what the policy did with it:
[jev-model-router] jev: tier fast (0.87) · effort 0.4 → low (0.71) · risky 0.02 · 249ms
[jev-model-router] main loop → effort low: fast (confidence 0.87)
[jev-model-router] jev: tier fast (0.41) · effort 0.4 → low (0.38) · risky 0.01 · 210ms
[jev-model-router] main loop: kept opus/medium, wanted haiku/low (confidence 0.41)
That last pair is the router working correctly and declining to act. It wanted to spend less and did not clear the bar.
Install
npx claude-code-templates@latest --mod productivity/jev-model-router
CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude
It needs Claude Code 2.1.259 or later. --mod writes the plugin into .claude/skills/jev-model-router/, and Claude Code only reads a project's .claude/ once you accept the trust prompt on a first interactive run.
Then the key, in user settings, not project settings:
{
"pluginConfigs": {
"jev-model-router@skills-dir": {
"options": { "typesafeApiKey": "" }
}
}
}
The entry name is the plugin id, and the id depends on how it loaded: jev-model-router@skills-dir from .claude/skills/, plain jev-model-router with --plugin-dir. Under the wrong key every option silently stays at its default and the log says no key set. A Vercel AI Gateway key works too, under gatewayApiKey, with one caveat: the Gateway's answer carries no confidence field, so confidence is read from an optional distribution and the downgrade bar often cannot fire.
With no key at all the mod still runs, falling back to Claude Code’s own classify with the small fast model.
The order to do this in:
- Install the mod and start Claude Code with
CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1. - Confirm the
ready online names the backend you expect. If it says the built in classifier, your key is under the wrongpluginConfigsid. - Leave the defaults alone for a few sessions and read the
jev:lines. - If it keeps declining downgrades you would have taken, lower
minDowngradeConfidence. - Only then consider
routeMainModel, and watch your cache stats after you do. - Run
claude plugin validate .claude/skills/jev-model-routerif anything looks wrong. It prints every event hooked and every call it makes.
You can follow me on my social media:
- Twitter (English): https://x.com/dani_avila7
- LinkedIn (Spanish): https://www.linkedin.com/in/daniel-avila-arias/
- Youtube (Spanish): https://www.youtube.com/@daniiielsan
- Instagram (Spanish): https://www.instagram.com/danielsan_avila/
Top comments (0)