Skip to content

Releases: alexei-led/pi-model-router

@alexeiled/pi-model-router 0.7.0

Choose a tag to compare

@github-actions github-actions released this 22 Sep 10:07
v0.7.0
ba1b395

Probability-based Jev routing and a smaller command set

Version 0.7.0 changes how the router acts on Jev answers, removes six /router verbs and adds four configuration keys.

Behavior change

WARNING: The router now acts on Jev answers that version 0.6.5 discarded. Routes can change on the same prompts.

  • A Choice with confidence at or above confidenceThreshold (0.65) is acted on directly, as before.
  • A Choice below that threshold is no longer discarded. The router reads the full probability distribution and selects the lowest tier whose cumulative probability, counted from micro upward, reaches probabilityThreshold (0.8). Abstention mass counts for the baseline tier.
  • An answer whose top option is uncertain still uses the baseline.

Set "probabilityThreshold": 1 to keep the most conservative fallback, or lower it toward 0.5 to follow the plain argmax.

Removed commands

WARNING: These /router verbs are removed. A removed verb prints its replacement and does nothing.

Removed Use instead
status /router
profile <name> /router <name>
disable /router off
fix <tier> /router pin <tier>
debug show, debug stats /router log
debug on, debug off, debug clear /router log on, off, clear
widget on, widget off, widget toggle /router widget
thinking <tier> <level> profiles.<name>.<tier>.thinking in the configuration
? /router help

The command now has eight verbs: <profile>, off, pin, thinking, log, widget, reload, help. A verb without an argument shows the state it controls. Top-level completion lists verbs and profile names.

Structured Jev question

Each tier is a structured Choice option with covers, notFor and examples. The high option also lists useWhen. The instructions are a structured object that names the state fields it refers to.

On the published 24-task corpus, the structured question matched the preferred tier in 22 of 24 tasks. The flat question matched 21. Three repeats did not change any top option.

Retries and diagnostics

  • The router retries one transient status (408, 429, 5xx) inside the existing timeoutMs budget. The backoff honors Retry-After. Permanent statuses, malformed responses and cancellation are not retried.
  • An invalid-response names the failing local check: unreadable-body, missing-answer, unexpected-answer-type, unknown-choice, invalid-confidence, distribution-keys, distribution-sum or distribution-argmax. Remote text is not retained.
  • The validator accepts omitted zero-mass options and two-decimal rounding. Version 0.6.5 rejected both.
  • A skipped advisor records why. The footer shows advice skipped: pinned high, over budget, only high eligible or tool turn instead of advice bypassed.
  • The low-confidence outcome is removed. Debug output shows selected, basis, route-p and route-threshold.
  • The request token estimate adds 400 tokens of headroom instead of 200. Live requests measured 110 to 135 tokens above the old estimate.

New configuration keys

All defaults are unchanged. No configuration change is required.

{
  "jev": {
    "probabilityThreshold": 0.8,
    "retry": { "maxAttempts": 2, "backoffMs": 400 }
  },
  "classifierModel": { "model": "provider/model", "timeoutMs": 10000 }
}
  • jev.probabilityThreshold: above 0, at most 1.
  • jev.retry.maxAttempts: 1 to 5. The value 1 disables retries.
  • jev.retry.backoffMs: 0 to 60000.
  • classifierModel.timeoutMs: positive milliseconds.

Verification

All 536 tests pass. Biome, TypeScript, package-content checks and the secret scan pass.

Three live Pi sessions ran the local extension with subscription aliases. They covered 9 prompts on claude-personal, 10 prompts on a spike with two extra questions and 10 prompts on openai-work. Every route was in the preferred range, except one abstention that used the baseline as intended. Two answers below the confidence threshold produced the preferred tier. Version 0.6.5 sends both to the baseline.

Parallel Noul questions were tested and not added. They separated the extremes but changed no route in 72 direct requests and 10 live turns.

Documentation

  • docs/README.md is the index.
  • docs/jev-advisor.md holds the Jev guide that was in the README.
  • docs/research/ holds dated experiment reports. docs/archive/ holds superseded reports.
  • Old paths such as docs/ARCHITECTURE.md no longer exist.

