@alexeiled/claude-router 1.7.2 → 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.2",
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,11 @@
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
+
3
9
  ## 1.7.2 (2026-10-10)
4
10
 
5
11
  ### Fixed
@@ -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, {
@@ -532,6 +537,7 @@ async function decideTurn($, router, e, signal, step) {
532
537
  pinned: selected.decision.pinned,
533
538
  route: `${selected.decision.model}@${selected.decision.effort ?? 'session'}`,
534
539
  classifier: cfg.classifier,
540
+ offSwitches: router.offSwitches,
535
541
  adviceMs,
536
542
  sessionId,
537
543
  requests: 0,
@@ -697,13 +703,16 @@ async function recordActivity($, router, turn) {
697
703
  if (start < 0) return;
698
704
  const observed = observedActivity(messages, start);
699
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;
700
709
  // The session may have changed during the reads; this turn is not the new session's.
701
710
  if ((await $.session.id()) !== turn.sessionId) return;
702
711
  // Advanced before any further await, so a session change meanwhile cannot carry this run into the new session.
703
712
  const { run, ended } = advanceRun(router.run, turn.answer);
704
713
  router.run = run;
705
714
  const down = advanceDown(router.afterDown, turn);
706
- router.afterDown = down.after;
715
+ router.afterDown = off ? null : down.after;
707
716
  await updateView($, router, {
708
717
  activityStats: recordTurn(view.activityStats ?? emptySession(), {
709
718
  activity: turn.label,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexeiled/claude-router",
3
- "version": "1.7.2",
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",