@alexeiled/claude-router 1.7.1 → 1.7.3

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.7.1",
4
+ "version": "1.7.3",
5
5
  "description": "Model and effort routing for the main conversation by task difficulty and activity, advised by a prompt classifier (Jev, Clef, Clef Flash, OpenAI or local Ollama). Preserves subagent model choices.",
6
6
  "author": {
7
7
  "name": "Alexei Ledenev",
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.3 (2026-10-10)
4
+
5
+ ### Fixed
6
+
7
+ - Turning routing off while a turn runs ends the watch behind **Escalations**, even when routing is back on by the time the turn finishes. Before, that turn could start the watch again for its cheaper activity move, and a later escalation counted against it. Routing itself is unchanged.
8
+
9
+ ## 1.7.2 (2026-10-10)
10
+
11
+ ### Fixed
12
+
13
+ - A Manual turn ends the watch behind **Escalations** (ACROSS SESSIONS). A turn that moved to a cheaper activity route and finished after routing was turned off mid-turn could count a later escalation against that move.
14
+
15
+ ### Added
16
+
17
+ - More live evidence in `experiments/mod-router/results/activity-live-acceptance.json`: the Sonnet → Haiku → Sonnet → Opus chain with tool calls, Sonnet and Opus thinking blocks after a Haiku detour, and the `shadow` would-route line, with no API errors.
18
+
3
19
  ## 1.7.1 (2026-10-10)
4
20
 
5
21
  Readouts the activity routing plan asked for, and a record of the live checks behind 1.7.0.
@@ -56,7 +56,7 @@ The script writes aggregate counts, reason histograms, route transitions, and sh
56
56
 
57
57
  Activity routing has no measured result. The replay above predates it and covers tiers only. It is `on` by default since 1.7, with defaults chosen from Anthropic's published benchmarks and a list-price replay of one developer's sessions; [Activity routing](activity-routing.md#what-the-estimates-mean) gives that replay and its limits. The pane counts turns, requests, switches, and the turns `on` would route differently, with a configured list-price estimate of those turns' next requests, not a measured saving. Two checks look at the classifier's activity label.
58
58
 
59
- The figures plan §11 tracks (tool agreement of at least 80% on `code` against `ops` and `explore`, Jev p95 latency of at most 450 ms, at most 1 tool-error escalation in 10 cheaper activity moves, a negative would-route estimate in `shadow`, the number of activity switches) are read from the Usage tab's **ACROSS SESSIONS** block, which shows the counts kept since the last reset: **Code/ops/explore** for the tool agreement on turns the classifier answered `code`, `ops` or `explore`, **Agreement** and **Mismatch** for all of them, **Activity moves** for moves inside a tier taken and refused (a refusal by a hold or the credits cap included), **Escalations** for the tool-error escalations that followed a cheaper activity move in `on` while the turns stayed on its route in `on` (turning routing off or a turn in `shadow` or `off` ends the watch, a pin in between does not, and an escalation the credits cap held counts), **Latency** for the active classifier's p95 wait, **Shadow** for the would-route count and estimate. Latency is kept in fixed buckets, so the p95 reads as a bound (`≤ 350 ms`); it is the wait for the classifier's answer, transient retries included, without the routing after it, so it compares with the probe's p95 below, and is not recorded with activity routing `off`. `/router` without a UI surface prints both agreements. The underlying counts are the `activity:stats:v1` store and the per-session `activity:metrics:v1:<session id>` records described in [Architecture](architecture.md).
59
+ The figures plan §11 tracks (tool agreement of at least 80% on `code` against `ops` and `explore`, Jev p95 latency of at most 450 ms, at most 1 tool-error escalation in 10 cheaper activity moves, a negative would-route estimate in `shadow`, the number of activity switches) are read from the Usage tab's **ACROSS SESSIONS** block, which shows the counts kept since the last reset: **Code/ops/explore** for the tool agreement on turns the classifier answered `code`, `ops` or `explore`, **Agreement** and **Mismatch** for all of them, **Activity moves** for moves inside a tier taken and refused (a refusal by a hold or the credits cap included), **Escalations** for the tool-error escalations that followed a cheaper activity move in `on` while the turns stayed on its route in `on` (turning routing off, a turn with routing off, or a turn in `shadow` or `off` ends the watch, a pin in between does not, and an escalation the credits cap held counts), **Latency** for the active classifier's p95 wait, **Shadow** for the would-route count and estimate. Latency is kept in fixed buckets, so the p95 reads as a bound (`≤ 350 ms`); it is the wait for the classifier's answer, transient retries included, without the routing after it, so it compares with the probe's p95 below, and is not recorded with activity routing `off`. `/router` without a UI surface prints both agreements. The underlying counts are the `activity:stats:v1` store and the per-session `activity:metrics:v1:<session id>` records described in [Architecture](architecture.md).
60
60
 
61
61
  ### Tool agreement
62
62
 
@@ -168,7 +168,7 @@ The band's activity label appears only when the activity applies, so a weak or `
168
168
  - **Routing**: **ACTIVITIES** starts with the **Activity routing** selector (`off`, `shadow`, `on`) and what the mode does. The matrix under it shows the effective routes per tier, with `·` where a cell uses the base route, and counts the distinct routes, because the router counts each as its own cache. Routes are abbreviated, such as `S·high` for Sonnet · high, and activities with the same cells share a row. **OVERRIDES** says whether the overrides are in use, then lists each override with a model, an effort, and **remove**, plus a selector to add one. **Activity threshold** under **POLICY** is the least probability at which an activity applies. Edits join the routing draft: **Save** and **Discard** apply as for routes. Yellow notes flag an override with no effect (`same as base`), one stronger than the tier above, and the only cell or tier on its (model, effort) pair, which adds a cache.
169
169
  - **Usage**: **ACTIVITY · this session** lists turns, requests, and share per activity, then `est. cost`, the list price of that activity's replies (the same per-reply estimate as Routing vs your model, but only for turns recorded with activity routing `shadow` or `on`, so the rows need not add up to its routed total; `—` when a reply had no price), and `mostly on`, the route most of its replies used, such as `Sonnet 5.5 · high`. A narrow pane drops `mostly on`, then `est. cost`. Below the table are the switches split by tier and by activity, with `· 2 refused` when activity moves were refused in `on` (not worth the cache write, a hold after an escalation, or the credits cap), and **Agreement**, how often the tools a turn used fit the classifier's activity (see [Evaluation](evaluation.md#tool-agreement)). In `shadow` the **Shadow** line counts how many turns `on` would have routed differently, such as `on would route 5 of 20 turns differently · est. −$0.300 … −$0.120 at list prices`. The estimate sums, over those turns, what the next request on the route `on` would use would cost against the route that ran, as a low and a high scenario at the configured list prices in `router.json`. Minus means cheaper. It covers only turns after a measured reply, and adds `for 3` when only three of the turns have one. It is not a measured saving.
170
170
 
171
- **ACROSS SESSIONS · since the last reset** shows the counts kept across sessions: 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 or a turn in `shadow` or `off` ends the watch, a pin in between does not, and an escalation the credits cap held counts), **Latency**, the active classifier's p95 wait as a bucket bound such as `Jev p95 ≤ 350 ms · 20 turns` (not recorded with activity routing `off`), and the **Shadow** line summed over all shadow turns. Each of these lines appears only when it has data. 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. **Reset stats** clears the activity counts and routing vs your model, for this session and across sessions.
171
+ **ACROSS SESSIONS · since the last reset** shows the counts kept across sessions: 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 `shadow` or `off` ends the watch, a pin in between does not, and an escalation the credits cap held counts), **Latency**, the active classifier's p95 wait as a bucket bound such as `Jev p95 ≤ 350 ms · 20 turns` (not recorded with activity routing `off`), and the **Shadow** line summed over all shadow turns. Each of these lines appears only when it has data. 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. **Reset stats** clears the activity counts and routing vs your model, for this session and across sessions.
172
172
 
173
173
  `/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 against your model, such as `vs your model (Opus 5.5 · xhigh): −$1.84 (−22%) this session, 64 replies, est. at list prices`.
174
174
 
@@ -112,6 +112,8 @@ function createRouter(options) {
112
112
  run: null,
113
113
  // The route a cheaper activity move went to, while the turns stay on it (advanceDown); else null.
114
114
  afterDown: null,
115
+ // Counts every switch to routing off; a turn compares it with its own start to see routing went off meanwhile.
116
+ offSwitches: 0,
115
117
  // Each turn's routing-vs-your-model totals until turn.complete adds them to the store.
116
118
  turnSavings: new Map(),
117
119
  // The totals kept across sessions: this session's record (`{ sessionId, record }`), held here so a refresh never
@@ -259,7 +261,10 @@ async function changeMode($, router, mode) {
259
261
  const view = router.view ?? (await readView($, router));
260
262
  for (const controller of router.controllers) controller.abort();
261
263
  // Turns with routing off run on Claude's model, off the cheaper move's route: the escalation watch ends.
262
- if (mode === 'manual') router.afterDown = null;
264
+ if (mode === 'manual') {
265
+ router.afterDown = null;
266
+ router.offSwitches += 1;
267
+ }
263
268
  router.modes.set(await $.session.id(), mode);
264
269
  const saved = await rememberMode($, mode);
265
270
  await updateView($, router, {
@@ -428,6 +433,9 @@ async function contextOf($, loop) {
428
433
  }
429
434
 
430
435
  async function* passMain($, e, next, loop, version, nativeModel, reason, router) {
436
+ // A turn routing did not choose is a turn on another route: it ends the watch for escalations after a cheaper
437
+ // activity move, including one a turn started before routing was turned off mid-turn.
438
+ if (reason === 'manual') router.afterDown = null;
431
439
  const ref = { ...LOOP, id: 'main' };
432
440
  const context = await contextOf($, loop);
433
441
  await updateView($, router, {
@@ -529,6 +537,7 @@ async function decideTurn($, router, e, signal, step) {
529
537
  pinned: selected.decision.pinned,
530
538
  route: `${selected.decision.model}@${selected.decision.effort ?? 'session'}`,
531
539
  classifier: cfg.classifier,
540
+ offSwitches: router.offSwitches,
532
541
  adviceMs,
533
542
  sessionId,
534
543
  requests: 0,
@@ -694,13 +703,16 @@ async function recordActivity($, router, turn) {
694
703
  if (start < 0) return;
695
704
  const observed = observedActivity(messages, start);
696
705
  const view = router.view ?? (await readView($, router));
706
+ // Routing turned off while this turn ran ends the watch here, even when it is back on by now, so the move is not
707
+ // inherited.
708
+ const off = (await modeOf($, router)) === 'manual' || turn.offSwitches !== router.offSwitches;
697
709
  // The session may have changed during the reads; this turn is not the new session's.
698
710
  if ((await $.session.id()) !== turn.sessionId) return;
699
711
  // Advanced before any further await, so a session change meanwhile cannot carry this run into the new session.
700
712
  const { run, ended } = advanceRun(router.run, turn.answer);
701
713
  router.run = run;
702
714
  const down = advanceDown(router.afterDown, turn);
703
- router.afterDown = down.after;
715
+ router.afterDown = off ? null : down.after;
704
716
  await updateView($, router, {
705
717
  activityStats: recordTurn(view.activityStats ?? emptySession(), {
706
718
  activity: turn.label,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexeiled/claude-router",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "description": "Native Claude Code Mod: model and effort routing for the main conversation, advised by Jev, Clef, Clef Flash, OpenAI or Ollama.",
5
5
  "license": "MIT",
6
6
  "author": "Alexei Ledenev",