Update

Run this command:

pi update npm:@alexeiled/pi-model-router

Then start a new Pi session. An existing session keeps the previous version.

More information

@alexeiled/pi-model-router 0.6.5

Choose a tag to compare

@github-actions github-actions released this 22 Sep 08:04
v0.6.5
de13e62

Jev context selection uses estimated tokens

Version 0.6.5 changes the Jev context format and its configuration.

Important configuration change

WARNING: Replace all character-budget keys before you load version 0.6.5. The router does not accept these keys.

Replace these keys:

  • Replace maxStateChars with maxStateTokens.
  • Replace maxHistoryChars with maxHistoryTokens.
  • Replace maxToolChars with maxToolTokens.

Use this configuration for the new defaults:

{
  "jev": {
    "maxStateTokens": 3000,
    "context": {
      "previousTurns": 2,
      "maxHistoryTokens": 500,
      "toolResults": "last-error",
      "maxToolTokens": 250
    }
  }
}

Structured Jev state

The router sends three named fields to Jev:

  • currentRequest contains the current user request.
  • recentDialogue contains bounded text from prior user turns and assistant replies.
  • recentToolEvidence contains optional text from one tool result.

The default policy includes only the last native-error result. It does not search tool output for error words.

Empty tool-call messages do not consume dialogue slots. A later successful result prevents reuse of an older error.

Long excerpts keep their beginning and end. Each excerpt includes a truncation flag. The router does not create a summary.

Token estimate

TypeSafe does not publish a Jev tokenizer or a token-count endpoint. The TypeSafe SDK reports input usage after a request.

OpenAI tokenizers use a different vocabulary. They underestimated measured Jev usage by 26 to 49 percent.

The router uses a conservative multilingual estimate. It counts ASCII text, non-ASCII UTF-8 bytes, and a 10 percent margin.

The serialized request includes 200 estimated tokens of envelope headroom. The router rejects a request above 28000 estimated tokens.

Jev permits 32k tokens for state plus the longest question. It permits 64k tokens for the complete request.

Debug output shows the local estimate and Jev usage.input_tokens. The server value is available only after the request.

Configuration fields

  • maxStateTokens sets the total selected-state budget. The default is 3000.
  • context.previousTurns sets the number of prior user turns. The default is 2.
  • context.maxHistoryTokens sets the dialogue budget. The default is 500.
  • context.toolResults accepts none, last, or last-error.
  • context.maxToolTokens sets the tool-result budget. The default is 250.

The router accepts a maximum of 20 prior turns. It accepts a maximum state budget of 24000 estimated tokens.

These fields belong in the user Jev configuration. Project Jev configuration remains disabled.

Verification

All 528 tests pass. Biome, TypeScript, package-content checks, and the secret scan pass.

The context study used 48 live Pi turns and 68 controlled Jev replays. Larger history did not give a consistent improvement.

Six authenticated Jev requests covered English, Russian, TypeScript, emoji, and a long request. Estimate-to-actual ratios were 1.06 to 1.39.

Two Pi/agterm turns completed Jev routing and saved token metrics. OpenAI and Claude account limits stopped their generation requests.

Unchanged behavior

The generation model still receives the normal Pi context. This release changes only the state that the router sends to Jev.

System prompts, thinking blocks, tool arguments, tool schemas, and binary data remain excluded. Selected text is not saved in router diagnostics.

The confidence threshold, timeout, baseline policy, pin policy, cancellation rules, and single-flight behavior are unchanged.

Update

Run this command:

pi update npm:@alexeiled/pi-model-router

Then restart Pi. Do not load the installed router and a local checkout in the same process.

More information

@alexeiled/pi-model-router 0.6.4

Choose a tag to compare

@github-actions github-actions released this 21 Sep 17:44
v0.6.4
4156499

