@alexeiled/claude-router 1.21.0 → 1.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "router",
3
3
  "displayName": "Router",
4
- "version": "1.21.0",
4
+ "version": "1.21.1",
5
5
  "description": "Native model and effort routing within your provider. Anthropic, DeepSeek, z.ai, MiniMax, MiMo and Kimi defaults, custom provider profiles, classifier advice and one model per subagent.",
6
6
  "author": {
7
7
  "name": "Alexei Ledenev",
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.21.1 (2026-11-05)
4
+
5
+ ### Changed
6
+
7
+ - `cost` mode moves down sooner. A cheaper tier now needs 65% support (`downgradeMass` 0.65), down from 80%. In 578 recorded cost decisions the classifier chose `high` on 33% of answers, but the router ran `high` on 58%: none of the 136 answers for a lower tier cleared the old bar of about 0.87 at ~430k tokens. A weaker activity on the same task uses the same bar. The upgrade bar is unchanged.
8
+ - `cost` keeps the `high` tier's model and drops one effort level. `high` ops runs Opus 5.5 at high, not Haiku 5.5.
9
+ - `cost` at `low` takes the `low` route when its model is cheaper than the activity's. `low` code, debug, plan and review run Haiku 5.5 at high, not Sonnet 5.5 at medium, which scored lower on FrontierCode and costs more per token. On MiMo, `high` read-only work runs Pro.
10
+ - The session difference names what it compares with: `−$1.84 (−22%) vs Opus 5.5` when every main reply was priced against your `/model` and no subagent ran, else `vs unrouted`. The pane and `/router` add the unrouted amount: `vs Opus 5.5 ≈$8.24`.
11
+ - Below 10 main replies the count reads `3 replies so far` instead of `early` or `early sample`, and the pane adds why: one model switch can still move the difference a lot.
12
+
13
+ ### Upgrade
14
+
15
+ Restart Claude Code after updating. A `modes.cost.policy` in `router.json` still overrides the new values.
16
+
3
17
  ## 1.21.0 (2026-11-04)
4
18
 
5
19
  ### Changed
@@ -104,7 +104,7 @@ At session start the incumbent is the session's model. `cellForModel` looks for
104
104
 
105
105
  ## Routing modes
106
106
 
107
- The routing mode (`lib/modes.mjs`) is a fixed transform of the configured routes, applied before policy. At `turn.start` the hook resolves the mode (session override in `$.store` `routing-mode:<session id>`, then the project's `.claude/router.json`, then `mode` in the profile `router.json`, then `balanced`) and stores `applyMode(router.config, mode)` as the turn's config: every tier's and activity's route as `modeRoute` gives it, and `modes[mode].policy` over `policy`. Every later read of the turn (policy, escalation, cache keys, activity order, the request) uses that one table. `modeRoute` always starts from the configured routes, so a turn never steps from a route a mode already moved. `cost` takes the route of the tier below (never below `low`) when its model has a lower input price, else one listed effort level less; `quality` one listed effort level more, else the tier above's route. `micro` and pins keep the configured route.
107
+ The routing mode (`lib/modes.mjs`) is a fixed transform of the configured routes, applied before policy. At `turn.start` the hook resolves the mode (session override in `$.store` `routing-mode:<session id>`, then the project's `.claude/router.json`, then `mode` in the profile `router.json`, then `balanced`) and stores `applyMode(router.config, mode)` as the turn's config: every tier's and activity's route as `modeRoute` gives it, and `modes[mode].policy` over `policy`. Every later read of the turn (policy, escalation, cache keys, activity order, the request) uses that one table. `modeRoute` always starts from the configured routes, so a turn never steps from a route a mode already moved. `cost` takes the route of the tier below (at `low`, the `low` route without its activity override; never `micro`) when its model has a lower input price, else one listed effort level less, and `high` always keeps its model; `quality` one listed effort level more, else the tier above's route. `micro` and pins keep the configured route.
108
108
 
109
109
  **Route in use.** The loop keeps the route the last decision ran (`loop.route`, models key and effort) instead of rebuilding it from config. The incumbent's price, cache key and order come from it, and a decision that stays on the incumbent's cell keeps running it. So a mode change, or a route edit, reaches the request only through a gate: a tier switch, a taken lateral move, or a pin. A loop saved before 1.15 has no `loop.route` and rebuilds it once.
110
110
 
package/docs/providers.md CHANGED
@@ -187,8 +187,7 @@ Generate these tables with `node scripts/provider-matrix.mjs`.
187
187
  | low | explore, ops, docs | flash · no routed effort | flash · no routed effort | flash · no routed effort |
188
188
  | medium | base/uncertain, code, debug, plan, review | flash · no routed effort | pro · no routed effort | pro · no routed effort |
189
189
  | medium | explore, ops, docs | flash · no routed effort | flash · no routed effort | pro · no routed effort |
190
- | high | base/uncertain, code, debug, plan, review | pro · no routed effort | pro · no routed effort | pro · no routed effort |
191
- | high | explore, ops, docs | flash · no routed effort | pro · no routed effort | pro · no routed effort |
190
+ | high | base/uncertain, code, debug, explore, plan, review, ops, docs | pro · no routed effort | pro · no routed effort | pro · no routed effort |
192
191
 
193
192
  **kimi**
194
193
 
@@ -203,7 +202,7 @@ Generate these tables with `node scripts/provider-matrix.mjs`.
203
202
 
204
203
  MiniMax uses all four preset effort levels. `xhigh` is omitted because some Claude Code versions send it as `high`;
205
204
  `max` supplies the deeper setting. Legacy M3 ignores effort and is not a stronger tier by default.
206
- MiMo's cost/quality modes change models where a neighbouring tier permits it; otherwise the route stays the same.
205
+ MiMo's cost/quality modes change models where a neighbouring tier permits it, except that `cost` keeps `high` on its model; otherwise the route stays the same.
207
206
  Kimi uses only `low`, `high`, `max`, the documented controls, and never promotes a session into another model.
208
207
  These are starting policies, not an optimal activity matrix. See [research and experiments](provider-experiments.md).
209
208
 
@@ -318,7 +317,7 @@ Launch on the model you would otherwise use:
318
317
  A launch model must be a model that some route runs. On any other model, a fresh session starts with routing off.
319
318
  To start on another Claude model, such as Sonnet, add it to `models`, put it on a route, and map it in the proxy configuration.
320
319
 
321
- Opus is billed by the plan and DeepSeek in credits, but the pane prices both at list prices, so one sum compares them: `session ≈$24.10 API value billed $4.10 −$45.90 (−66%) vs no routing`, where `billed $4.10` is the DeepSeek part.
320
+ Opus is billed by the plan and DeepSeek in credits, but the pane prices both at list prices, so one sum compares them: `session ≈$24.10 API value billed $4.10 −$45.90 (−66%) vs Opus 5.5`, where `billed $4.10` is the DeepSeek part.
322
321
  See [how dollars are paid](user-guide.md#how-dollars-are-paid).
323
322
 
324
323
  Open `/router` and check the selected file, classifier health and routing state before use.
@@ -25,7 +25,7 @@
25
25
  <text x="765.0" y="56" fill="#87d787" xml:space="preserve">100%</text>
26
26
  <text x="796.2" y="56" fill="#7c7c7c" xml:space="preserve"> last</text>
27
27
  <text x="850.8" y="56" fill="#d0d0d0" xml:space="preserve">Router</text>
28
- <text class="cap" x="20" y="95">Two rows on a Claude plan, with the hover row shown: plan windows, the session as API value against no routing, pins</text>
28
+ <text class="cap" x="20" y="95">Two rows on a Claude plan, with the hover row shown: plan windows, the session as API value against your model, pins</text>
29
29
  <rect x="12" y="103" width="897.6" height="67" rx="5" fill="#232323"/>
30
30
  <text x="24.0" y="121" fill="#e0708a" xml:space="preserve">▂</text>
31
31
  <text x="31.8" y="121" fill="#e0708a" xml:space="preserve">▄</text>
@@ -54,8 +54,8 @@
54
54
  <text x="390.6" y="140" fill="#d0d0d0" font-weight="700" xml:space="preserve">≈$6.40</text>
55
55
  <text x="437.4" y="140" fill="#7c7c7c" xml:space="preserve"> API value</text>
56
56
  <text x="538.8" y="140" fill="#6fcf97" font-weight="700" xml:space="preserve">−$1.84 (−22%)</text>
57
- <text x="640.2" y="140" fill="#7c7c7c" xml:space="preserve"> vs no routing</text>
58
- <text x="772.8" y="140" fill="#7c7c7c" xml:space="preserve">64 replies</text>
57
+ <text x="640.2" y="140" fill="#7c7c7c" xml:space="preserve"> vs Opus 5.5</text>
58
+ <text x="757.2" y="140" fill="#7c7c7c" xml:space="preserve">64 replies</text>
59
59
  <text x="24.0" y="159" fill="#7c7c7c" xml:space="preserve">pin </text>
60
60
  <rect x="55.2" y="145" width="140.4" height="18" rx="4" fill="#2e3340"/>
61
61
  <text x="55.2" y="159" fill="#d0d0d0" xml:space="preserve">[ ▂ Haiku·medium ]</text>
@@ -69,7 +69,7 @@
69
69
  <text x="663.6" y="159" fill="#d0d0d0" xml:space="preserve">[ Turn off ]</text>
70
70
  <rect x="772.8" y="145" width="70.2" height="18" rx="4" fill="#2e3340"/>
71
71
  <text x="772.8" y="159" fill="#d0d0d0" xml:space="preserve">[ 1 row ]</text>
72
- <text class="cap" x="20" y="198">Two rows on an API key: the session as billed against no routing</text>
72
+ <text class="cap" x="20" y="198">Two rows on an API key: the session as billed against your model</text>
73
73
  <rect x="12" y="206" width="897.6" height="48" rx="5" fill="#232323"/>
74
74
  <text x="24.0" y="224" fill="#e0708a" xml:space="preserve">▂</text>
75
75
  <text x="31.8" y="224" fill="#e0708a" xml:space="preserve">▄</text>
@@ -91,8 +91,8 @@
91
91
  <text x="86.4" y="243" fill="#d0d0d0" font-weight="700" xml:space="preserve">$6.40</text>
92
92
  <text x="125.4" y="243" fill="#7c7c7c" xml:space="preserve"> billed</text>
93
93
  <text x="203.4" y="243" fill="#6fcf97" font-weight="700" xml:space="preserve">−$1.84 (−22%)</text>
94
- <text x="304.8" y="243" fill="#7c7c7c" xml:space="preserve"> vs no routing</text>
95
- <text x="437.4" y="243" fill="#7c7c7c" xml:space="preserve">64 replies</text>
94
+ <text x="304.8" y="243" fill="#7c7c7c" xml:space="preserve"> vs Opus 5.5</text>
95
+ <text x="421.8" y="243" fill="#7c7c7c" xml:space="preserve">64 replies</text>
96
96
  <text class="cap" x="20" y="282">A pin waits for the next turn; ✕ cancels it</text>
97
97
  <rect x="12" y="290" width="897.6" height="29" rx="5" fill="#232323"/>
98
98
  <text x="24.0" y="308" fill="#5f9fe0" xml:space="preserve">▂</text>
@@ -1,6 +1,6 @@
1
1
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 602 496" role="img" aria-labelledby="title desc">
2
2
  <title id="title">Router pane, Now tab</title>
3
- <desc id="desc">NEXT TURN: the tier meter, model and activity, the reason with the classifier support it weighed and the switch cost, and one pin per tier, low to high, with its support. PLAN: the 5-hour and 7-day windows with their resets. SESSION: the total of the main thread and one running subagent as API value, the difference against no routing, the main thread and the subagents as bars on one scale, and a strip of every reply colored by tier with the replies per tier. CONTEXT: the window fill and the cache reuse.</desc>
3
+ <desc id="desc">NEXT TURN: the tier meter, model and activity, the reason with the classifier support it weighed and the switch cost, and one pin per tier, low to high, with its support. PLAN: the 5-hour and 7-day windows with their resets. SESSION: the total of the main thread and one running subagent as API value, the difference against unrouted, the main thread and the subagents as bars on one scale, and a strip of every reply colored by tier with the replies per tier. CONTEXT: the window fill and the cache reuse.</desc>
4
4
  <style>
5
5
  text { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace; font-size: 13px; }
6
6
  .cap { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 12px; fill: #9a988f; }
@@ -63,8 +63,8 @@
63
63
  <rect x="382.8" y="286" width="70.2" height="18" rx="4" fill="#2e3340"/>
64
64
  <text x="382.8" y="300" fill="#d0d0d0" xml:space="preserve">[ Usage ]</text>
65
65
  <text x="39.6" y="319" fill="#6fcf97" font-weight="700" xml:space="preserve">−$4.09 (−31%)</text>
66
- <text x="141.0" y="319" fill="#d0d0d0" xml:space="preserve"> vs no routing</text>
67
- <text x="250.2" y="319" fill="#7c7c7c" xml:space="preserve"> of ≈$13.06</text>
66
+ <text x="141.0" y="319" fill="#d0d0d0" xml:space="preserve"> vs unrouted</text>
67
+ <text x="234.6" y="319" fill="#7c7c7c" xml:space="preserve"> ≈$13.06</text>
68
68
  <text x="24.0" y="338" fill="#d0d0d0" xml:space="preserve"> main </text>
69
69
  <text x="86.4" y="338" fill="#d0d0d0" xml:space="preserve"> ≈$6.45</text>
70
70
  <text x="156.6" y="338" fill="#5fafd7" xml:space="preserve">████████████████</text>
@@ -41,10 +41,10 @@
41
41
  <text x="24.0" y="110" fill="#7c7c7c" xml:space="preserve">this session · your model </text>
42
42
  <text x="226.8" y="110" fill="#e0708a" font-weight="700" xml:space="preserve">Opus 5.5 · xhigh</text>
43
43
  <text x="24.0" y="148" fill="#6fcf97" font-weight="700" xml:space="preserve">−$4.09 (−31%)</text>
44
- <text x="125.4" y="148" fill="#d0d0d0" xml:space="preserve"> vs no routing</text>
44
+ <text x="125.4" y="148" fill="#d0d0d0" xml:space="preserve"> vs unrouted</text>
45
45
  <text x="226.8" y="186" fill="#7c7c7c" xml:space="preserve"> cost</text>
46
- <text x="289.2" y="186" fill="#7c7c7c" xml:space="preserve"> vs no routing</text>
47
- <text x="406.2" y="186" fill="#7c7c7c" xml:space="preserve"> no routing</text>
46
+ <text x="289.2" y="186" fill="#7c7c7c" xml:space="preserve"> vs unrouted</text>
47
+ <text x="406.2" y="186" fill="#7c7c7c" xml:space="preserve"> unrouted</text>
48
48
  <text x="24.0" y="205" fill="#d0d0d0" xml:space="preserve">main · 86 replies</text>
49
49
  <text x="226.8" y="205" fill="#d0d0d0" xml:space="preserve"> ≈$6.45</text>
50
50
  <text x="289.2" y="205" fill="#6fcf97" xml:space="preserve"> −$4.17</text>
@@ -72,7 +72,7 @@
72
72
  <rect x="234.6" y="362" width="62.4" height="18" rx="4" fill="#87afff"/>
73
73
  <text x="234.6" y="376" fill="#0d1016" font-weight="700" xml:space="preserve">[ Tier ]</text>
74
74
  <text x="304.8" y="376" fill="#7c7c7c" xml:space="preserve"> g next</text>
75
- <text x="24.0" y="395" fill="#7c7c7c" xml:space="preserve"> replies cost vs no routing mostly on</text>
75
+ <text x="24.0" y="395" fill="#7c7c7c" xml:space="preserve"> replies cost vs unrouted mostly on</text>
76
76
  <text x="39.6" y="414" fill="#d0d0d0" xml:space="preserve">▸</text>
77
77
  <text x="55.2" y="414" fill="#5f9fe0" xml:space="preserve">▂▄</text>
78
78
  <text x="211.2" y="414" fill="#d0d0d0" xml:space="preserve"> 41 ≈$1.20</text>
@@ -1,6 +1,6 @@
1
1
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 758 1123" role="img" aria-labelledby="title desc">
2
2
  <title id="title">Router pane, Usage tab</title>
3
- <desc id="desc">The last 7 days across sessions: the period row, the difference against no routing first, then a cost table whose rows add up (the main thread with its cheaper-model saving and cache rebuilds, the subagents, the total) with each row against no routing, the replies and tokens, the cost by activity with code opened to its routes and cost parts, the cost by day, what is worth a look with a link to Routes, subagents, and Delete history.</desc>
3
+ <desc id="desc">The last 7 days across sessions: the period row, the difference against unrouted first, then a cost table whose rows add up (the main thread with its cheaper-model saving and cache rebuilds, the subagents, the total) with each row against unrouted, the replies and tokens, the cost by activity with code opened to its routes and cost parts, the cost by day, what is worth a look with a link to Routes, subagents, and Delete history.</desc>
4
4
  <style>
5
5
  text { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace; font-size: 13px; }
6
6
  .cap { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 12px; fill: #9a988f; }
@@ -40,10 +40,10 @@
40
40
  <text x="453.0" y="91" fill="#7c7c7c" xml:space="preserve"> p next</text>
41
41
  <text x="24.0" y="110" fill="#7c7c7c" xml:space="preserve">all projects · Oct 7 – Oct 13 · each session vs its own model</text>
42
42
  <text x="24.0" y="148" fill="#6fcf97" font-weight="700" xml:space="preserve">−$12.29 (−37%)</text>
43
- <text x="133.2" y="148" fill="#d0d0d0" xml:space="preserve"> vs no routing</text>
43
+ <text x="133.2" y="148" fill="#d0d0d0" xml:space="preserve"> vs unrouted</text>
44
44
  <text x="226.8" y="186" fill="#7c7c7c" xml:space="preserve"> cost</text>
45
- <text x="289.2" y="186" fill="#7c7c7c" xml:space="preserve"> vs no routing</text>
46
- <text x="406.2" y="186" fill="#7c7c7c" xml:space="preserve"> no routing</text>
45
+ <text x="289.2" y="186" fill="#7c7c7c" xml:space="preserve"> vs unrouted</text>
46
+ <text x="406.2" y="186" fill="#7c7c7c" xml:space="preserve"> unrouted</text>
47
47
  <text x="24.0" y="205" fill="#d0d0d0" xml:space="preserve">main · 221 replies</text>
48
48
  <text x="226.8" y="205" fill="#d0d0d0" xml:space="preserve"> ≈$15.33</text>
49
49
  <text x="289.2" y="205" fill="#6fcf97" xml:space="preserve"> −$11.78</text>
@@ -71,7 +71,7 @@
71
71
  <rect x="234.6" y="362" width="62.4" height="18" rx="4" fill="#2e3340"/>
72
72
  <text x="234.6" y="376" fill="#d0d0d0" xml:space="preserve">[ Tier ]</text>
73
73
  <text x="304.8" y="376" fill="#7c7c7c" xml:space="preserve"> g next</text>
74
- <text x="24.0" y="395" fill="#7c7c7c" xml:space="preserve"> replies cost vs no routing mostly on</text>
74
+ <text x="24.0" y="395" fill="#7c7c7c" xml:space="preserve"> replies cost vs unrouted mostly on</text>
75
75
  <text x="39.6" y="414" fill="#d0d0d0" xml:space="preserve">▾</text>
76
76
  <text x="55.2" y="414" fill="#d7875f" font-style="italic" xml:space="preserve">code</text>
77
77
  <text x="211.2" y="414" fill="#d0d0d0" xml:space="preserve"> 125 ≈$12.70</text>
@@ -5,7 +5,7 @@ your routes stay as they are. The mode moves the route each tier runs by one fix
5
5
 
6
6
  | Mode | What changes |
7
7
  | --- | --- |
8
- | `cost` | A cheaper route where the turn allows it: the tier below when that tier runs a model with a lower input price, else one effort level less on the same model. Never below `low`. |
8
+ | `cost` | A cheaper route where the turn allows it: the tier below when that tier runs a model with a lower input price (at `low`, the `low` route without its activity override), else one effort level less on the same model. `high` keeps its model and drops one effort level. Never below `low`. |
9
9
  | `balanced` | Nothing: every tier runs its route as configured. |
10
10
  | `quality` | One effort level more on the same model, else the route of the tier above. |
11
11
 
@@ -48,13 +48,19 @@ Each mode except `balanced` replaces some `policy` fields while it is active. Th
48
48
  codex-router's and are **not tuned** on outcomes. Since 1.16, `cost` upgrades on balanced's bar (2 votes from 0.75):
49
49
  with 3 votes from 0.85, the cache write of a cold stronger model raised the bar to about 0.92 from 60k tokens and 0.97
50
50
  at 250k, so a cost turn on Haiku kept a task the classifier scored hard at 90%. `cost` still moves down sooner than
51
- `balanced` (one vote, 80% support, a 4-request dwell):
51
+ `balanced`: one vote, a 4-request dwell, and since 1.21.1 65% support. At 80% support
52
+ the cold cache of a cheaper model raised the bar to about 0.87 at ~430k tokens. In 578 recorded cost decisions the
53
+ classifier chose `high` on 33% of answers, the router ran `high` on 58%, and none of the 136 answers for a lower tier
54
+ cleared the bar. Not 60%: an upgrade counts all the mass above the running tier, so an answer split between medium
55
+ and high can move `low` to `high`, and at 60% the next such answer dropped straight back to the still-warm cheaper
56
+ cache:
52
57
 
53
58
  ```json
54
59
  {
55
60
  "modes": {
56
61
  "cost": { "policy": { "upgradeVotes": 2, "upgradeBase": 0.75, "jumpConfidence": 0.98, "downgradeVotes": 1,
57
- "downgradeMass": 0.8, "minDwellRequests": 4, "escalationHoldTurns": 1 } },
62
+ "downgradeMass": 0.65, "minDwellRequests": 4,
63
+ "escalationHoldTurns": 1 } },
58
64
  "quality": { "policy": { "upgradeVotes": 1, "upgradeBase": 0.6, "jumpConfidence": 0.9, "downgradeVotes": 3,
59
65
  "downgradeMass": 0.95, "minDwellRequests": 16, "escalationHoldTurns": 4 } }
60
66
  }
@@ -75,14 +81,13 @@ path. Generated from the test data by `npm run docs:modes`; `test/mode-matrix.te
75
81
  | Classifier | Activities | cost | balanced | quality |
76
82
  | --- | --- | --- | --- | --- |
77
83
  | micro | code, debug, explore, plan, review, ops, docs, uncertain | Haiku · medium | Haiku · medium | Haiku · medium |
78
- | low | code, debug, plan, review | Sonnet · medium | Sonnet · high | Sonnet · xhigh |
84
+ | low | code, debug, plan, review | Haiku · high | Sonnet · high | Sonnet · xhigh |
79
85
  | low | explore, ops, docs, uncertain | Haiku · medium | Haiku · high | Haiku · xhigh |
80
86
  | medium | code, debug, plan, review | Sonnet · high | Opus · medium | Opus · high |
81
87
  | medium | explore, docs, uncertain | Haiku · high | Opus · medium | Opus · high |
82
88
  | medium | ops | Haiku · medium | Haiku · high | Haiku · xhigh |
83
- | high | code, debug, explore, plan, review, docs, uncertain | Opus · high | Opus · xhigh | Opus · max |
84
- | high | ops | Haiku · high | Opus · xhigh | Opus · max |
85
- | uncertain | code, debug, plan, review | Sonnet · medium | Sonnet · high | Sonnet · xhigh |
89
+ | high | code, debug, explore, plan, review, ops, docs, uncertain | Opus · high | Opus · xhigh | Opus · max |
90
+ | uncertain | code, debug, plan, review | Haiku · high | Sonnet · high | Sonnet · xhigh |
86
91
  | uncertain | explore, ops, docs, uncertain | Haiku · medium | Haiku · high | Haiku · xhigh |
87
92
 
88
93
  **`routes.high` = Opus · high**
@@ -90,33 +95,30 @@ path. Generated from the test data by `npm run docs:modes`; `test/mode-matrix.te
90
95
  | Classifier | Activities | cost | balanced | quality |
91
96
  | --- | --- | --- | --- | --- |
92
97
  | micro | code, debug, explore, plan, review, ops, docs, uncertain | Haiku · medium | Haiku · medium | Haiku · medium |
93
- | low | code, debug, plan, review | Sonnet · medium | Sonnet · high | Sonnet · xhigh |
98
+ | low | code, debug, plan, review | Haiku · high | Sonnet · high | Sonnet · xhigh |
94
99
  | low | explore, ops, docs, uncertain | Haiku · medium | Haiku · high | Haiku · xhigh |
95
100
  | medium | code, debug, plan, review | Sonnet · high | Opus · medium | Opus · high |
96
101
  | medium | explore, docs, uncertain | Haiku · high | Opus · medium | Opus · high |
97
102
  | medium | ops | Haiku · medium | Haiku · high | Haiku · xhigh |
98
- | high | code, debug, explore, plan, review, docs, uncertain | Opus · medium | Opus · high | Opus · xhigh |
99
- | high | ops | Haiku · high | Opus · high | Opus · xhigh |
100
- | uncertain | code, debug, plan, review | Sonnet · medium | Sonnet · high | Sonnet · xhigh |
103
+ | high | code, debug, explore, plan, review, ops, docs, uncertain | Opus · medium | Opus · high | Opus · xhigh |
104
+ | uncertain | code, debug, plan, review | Haiku · high | Sonnet · high | Sonnet · xhigh |
101
105
  | uncertain | explore, ops, docs, uncertain | Haiku · medium | Haiku · high | Haiku · xhigh |
102
106
  <!-- mode-matrix:end -->
103
107
 
104
108
  ## Known trade-offs
105
109
 
106
- The steps are fixed rules, with no per-activity exceptions. Two cells go against this router's own model notes
107
- (`lib/config.mjs`), and replay data should decide them later:
110
+ The steps are fixed rules, with no per-activity exceptions. Before 1.21.1, `cost` ran `high` ops on Haiku 5.5 and `low`
111
+ code on Sonnet 5.5 at medium, which scored below Haiku 5.5 at high on FrontierCode and costs more per token. One cell
112
+ still goes against this router's own model notes (`lib/config.mjs`):
108
113
 
109
- - `cost` at `high` for **ops** runs Haiku 5.5 at high (the `medium` ops route), although Haiku trails Opus on
110
- multi-step tool work. Repeated tool errors cannot escalate it: no tier is above `high`. For such a task, pin `high`
111
- or switch to `balanced`.
112
- - `cost` at `low` for **code, debug, plan and review** runs Sonnet 5.5 at medium, which scored below Haiku 5.5 at high
113
- on FrontierCode and costs more per token.
114
+ - `cost` at `medium` for **ops** runs Haiku 5.5 at medium, although Haiku trails on shell work (Artificial Analysis
115
+ v5.0.1 Terminal-Bench 4.0: Haiku 5.5 15.2% at medium, Sonnet 5.5 29.8%). Repeated tool errors still escalate it.
114
116
 
115
- With the built-in routes, `cost` at `low` runs Haiku 5.5 at medium, the same route as `micro`.
117
+ With the built-in routes, `cost` at `low` runs Haiku 5.5 at medium for read-only work and Haiku 5.5 at high for code.
116
118
 
117
119
  ## Measured impact
118
120
 
119
- One 5-turn coding task (read two files, add a function with tests, run the tests, review, add edge-case tests), the
121
+ Measured on 1.16, before the 1.21.1 rule and policy changes, which are not measured yet. One 5-turn coding task (read two files, add a function with tests, run the tests, review, add edge-case tests), the
120
122
  same prompts in a new session per mode, Jev classifier, built-in routes. Cost is a list-price estimate of the measured
121
123
  tokens ([raw results](../experiments/mod-router/results/mode-live-acceptance.json)).
122
124
 
@@ -71,10 +71,10 @@ While routing is on, hover over the band for a second row: a pin per tier, low t
71
71
  **2 rows** adds the session under the route, in the same numbers as the pane's SESSION block. On a Claude plan it leads with the plan windows Claude Code reports:
72
72
 
73
73
  ```text
74
- plan 5h ▰▰▰▰▱▱▱▱ 48% ↻18:00 7d 43% session ≈$6.40 API value −$1.84 (−22%) vs no routing 64 replies
74
+ plan 5h ▰▰▰▰▱▱▱▱ 48% ↻18:00 7d 43% session ≈$6.40 API value −$1.84 (−22%) vs Opus 5.5 64 replies
75
75
  ```
76
76
 
77
- On an API key, or a provider billed in credits, the same row reads `session $6.40 billed −$1.84 (−22%) vs no routing 64 replies`. Read it as: this session's replies and subagents cost $6.40 at list prices, $1.84 less than without the router. **No routing** is your model on every main-thread reply and Claude Code's own pick for every subagent, priced on the same tokens. Minus is cheaper than no routing, plus is dearer; past double it reads as a ratio, `+$2.48 (×5.0)`. `≈` marks [API value](#how-dollars-are-paid): plan quota, not a charge. A profile that mixes plan and credits models adds the billed part, `billed $4.10`. Before the tenth routed reply the difference adds `· early`, because one switch can decide a short run. Some situations change the middle part:
77
+ On an API key, or a provider billed in credits, the same row reads `session $6.40 billed −$1.84 (−22%) vs Opus 5.5 64 replies`. Read it as: this session's replies cost $6.40 at list prices, $1.84 less than the same tokens on Opus 5.5, the model `/model` selected. The band names that model while every main reply was priced against it and no subagent ran. Otherwise it reads `vs unrouted`: your model on every main-thread reply and Claude Code's own pick for every subagent, priced on the same tokens. Minus is cheaper, plus is dearer; past double it reads as a ratio, `+$2.48 (×5.0)`. `≈` marks [API value](#how-dollars-are-paid): plan quota, not a charge. A profile that mixes plan and credits models adds the billed part, `billed $4.10`. Before the tenth routed reply the count reads `3 replies so far`, because one model switch and its cache write can still decide a short run. Some situations change the middle part:
78
78
 
79
79
  - `effort low 4 · high 2`: the profile runs one model and routing moves only the effort, so no saving is estimated; see [Providers](providers.md).
80
80
  - `3 of 20 not compared`: some replies have no comparison, such as on a provider whose cache hit rate cannot be known; no saving is shown.
@@ -103,7 +103,7 @@ Run `/router` or select **Router** above the prompt. Without a UI surface, as in
103
103
 
104
104
  The top line of every tab, `ROUTER [ ◉ on ] [ ○ off ] Jev ready · 347 ms`, shows the routing mode, switches it, and says whether the classifier is ready. Press `o` or `f` while the pane has focus. The tabs under it carry their digits, `[ 1 Now ] [ 2 Routes ] …`, and **?** shows what the numbers mean above the tab. When routing is unavailable, the top line reads `ROUTER unavailable Claude’s model is kept` with the reason under it, and offers no on or off: see [Troubleshooting](#troubleshooting).
105
105
 
106
- ![The Now tab in four blocks. NEXT TURN: the tier meter, model and activity, the reason with the classifier support and the switch cost, one pin per tier. PLAN: the 5-hour and 7-day windows with their resets. SESSION: the total with one running subagent as API value, the difference against no routing, the main thread and the subagents as bars, and a strip of every reply colored by tier. CONTEXT: the window fill and the cache reuse](router-pane-now.svg)
106
+ ![The Now tab in four blocks. NEXT TURN: the tier meter, model and activity, the reason with the classifier support and the switch cost, one pin per tier. PLAN: the 5-hour and 7-day windows with their resets. SESSION: the total with one running subagent as API value, the difference against unrouted, the main thread and the subagents as bars, and a strip of every reply colored by tier. CONTEXT: the window fill and the cache reuse](router-pane-now.svg)
107
107
 
108
108
  The **Now** tab has four blocks, each with its name in capitals.
109
109
 
@@ -116,7 +116,7 @@ The **Now** tab has four blocks, each with its name in capitals.
116
116
  ```text
117
117
  SESSION since 14:18 · 86 replies · 6 agents · 9 switches ● 1 running
118
118
  ≈$8.97 API value · plan quota, not billed [ Usage ]
119
- −$4.09 (−31%) vs no routing of ≈$13.06
119
+ −$4.09 (−31%) vs unrouted ≈$13.06
120
120
  main ≈$6.45 ████████████████ −$4.17 vs Opus 5.5 · xhigh
121
121
  agents ≈$2.52 ██████░░░░░░░░░░ +$0.08 vs their picks
122
122
  tiers ███████████████████████████████████████████ 2 replies per cell
@@ -124,7 +124,7 @@ SESSION since 14:18 · 86 replies · 6 agents · 9 switches ● 1 running
124
124
  ```
125
125
 
126
126
  - The first line is the total and how it is paid: `API value · plan quota, not billed` on a plan, `billed at list prices` on an API key or credits, and `API value · $4.10 of it billed as credits` when a profile mixes the two. See [How dollars are paid](#how-dollars-are-paid). **Usage** opens the Usage tab on this session.
127
- - The second line is the difference against no routing and what no routing would have cost. The parts add up: main and agents make the total, and their differences make the session's difference (−$4.17 + $0.08 = −$4.09). Before the tenth main reply it adds `early sample`; a narrow pane drops that note first.
127
+ - The second line is the difference and what the same tokens would have cost: `vs Opus 5.5 ≈$13.06` when every main reply was priced against your model and no subagent ran, else `vs unrouted ≈$13.06`. The parts add up: main and agents make the total, and their differences make the session's difference (−$4.17 + $0.08 = −$4.09). Before the tenth main reply a line follows: `3 replies so far: one model switch can still move this a lot`. A narrow pane drops the amount first.
128
128
  - **main** compares the main thread with your model, **agents** compares the subagents with Claude Code's picks. The bars share one scale.
129
129
  - An effort-only profile shows `effort routing on one model: no saving is estimated` and its effort mix instead. When some replies have no comparison, the block says how many and shows no saving.
130
130
  - When cache rebuilds cost more than the cheaper models saved, `▲ switches cost more than they saved` follows, with **Policy** to raise the bar for a switch.
@@ -144,18 +144,18 @@ Every write applies from the next turn and can be undone. **Undo** (`u`) puts ba
144
144
 
145
145
  ### Compare routing with no routing
146
146
 
147
- ![The Usage tab over 7 days: the period buttons, the difference against no routing first, then a cost table whose rows add up (the main thread with its cheaper-model saving and cache rebuilds, the subagents, the total), the tokens, the cost by activity with code opened to its routes, the cost by day, and the cell worth a look with a link to Routes](router-pane-usage.svg)
147
+ ![The Usage tab over 7 days: the period buttons, the difference against unrouted first, then a cost table whose rows add up (the main thread with its cheaper-model saving and cache rebuilds, the subagents, the total), the tokens, the cost by activity with code opened to its routes, the cost by day, and the cell worth a look with a link to Routes](router-pane-usage.svg)
148
148
 
149
- The Usage tab keeps observed routed spend and, when the cache history permits it, compares it with **no routing**: your model on every main-thread reply and Claude Code's own pick for every subagent, priced on the same tokens. Your model is the model `/model` (or `--model`) selected, at the session effort, when a reply ran. The router prices observed tokens at the list prices in `router.json`.
149
+ The Usage tab keeps observed routed spend and, when the cache history permits it, compares it with **unrouted**: your model on every main-thread reply and Claude Code's own pick for every subagent, priced on the same tokens. Your model is the model `/model` (or `--model`) selected, at the session effort, when a reply ran. The router prices observed tokens at the list prices in `router.json`.
150
150
 
151
151
  The top row picks the period: **Session**, **Today**, **7d** (today and the six days before), **30d**, **Month** (since the first of this month) and **All**. Press `p` for the next one. The pane remembers the choice across sessions. Session holds this session's replies, and the line under the row names your model, or every model when `/model` changed during the session. The other periods add up the replies of every session on those calendar days. Each session counts against its own model, and the line reads `all projects · Oct 7 – Oct 13 · each session vs its own model`.
152
152
 
153
- When the period is comparable, the difference comes first, then one table whose cents add up:
153
+ When the period is comparable, the difference comes first, then one table whose cents add up. The Usage tab always says `unrouted`, even for the session, because a period mixes your model with Claude Code's picks; the Now tab and the band name your model when they can:
154
154
 
155
155
  ```text
156
- −$12.29 (−37%) vs no routing
156
+ −$12.29 (−37%) vs unrouted
157
157
 
158
- cost vs no routing no routing
158
+ cost vs unrouted unrouted
159
159
  main · 221 replies ≈$15.33 −$11.78 ≈$27.11
160
160
  cheaper models −$12.29
161
161
  cache rebuilds +$0.51 4% of the saving
@@ -171,9 +171,9 @@ agents · 15 ≈$5.60 −$0.51 ≈$6.11
171
171
  | stronger models | What replies on models stronger than yours cost on top. Shown only when not zero. |
172
172
  | cache rebuilds | What rewriting the prompt cache after a model switch cost, and its share of the saving. |
173
173
  | agents | The subagents, against the same tokens on Claude Code's pick for each. |
174
- | total | The period's cost, its difference, and what no routing would have cost: `billed` or `≈ API value`. |
174
+ | total | The period's cost, its difference, and what unrouted would have cost: `billed` or `≈ API value`. |
175
175
 
176
- Each row reads across: cost − no routing = the difference. Down the table, main and agents make the total, and cheaper models, stronger models and cache rebuilds make main's difference. A profile that mixes plan and credits models adds `billed as credits` under the total. Below 10 routed replies the difference adds `early sample`, because one switch and its cache write can decide a short run.
176
+ Each row reads across: cost − unrouted = the difference. Down the table, main and agents make the total, and cheaper models, stronger models and cache rebuilds make main's difference. A profile that mixes plan and credits models adds `billed as credits` under the total. Below 10 routed replies the difference adds `3 replies so far: one model switch can still move this a lot`, because one switch and its cache write can decide a short run.
177
177
 
178
178
  When some replies have no comparison, the tab says `3 of 20 replies have no comparison: no saving is shown.`, and the table shows the cost alone. Counts, tokens, breakdowns and trends still include those replies; a row with incomplete coverage shows `—` against no routing, and **What if** stays unavailable rather than inventing a baseline. This is common with automatic provider caches, whose future hit rates are unknown. An effort-only profile says `Effort routing on one model: no saving is estimated; the cost is what was billed.`
179
179
 
@@ -280,7 +280,7 @@ On the running task:
280
280
  - `explore`, `plan`, `review`: a turn finished, nothing was edited, written, run or delegated, and the last tool result was not an error.
281
281
  - `code`, `debug` and a route with no activity: only a passed check counts.
282
282
 
283
- A failed check blocks every one of these, and so does a check whose result is not the check's own (chained, redirected, piped, after `;` or `||`, or in the background). While no checkpoint is met, the route stays: for a tier the band shows `… down after a checkpoint`; a held activity keeps the running one and shows `= fits`. A cheaper activity also needs 90% probability (`policy.downgradeMass`).
283
+ A failed check blocks every one of these, and so does a check whose result is not the check's own (chained, redirected, piped, after `;` or `||`, or in the background). While no checkpoint is met, the route stays: for a tier the band shows `… down after a checkpoint`; a held activity keeps the running one and shows `= fits`. A cheaper activity also needs 90% probability (`policy.downgradeMass`; 65% in `cost`).
284
284
  - A cheaper tier lands where the answer as a whole points: when the classifier says `micro` 63% and `low` 30%, the turn moves to `low`, which 93% of the answer supports, instead of staying until `micro` alone reaches 90%.
285
285
  - A pinned turn does not move. A new task, a prompt the classifier does not score as a continuation, is routed as a fresh turn. Ollama does not answer the continuation question, so every prompt is a new task to it; reviews inside a turn still apply.
286
286
 
@@ -295,7 +295,7 @@ These thresholds are starting values. They are not tuned on data yet.
295
295
 
296
296
  On the **Classifier** tab, **ACROSS SESSIONS · since the last reset** shows the counts kept across sessions, once there are any: the turns labelled from their tools, **Agreement** over them, **Code/ops/explore**, the same agreement over the turns the classifier answered `code`, `ops` or `explore` (omitted when there are none), the two most frequent mismatches as `predicted → observed count` (`code → read 3`), **Activity moves**, the moves to another route inside a tier, taken and refused for any reason, **Escalations**, such as `after a cheaper activity move: 1 in 12 moves`, the tool-error escalations that followed a move to a cheaper route in `on` while the turns stayed on it in `on` (turning routing off, a turn with routing off, or a turn in `off` ends the watch, a pin in between does not, and an escalation the credits cap held counts). Each of these lines appears only when it has data. The active classifier's p95 wait across sessions shows on its **Deadline** line instead (not recorded with activity routing `off`). This agreement compares the classifier's raw answer, so it can differ from the session's. The pane reads these counts when the session starts and when it opens, and adds this session's turns as they finish; another session's new latency and escalation readings show the next time the pane opens. **Delete history** on the Usage tab deletes these counts with the usage and subagent records, for this session and across sessions.
297
297
 
298
- `/router` without a UI surface adds an `Activity: ops (81%)` line, the resolved route, and `Agreement across sessions: 19 of 22 turns (86%) · code/ops/explore 9 of 10 (90%)`. It also prints the session in the band's words, such as `Session: $6.40 billed · −$1.84 (−22%) vs no routing · 64 replies`, after a `Plan: 5h 48% · 7d 43%` line on a Claude plan.
298
+ `/router` without a UI surface adds an `Activity: ops (81%)` line, the resolved route, and `Agreement across sessions: 19 of 22 turns (86%) · code/ops/explore 9 of 10 (90%)`. It also prints the session in the band's words, such as `Session: $6.40 billed · −$1.84 (−22%) vs Opus 5.5 $8.24 · 64 replies`, after a `Plan: 5h 48% · 7d 43%` line on a Claude plan.
299
299
 
300
300
  ## Change routing
301
301
 
package/lib/band.mjs CHANGED
@@ -2,6 +2,7 @@ import { activeClassifier, resolveRoute, TIERS } from './config.mjs';
2
2
  import { resetText } from './costs.mjs';
3
3
  import {
4
4
  BILLING_WORDS,
5
+ baselineName,
5
6
  classifierLabel,
6
7
  classifierStatus,
7
8
  classifierWarns,
@@ -16,10 +17,12 @@ import {
16
17
  percentPair,
17
18
  reasonActivity,
18
19
  reasonNamesActivity,
20
+ repliesText,
19
21
  routeLabel,
20
22
  routingModeOf,
21
23
  savingsColor,
22
24
  sessionCost,
25
+ sessionUsage,
23
26
  shortReason,
24
27
  shortRoute,
25
28
  shownConfig,
@@ -259,7 +262,8 @@ export function bandSegments(config, view, usage, actions) {
259
262
  }
260
263
 
261
264
  // The second row: the plan windows on a Claude plan, then this session's cost with its subagents, and how it compares
262
- // with no routing: "plan 5h ▰▰▰▱▱▱▱▱ 37% ↻17:00 7d 62% session ≈$7.60 API value −$1.76 (−19%) vs no routing".
265
+ // with your /model (or `unrouted` with subagents):
266
+ // "plan 5h ▰▰▰▱▱▱▱▱ 37% ↻17:00 7d 62% session ≈$7.60 API value −$1.76 (−19%) vs Sonnet 5.5 24 replies".
263
267
  // An effort-only profile shows its effort mix instead of a saving. When the band is narrow the reset time, the
264
268
  // counts and the words go first; the 5h window and the session total stay.
265
269
  export function sessionSegments(config, view, usage, now = Date.now()) {
@@ -299,8 +303,7 @@ export function sessionSegments(config, view, usage, now = Date.now()) {
299
303
  segment(
300
304
  1,
301
305
  part(diffText(cost.diffUsd, cost.baseUsd), { bold: true, color: savingsColor(cost.diffUsd) }),
302
- dim(' vs no routing'),
303
- cost.early ? { ...dim(' · early'), priority: 7 } : null,
306
+ dim(` vs ${baselineName(view, sessionUsage(view, now), cost)}`),
304
307
  ),
305
308
  );
306
309
  else if (cost.uncomparedReplies)
@@ -317,9 +320,7 @@ export function sessionSegments(config, view, usage, now = Date.now()) {
317
320
  out.push(
318
321
  segment(
319
322
  6,
320
- dim(
321
- `${cost.replies} repl${cost.replies === 1 ? 'y' : 'ies'}${cost.agents ? ` · ${cost.agents} agent${cost.agents === 1 ? '' : 's'}` : ''}`,
322
- ),
323
+ dim(`${repliesText(cost)}${cost.agents ? ` · ${cost.agents} agent${cost.agents === 1 ? '' : 's'}` : ''}`),
323
324
  ),
324
325
  );
325
326
  return out.filter(Boolean);
package/lib/config.mjs CHANGED
@@ -29,7 +29,8 @@ export const DEFAULTS = {
29
29
  // Haiku 5.5 is the worker at `low` and `micro`: at high effort it scored above Sonnet 5.5 at low, and at xhigh near
30
30
  // Sonnet at medium, for a fraction of the cost per attempt (Anthropic's OSWorld 2.1 effort chart: computer use, not
31
31
  // coding). Opus 5.5 at medium matched or beat Sonnet 5.5 at xhigh at 25-50% lower cost per task on Terminal-Bench
32
- // 4.0, FrontierCode v1.1 and CursorBench 4.0 (anthropic.com/claude-sonnet-5-5). `high` is Opus 5.5 at xhigh, the
32
+ // 4.0, FrontierCode v1.1 and CursorBench 4.0 (anthropic.com/claude-sonnet-5-5); Artificial Analysis v5.0.1 puts it
33
+ // just below (index 48.2 vs 49.9) at 60% of the cost per task, and Opus at high above. `high` is Opus 5.5 at xhigh, the
33
34
  // strongest setting this router asks for. These are routing defaults, not a claim of equal model quality.
34
35
  routes: {
35
36
  high: { model: 'opus', effort: 'xhigh' },
@@ -135,7 +136,12 @@ export const DEFAULTS = {
135
136
  // those fields of `policy` while it is active. The values started as codex-router's presets. 1.16 sets cost's upgrade
136
137
  // bar to balanced's (2 votes from 0.75): from 3 votes at 0.85 the bar, raised by the cache write of a cold stronger
137
138
  // model, sat at 0.92 from 60k tokens and 0.97 at 254k, so a cost turn on Haiku kept a task the classifier scored
138
- // hard at 90%. Cost still moves down sooner. Not tuned on outcomes yet.
139
+ // hard at 90%. Cost still moves down sooner. 1.21.1 lowers cost's downgrade bar: in 578 recorded cost decisions
140
+ // (one developer, Clef and Jev, ~430k-token contexts) the classifier chose `high` on 33% of answers but the router ran
141
+ // `high` on 58%, because none of the 136 answers for a lower tier cleared the ~0.87 bar a cold cheaper cache set.
142
+ // 0.65, not 0.6: an upgrade counts all mass above the incumbent, so a near-tie that moved two tiers up must not drop
143
+ // straight back to a warm cheaper cache.
144
+ // Not tuned on outcomes yet.
139
145
  mode: 'balanced',
140
146
  modes: {
141
147
  cost: {
@@ -144,7 +150,7 @@ export const DEFAULTS = {
144
150
  upgradeBase: 0.75,
145
151
  jumpConfidence: 0.98,
146
152
  downgradeVotes: 1,
147
- downgradeMass: 0.8,
153
+ downgradeMass: 0.65,
148
154
  minDwellRequests: 4,
149
155
  escalationHoldTurns: 1,
150
156
  },
package/lib/display.mjs CHANGED
@@ -345,6 +345,20 @@ export function recordedModels(config, view, summary) {
345
345
  // record kept them against.
346
346
  export const comparedModel = (config, view, summary) => recordedModels(config, view, summary) ?? yourModel(view);
347
347
 
348
+ // What the cost is compared with, the same word on the band, the pane and /router: the one model the main replies
349
+ // were priced against (the one `/model` selected when they ran), else `unrouted` (after a `/model` change, or with
350
+ // subagents, which are priced against Claude Code's pick).
351
+ export const UNROUTED = 'unrouted';
352
+ export function baselineName(view, summary, cost) {
353
+ const ids = Object.keys(summary.yours ?? {});
354
+ const id = ids.length ? ids[0] : view.nativeModel;
355
+ return cost.agents || ids.length > 1 || !id ? UNROUTED : modelName(id);
356
+ }
357
+ // Under EARLY_REPLIES main replies one model switch and its cache write can decide the difference: "9 replies so far".
358
+ export const repliesText = (cost) =>
359
+ `${replyCount(cost.replies)}${cost.early && cost.diffUsd !== null ? ' so far' : ''}`;
360
+ export const EARLY_NOTE = 'one model switch can still move this a lot';
361
+
348
362
  // Cache rebuilds cost more than the cheaper models saved: the switches lost money.
349
363
  export const switchesLost = (r) => r.switchUsd > 0 && r.switchUsd > -r.cheaperUsd;
350
364
 
@@ -365,12 +379,12 @@ export function savingsLine(config, view, usage, now) {
365
379
  const credits = cost.creditsUsd ? ` · billed ${usd(cost.creditsUsd)}` : '';
366
380
  const versus =
367
381
  cost.diffUsd !== null
368
- ? ` · ${diffText(cost.diffUsd, cost.baseUsd)} vs no routing${cost.early ? ', early sample' : ''}`
382
+ ? ` · ${diffText(cost.diffUsd, cost.baseUsd)} vs ${baselineName(view, sessionUsage(view, now), cost)} ${costText(cost.baseUsd, cost.billing)}`
369
383
  : cost.effortOnly
370
384
  ? ` · effort ${cost.effortMix.map(([effort, n]) => `${effort} ${n}`).join(' · ')}`
371
385
  : ` · ${uncomparedText(cost)}`;
372
386
  lines.push(
373
- `Session: ${costText(cost.totalUsd, cost.billing)} ${BILLING_WORDS[cost.billing]}${split}${credits}${versus} · ${replyCount(cost.replies)}`,
387
+ `Session: ${costText(cost.totalUsd, cost.billing)} ${BILLING_WORDS[cost.billing]}${split}${credits}${versus} · ${repliesText(cost)}`,
374
388
  );
375
389
  return lines.join('\n');
376
390
  }
package/lib/modes.mjs CHANGED
@@ -15,18 +15,19 @@ function steppedEffort(config, route, step) {
15
15
  return choices.find((effort) => supported.includes(effort)) ?? null;
16
16
  }
17
17
 
18
- // The route `mode` runs for tier and activity, always from the configured routes. `cost` takes the tier below (never
19
- // below `low`) when it runs a model with a lower input price, else one effort level less; `quality` one effort level
20
- // more, else the tier above. One lever per decision: cost pays mostly for input and cache tokens, which effort does
21
- // not lower, and quality keeps the model and its cache. `micro` and `balanced` keep the configured route.
18
+ // The route `mode` runs for tier and activity, always from the configured routes. `cost` takes a model with a lower
19
+ // input price where one is below: the tier below, or at `low` the tier's route without its activity override (never
20
+ // `micro`); else one effort level less. `high` keeps its model, so a turn that clears the upgrade bar runs on the
21
+ // strongest one. `quality` one effort level more, else the tier above. One lever per decision; quality keeps the
22
+ // model and its cache. `micro` and `balanced` keep the configured route.
22
23
  export function modeRoute(config, mode, tier, activity = null) {
23
24
  const routeAt = (t) => resolveRoute(config, t, activity);
24
25
  const route = routeAt(tier);
25
26
  if (mode === 'balanced' || tier === 'micro') return route;
26
27
  if (mode === 'cost') {
27
- const below = routeAt(TIERS[Math.max(rank('low'), rank(tier) - 1)]);
28
- if (below.model !== route.model && config.models[below.model].input < config.models[route.model].input)
29
- return below;
28
+ const below = tier === 'low' ? resolveRoute(config, 'low') : routeAt(TIERS[rank(tier) - 1]);
29
+ const cheaper = config.models[below.model].input < config.models[route.model].input;
30
+ if (tier !== 'high' && below.model !== route.model && cheaper) return below;
30
31
  const effort = steppedEffort(config, route, -1);
31
32
  return effort ? { model: route.model, effort } : route;
32
33
  }
package/lib/panel.mjs CHANGED
@@ -18,11 +18,13 @@ import { effortSharesCache, routeEffort } from './cost.mjs';
18
18
  import { periodCost, resetText } from './costs.mjs';
19
19
  import {
20
20
  activityReading,
21
+ baselineName,
21
22
  classifierLabel,
22
23
  classifierStatus,
23
24
  comparedModel,
24
25
  costText,
25
26
  diffText,
27
+ EARLY_NOTE,
26
28
  formatTokens,
27
29
  GATEWAY_CLEANUP,
28
30
  GATEWAY_SETTINGS,
@@ -39,6 +41,7 @@ import {
39
41
  probeOf,
40
42
  reasonActivity,
41
43
  recordedModels,
44
+ repliesText,
42
45
  routeLabel,
43
46
  routeName,
44
47
  routingModeOf,
@@ -54,6 +57,7 @@ import {
54
57
  switchesLost,
55
58
  TIER_COLOR,
56
59
  tierBars,
60
+ UNROUTED,
57
61
  unavailableReason,
58
62
  uncomparedText,
59
63
  unpricedLine,
@@ -474,16 +478,13 @@ function sessionLines(ui, config, view, cost, actions, columns, now) {
474
478
  );
475
479
  if (cost.diffUsd !== null) {
476
480
  const diff = diffText(cost.diffUsd, cost.baseUsd);
477
- const of = ` of ${costText(cost.baseUsd, cost.billing)}${cost.early ? ' · early sample' : ''}`;
478
- const fits = !Number.isFinite(columns) || 2 + diff.length + ' vs no routing'.length + of.length <= columns;
481
+ const versus = ` vs ${baselineName(view, sessionUsage(view, now), cost)}`;
482
+ const of = ` ${costText(cost.baseUsd, cost.billing)}`;
483
+ const fits = !Number.isFinite(columns) || 2 + diff.length + versus.length + of.length <= columns;
479
484
  out.push(
480
- ui.line(
481
- ' ',
482
- ui.text(diff, { bold: true, color: savingsColor(cost.diffUsd) }),
483
- ' vs no routing',
484
- fits ? ui.dim(of) : null,
485
- ),
485
+ ui.line(' ', ui.text(diff, { bold: true, color: savingsColor(cost.diffUsd) }), versus, fits ? ui.dim(of) : null),
486
486
  );
487
+ if (cost.early) out.push(ui.dim(` ${repliesText(cost)}: ${EARLY_NOTE}`));
487
488
  } else if (cost.effortOnly) out.push(ui.dim(' effort routing on one model: no saving is estimated'));
488
489
  else if (cost.uncomparedReplies) out.push(ui.dim(` ${uncomparedText(cost)}: no saving shown`));
489
490
  out.push(...costBars(ui, config, view, cost, now));
@@ -1797,7 +1798,7 @@ function breakdownLines(ui, view, actions, summary, columns, compare, billing) {
1797
1798
  const tailHead = by === 'model' ? 'share' : 'mostly on';
1798
1799
  out.push(
1799
1800
  ui.dim(
1800
- ` ${''.padEnd(NAME)}${'replies'.padStart(8)}${'cost'.padStart(10)}${compare ? 'vs no routing'.padStart(15) : ''}${tail ? ` ${tailHead}` : ''}`,
1801
+ ` ${''.padEnd(NAME)}${'replies'.padStart(8)}${'cost'.padStart(10)}${compare ? `vs ${UNROUTED}`.padStart(15) : ''}${tail ? ` ${tailHead}` : ''}`,
1801
1802
  ),
1802
1803
  );
1803
1804
  const numbers = (sums, unavailable) => [
@@ -2055,8 +2056,8 @@ function costHeadline(ui, cost) {
2055
2056
  if (cost.diffUsd !== null)
2056
2057
  return ui.line(
2057
2058
  ui.text(diffText(cost.diffUsd, cost.baseUsd), { bold: true, color: savingsColor(cost.diffUsd) }),
2058
- ' vs no routing',
2059
- cost.early ? ui.text(` early sample · ${plural(cost.replies, 'reply', 'replies')}`, { color: 'yellow' }) : null,
2059
+ ` vs ${UNROUTED}`,
2060
+ cost.early ? ui.text(` ${repliesText(cost)}: ${EARLY_NOTE}`, { color: 'yellow' }) : null,
2060
2061
  );
2061
2062
  return ui.dim(
2062
2063
  cost.effortOnly
@@ -2108,8 +2109,8 @@ function costTable(ui, config, view, period, cost, legacy, actions, columns) {
2108
2109
  ui.line(
2109
2110
  ui.cell(COST_LABEL, ''),
2110
2111
  ui.dim('cost'.padStart(COST_AMOUNT)),
2111
- compared ? ui.dim('vs no routing'.padStart(COST_DIFF)) : null,
2112
- compared ? ui.dim('no routing'.padStart(COST_BASE)) : null,
2112
+ compared ? ui.dim(`vs ${UNROUTED}`.padStart(COST_DIFF)) : null,
2113
+ compared ? ui.dim(UNROUTED.padStart(COST_BASE)) : null,
2113
2114
  ),
2114
2115
  row(
2115
2116
  `main · ${plural(cost.replies, 'reply', 'replies')}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexeiled/claude-router",
3
- "version": "1.21.0",
3
+ "version": "1.21.1",
4
4
  "description": "Native Claude Code model and effort routing with Anthropic, DeepSeek, z.ai, MiniMax, MiMo and Kimi defaults, custom provider profiles, and classifier advice.",
5
5
  "license": "MIT",
6
6
  "author": "Alexei Ledenev",