Quality-first routing and clearer Jev decisions

  • Frontier when useful, not only when unavoidable. Jev now prioritizes expected correctness, completeness and reduced rework. Straightforward retrieval and mechanical tasks still favor micro/low. Confidence thresholds, cancellation, eligibility and budget safeguards are unchanged.
  • Understandable feedback. Footer outcomes explicitly distinguish the selected tier, low confidence, no tier chosen, timeout and transport/validation failure. Compact mode no longer presents abstention confidence as confidence in the generation model; widget/debug explain it.
  • Real request statistics. /router debug stats shows unique HTTP requests, advised tiers, outcome rates and median latency in retained history. Locally generated IDs deduplicate same-turn sharing, cached routes and tool continuations, including after resume.
  • Debug fixes. Runtime now retains the documented 50 decisions instead of 12. debug off stops new history collection while retaining the latest route; debug clear resets the window. Statistics are not presented as lifetime totals.
  • Quality-first fallback recipe. Set baselineTier: "high" in an existing profile when avoiding underpowered fallback matters more than cost. Confident micro/low advice still wins. Profiles are not rewritten automatically; high must be configured and eligible, and budget/pin policy still applies.

Example feedback

Jev → high c87% · 374ms
Jev high c62% <65% → baseline · 284ms
Jev: no tier chosen → baseline · 748ms

Validation

  • 24 real prompts through Pi/agterm with one local router and alias provider.
  • Actual assistant metadata: 10 Astra, 14 Luna generations; all matched the predefined acceptable tier ranges.
  • Repeated simple → complex → simple transitions, contextual follow-ups and tool continuations verified.
  • Two low-confidence results and one abstention used the configured high baseline; no confidence threshold was lowered.
  • Retention, reload, debug-off collection, clear/reset and deduplicated statistics checked against session JSONL.
  • 492 tests pass, plus Biome, TypeScript, package-content validation and secret scanning.

This is a small coding acceptance corpus, not a blinded model-quality benchmark.

Validation report · Task corpus · Configuration and diagnostics

Package: @alexeiled/pi-model-router@0.6.4. Update the installed package and reload/restart Pi to load the new code. Avoid loading the installed router and a local checkout simultaneously.

Full changelog: v0.6.3...v0.6.4

@alexeiled/pi-model-router 0.6.3

Choose a tag to compare

@github-actions github-actions released this 21 Sep 16:13
v0.6.3
c41cdc8

Package

  • Name: @alexeiled/pi-model-router
  • Version: 0.6.3
  • Tag: v0.6.3
  • Commit: c41cdc88b6cdf31c99a495e81356094dc0ba331d

Full Changelog: v0.6.2...v0.6.3

@alexeiled/pi-model-router 0.6.2

Choose a tag to compare

@github-actions github-actions released this 21 Sep 13:43
v0.6.2
d50e798

Jev timeout and thinking-effort fixes

Configurable timeout

  • Jev now defaults to 1500 ms, instead of 750 ms.
  • User-level jev.timeoutMs controls the entire advisory budget, including the HTTP request and response body. The hidden 750 ms clamp and fixed outer deadline are removed.
  • There is no arbitrary product-level maximum: 4000 ms and 5000 ms are valid. Values must be positive, finite, and within Node's timer range (at most 2147483647 ms).
  • Existing explicit shorter values remain unchanged. Set "timeoutMs": 1500 or remove the field to adopt the new default.
{
  "jev": {
    "timeoutMs": 1500
  }
}

Merge this field into your existing ~/.pi/agent/model-router.json; keep your current credentials and profile privacy settings. Project-level Jev settings remain ignored.

Preserve per-tier thinking

Fixed delayed Pi thinking-display events being mistaken for user choices and overwriting every tier's configured effort. A routed high-effort turn no longer causes subsequent micro routes to inherit that effort. Genuine user overrides still work.

Unchanged safeguards

  • Explicit profile privacy opt-in and confidence validation.
  • One bounded Jev request, with no retry or second-advisor cascade.
  • Direct eligible baseline fallback on failure, uncertainty, or timeout.
  • Caller cancellation stops generation.
  • No raw task text, credentials, or remote explanations in routing diagnostics.

Upgrade and verification

Update the extension and restart Pi to load the new code. In an existing session, /router thinking auto clears unwanted persisted thinking overrides; it also clears intentional overrides, so use it only when desired.

  • 459 tests pass across 12 files.
  • Typecheck, lint/format checks, build and package dry run pass.
  • Runtime dependency audit: zero vulnerabilities.
  • Regression tests cover delayed valid responses, configured deadlines, cancellation, candidate eligibility, deferred thinking events, and explicit user overrides.

Live agterm testing with an isolated 3-second budget verified Luna/off → Astra/high → Luna/off on easy, hard, then easy prompts in one session. This is observed behavior for those prompts, not a guarantee of model choice.

v0.6.1

Choose a tag to compare

@alexei-led alexei-led released this 21 Sep 11:56
v0.6.1
dfc3962

Jev route visibility

  • Add compact Pi footer/status markers: 🧭 Jev ✓ means Jev selected the route; 🧭 Jev ↪ base means Jev ran but the local deterministic baseline was used.
  • Keep the normal footer unchanged when Jev is not involved.
  • Show the same marker and short latency in the optional widget and /router status.
  • Keep raw Jev context, responses, credentials and remote explanations out of the UI and persisted state.

Routing provenance

  • Track closed route-guidance outcomes across Jev, classifier, bypass and baseline paths.
  • Preserve provenance across reusable tool continuations and explicit generation fallbacks.
  • Reject invalid persisted outcomes while remaining compatible with older 0.6.0 snapshots.

Verification

  • npm test — 442 tests passing.
  • npm run check — passing.
  • npm audit --omit=dev — 0 vulnerabilities.
  • npm publish --dry-run --access public — passing; no test files or .env files in the package.

Full Changelog: v0.6.0...v0.6.1

@alexeiled/pi-model-router 0.6.0

Choose a tag to compare

@github-actions github-actions released this 21 Sep 10:56
v0.6.0
69f5df2

Package

  • Name: @alexeiled/pi-model-router
  • Version: 0.6.0
  • Tag: v0.6.0
  • Commit: 69f5df208eb47c55620bae277f2100c7b949b5b6

Jev-aware routing

  • Add optional Jev System One Choice advice for eligible new user turns.
  • Jev uses user-level credentials, explicit per-profile privacy opt-in, and bounded recent user/assistant/tool context.
  • Accept only validated current primary candidate IDs; do not retry or accept remote explanations as routing instructions.
  • Cap Jev transport at 750 ms within the 1500 ms advisory budget.
  • Route uncertain, invalid, failed, or cancelled advice directly to the eligible deterministic baseline. No second-advisor cascade.
  • Pins, budget policy, single-candidate routes, and tool continuations bypass advisors.
  • Keep advisor credentials, request text, and raw responses out of persisted router state and UI.

Four-level routing

  • Add the optional micro tier with off thinking by default.
  • Treat micro, low, medium, and high as model/effort choices, not security or tool-permission boundaries.
  • Filter model availability, input limits, and thinking support before selecting a baseline or fallback.

Verification

  • npm test — 432 tests passing.
  • npm run check — passing.

What's Changed

  • feat: semantic four-level routing and prepare 0.6.0 by @alexei-led in #5

Full Changelog: v0.5.2...v0.6.0

@alexeiled/pi-model-router 0.5.2

Choose a tag to compare

@github-actions github-actions released this 20 Sep 09:42
v0.5.2
07efb7c

Package

  • Name: @alexeiled/pi-model-router
  • Version: 0.5.2
  • Tag: v0.5.2
  • Commit: 07efb7c7675804e99ff5be2c7a5b3113996ccea3

What's Changed

  • refactor: simplify router modules and test setup by @alexei-led in #4

Full Changelog: v0.5.1...v0.5.2

@alexeiled/pi-model-router 0.5.1

Choose a tag to compare

@github-actions github-actions released this 20 Sep 08:25
v0.5.1
cee172e

Package

  • Name: @alexeiled/pi-model-router
  • Version: 0.5.1
  • Tag: v0.5.1
  • Commit: cee172e44ac66fd249ebdd5bc33819b622c15616

What's Changed

Full Changelog: v0.5.0...v0.5.1

@alexeiled/pi-model-router v0.5.0

Choose a tag to compare

@alexei-led alexei-led released this 20 Sep 07:49
v0.5.0
63416a8

What's Changed

Full Changelog: v0.3.3...v0.5.0