@alexeiled/claude-router 1.10.0 → 1.10.2

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.
@@ -32,7 +32,7 @@ Keys are stored as sensitive plugin options. Do not paste them into a model conv
32
32
 
33
33
  Router draws one line above the prompt. The line ends with a **Router** button that opens the pane. When the band is narrow, the less important parts drop first: classifier figures, then context and cache, then the activity, then the reason. The tier and model always stay, except behind a classifier warning: the warning and its **Set up** button come first, and the route gives way to them.
34
34
 
35
- ![Seven band states: routed to high, two rows with the hover row, a pending pin, a missing classifier key, routing off, an activity move with activity routing on, and an activity label in shadow](router-band.svg)
35
+ ![Six band states: routed to high, two rows with the hover row, a pending pin, a missing classifier key, routing off, and an activity move with activity routing on](router-band.svg)
36
36
 
37
37
  Read the first line of the picture from left to right:
38
38
 
@@ -77,7 +77,7 @@ The top line of every tab, `ROUTING [ ◉ on ] [ ○ off ] Jev ready · 347 ms`
77
77
 
78
78
  ![The Now tab: what runs next turn with its tier, model and activity, the reason with the classifier support it weighed and the switch cost, classifier support per tier with pin buttons, the last replies as a strip with the switch count and the replies per tier and per activity, and context, cache and cost](router-pane-now.svg)
79
79
 
80
- The **Now** tab answers "what runs next turn, and why". **Next turn** names the tier, the model and effort, and, when an activity override runs, the tier's own model beside it. **Activity** names the classifier's activity as a verb, such as `coding 84%`, with the two next answers and the threshold at which an activity applies. **Why** gives the reason; under it, `Jev gave stronger tiers 88% (needs 82%) · switch ≈ $0.48` compares the classifier's support for the switch with the bar the policy set, and gives the estimated switch cost. The ladder lists the tiers from strongest to cheapest with the route each one uses and the support the classifier gave it on the last turn. **pin** forces that tier for the next turn only. In `shadow`, a **Shadow** line says what `on` would run; see [Route by activity](#route-by-activity).
80
+ The **Now** tab answers "what runs next turn, and why". **Next turn** names the tier, the model and effort, and, when an activity override runs, the tier's own model beside it. **Activity** names the classifier's activity as a verb, such as `coding 84%`, with the two next answers and the threshold at which an activity applies. **Why** gives the reason; under it, `Jev gave stronger tiers 88% (needs 82%) · switch ≈ $0.48` compares the classifier's support for the switch with the bar the policy set, and gives the estimated switch cost. The ladder lists the tiers from strongest to cheapest with the route each one uses and the support the classifier gave it on the last turn. **pin** forces that tier for the next turn only.
81
81
 
82
82
  ### Save and undo changes
83
83
 
@@ -103,7 +103,7 @@ The Usage tab opens with the answer, such as `Routing saved $1.84 (22%) this ses
103
103
  | stronger than yours | The part from replies on stronger models, with how many replies ran on them. |
104
104
  | cache writes from switches | The part from rewriting the prompt cache after model switches. |
105
105
 
106
- The three parts add up to the difference. Two bars compare the costs, the routed one colored by the tier that spent it, and a line gives the share of replies per tier. In activity-routing `shadow`, one more line estimates what `on` would change in this session. The columns are this session and every session since the last reset; the saved column compares each reply with the model `/model` selected when it ran, so it can add up several models. A column reads `too early` until it has 10 routed replies. With routing off or unavailable and no routed reply this session, the section says every reply used your model. In a narrow pane the bars go first, then the saved column.
106
+ The three parts add up to the difference. Two bars compare the costs, the routed one colored by the tier that spent it, and a line gives the share of replies per tier. The columns are this session and every session since the last reset; the saved column compares each reply with the model `/model` selected when it ran, so it can add up several models. A column reads `too early` until it has 10 routed replies. With routing off or unavailable and no routed reply this session, the section says every reply used your model. In a narrow pane the bars go first, then the saved column.
107
107
 
108
108
  These are estimates, not a bill. They hold the tokens and the output length the same, although another model may write more or less, and they do not measure answer quality. On a Claude plan the dollars stand for quota. Your model's cache reads the previous prompt inside the cache lifetime Claude Code uses, one hour on a Claude plan, and never less than the API actually read. A route that changes only the effort, such as Opus at `xhigh` to Opus at `medium`, costs no less per token: it shows only its cache writes. [Evaluation](evaluation.md#routing-vs-your-model) explains the method.
109
109
 
@@ -144,12 +144,11 @@ The mode decides what happens with the label:
144
144
  | Mode | What the router does |
145
145
  | -------- | ---------------------------------------------------------------------------------------------------- |
146
146
  | `on` | The default. Applies the activity overrides. |
147
- | `shadow` | Shows the activity, records the stats, and works out what `on` would run. The base route still runs. |
148
147
  | `off` | Does not ask the activity: the classifier is asked for the tier only. The base routes run. |
149
148
 
150
- To turn activity routing off or back to `shadow`, run `/router activities off` or `/router activities shadow`, or set **Activity routing** at the top of the Routes tab and press **Save**. Routing itself stays on: only the activity overrides stop. Upgrading from 1.6, where `shadow` was the default, a `router.json` without `activityRouting` now runs `on`. Choosing `shadow` in 1.6 removed the key, because `shadow` was the default then: if you chose `shadow` in 1.6, run `/router activities shadow` again after upgrading.
149
+ To turn activity routing off, run `/router activities off`, or set **Activity routing** at the top of the Routes tab and press **Save**. Routing itself stays on: only the activity overrides stop. Upgrading from 1.6, which asked the activity but ran the base routes, run `/router activities off` to keep 1.6's routes. A `router.json` that still sets `"shadow"`, for activity or subagent routing, is read as not setting it, so the default, `on`, runs.
151
150
 
152
- In `shadow` you can see what `on` would do without it running. The band marks the label `(shadow)` and dims it, and the **Now** tab's **Shadow** line says `low + code would use Sonnet 5.5 · high (shadow; using Haiku 5.5 · high)`, or `same route` when both agree. In `on`, when an override runs, the **Next turn** line adds the tier's own model: `override · low runs Haiku 5.5 · high`.
151
+ When an override runs, the **Next turn** line adds the tier's own model: `override · low runs Haiku 5.5 · high`.
153
152
 
154
153
  How the router moves inside a tier:
155
154
 
@@ -157,8 +156,8 @@ How the router moves inside a tier:
157
156
  - A move to a stronger route needs the classifier's support, as an upgrade between tiers does. A move to a cheaper one must pay back its cache write within the payback horizon. One vote is enough for either, because the activity is a fact about this turn.
158
157
  - An activity applies only when the classifier gives it at least 60% probability (`policy.activityMass`). Below that, or on `uncertain`, a new task goes back to its base route if the move passes the same checks; a continuation of the running task keeps its activity, or moves to the classifier's activity when that route is stronger. Tool continuations inside a turn keep the turn's route. When the classifier sees a new prompt as a continuation of the task, the activity may only move to a stronger route: `explore` can become `code`, but not the other way. Ollama does not answer the continuation question, so this rule does not apply to it.
159
158
  - A pinned turn uses the pin's base route and shows no activity.
160
- - When the classifier gives no answer at all (a timeout, a failure, a pause, or a missing key), the running route stays. When it answers the tier but gives no usable activity, only the running activity stays: the tier answer still applies, so the turn can change tier and keeps its activity there. In `shadow` and `off` the base route always runs.
161
- - A fresh session starts with routing on when the session model is a tier's route. With activity routing `on`, a model that only an activity override uses also counts: Sonnet 5.5 on the defaults. In `off` and `shadow` it does not.
159
+ - When the classifier gives no answer at all (a timeout, a failure, a pause, or a missing key), the running route stays. When it answers the tier but gives no usable activity, only the running activity stays: the tier answer still applies, so the turn can change tier and keeps its activity there. In `off` the base route always runs.
160
+ - A fresh session starts with routing on when the session model is a tier's route. With activity routing `on`, a model that only an activity override uses also counts: Sonnet 5.5 on the defaults. In `off` it does not.
162
161
 
163
162
  The band's activity label appears only when the activity applies, so a weak or `uncertain` answer shows none. The two-row band and the **Replies** strip show the activities of recent replies.
164
163
 
@@ -166,9 +165,9 @@ The band's activity label appears only when the activity applies, so a weak or `
166
165
 
167
166
  - **Now**: the **Activity** line names the classifier's choice as a verb with its share, the two next-best answers, and the threshold at which an activity applies, such as `coding 84% debugging 8% · planning 5% applies at 60%+`. An `uncertain` answer is shown dim: it applies no activity. In `on`, **Why** names the cell when the activity moved the route or the route is an override, such as `coding at low runs on Sonnet 5.5 · high`, or `low runs on its base route, Haiku 5.5 · high` for a move without an activity; a refused move, a hold, or a tier change keeps its reason. **Last replies** counts the replies per activity under the strip.
168
167
  - **Routes**: see [Edit routes and policy](#edit-routes-and-policy). Each activity is a row of the grid, and a cell shows the model the activity runs at that tier.
169
- - **Usage**: **BY 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.
168
+ - **Usage**: **BY 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 `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)).
170
169
 
171
- 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 `shadow` or `off` ends the watch, a pin in between does not, and an escalation the credits cap held counts), and the **Shadow** line summed over all shadow turns. 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. **Reset stats** on the Usage tab clears the activity counts and routing vs your model, for this session and across sessions.
170
+ 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. **Reset stats** on the Usage tab clears the activity counts and routing vs your model, for this session and across sessions.
172
171
 
173
172
  `/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
173
 
@@ -180,7 +179,7 @@ On the **Classifier** tab, **ACROSS SESSIONS · since the last reset** shows the
180
179
  | `/router auto` | Resume automatic routing. |
181
180
  | `/router off` | Turn routing off and keep Claude's selected model. |
182
181
  | `/router pin <micro\|low\|medium\|high>` | Pin the next turn and its tool continuations. Routing on must already be enabled. |
183
- | `/router activities <off\|shadow\|on>` | Set the [activity routing](#route-by-activity) mode. Saved to `router.json` at once; **Undo** reverts it. |
182
+ | `/router activities <off\|on>` | Set the [activity routing](#route-by-activity) mode. Saved to `router.json` at once; **Undo** reverts it. |
184
183
  | `/model <name>` | Select a model and turn routing off. Use `/router auto` to turn it back on. |
185
184
  | **Turn on** / **Turn off** on the band | The same as `/router auto` and `/router off`. |
186
185
  | **on** / **off** on the pane (`o` / `f`) | The same as `/router auto` and `/router off`. |
@@ -201,7 +200,7 @@ Select a cell, with the pointer or Tab and Enter, to edit it under the grid:
201
200
 
202
201
  The model list comes from the aliases in `router.json` `models`, limited by the `availableModels` setting. `inherit` keeps the effort Claude Code sends. A model without effort levels, such as a custom one with `"efforts": []`, shows `none`.
203
202
 
204
- **Activity routing** at the top sets `off`, `shadow`, or `on`, and says what the mode does. A yellow line says when the overrides do not run: activity routing `shadow` or `off`, or routing off or unavailable.
203
+ **Activity routing** at the top sets `off` or `on`, and says what the mode does. A yellow line says when the overrides do not run: activity routing `off`, or routing off or unavailable.
205
204
 
206
205
  Under the grid, `3 prompt caches in use` counts the caches the grid can run on. Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.1 keep one cache per model across efforts with an API key or a Claude subscription; on Amazon Bedrock, Google Cloud, Microsoft Foundry or a custom `ANTHROPIC_BASE_URL`, each (model, effort) pair has its own. Moving to a model without a warm cache writes the whole conversation into a new cache, which is the switch cost on the Now tab. More caches mean more of those writes. A yellow line flags two neighbouring tiers that run the same model and effort, since that step changes nothing.
207
206
 
@@ -247,7 +246,7 @@ Under the rows, a block for the active classifier:
247
246
  - **Sends** names the service that receives prompt text. **Health** shows a pause, recent failures, and the last wait.
248
247
  - **Credentials**: **Edit** opens Claude Code's secure plugin configuration, where you enter them.
249
248
 
250
- With `shadow` or `on`, the activity question goes in the same request as the tier question (Ollama makes a second call), with the same text and nothing more. **Sends** names the service that receives the prompt and recent dialogue. With Clef or Clef Flash that is Cloudflare, not typesafe.ai; with OpenAI it is OpenAI; with Ollama it stays on this machine. Give the Cloudflare token Workers AI permissions only.
249
+ With activity routing `on`, the activity question goes in the same request as the tier question (Ollama makes a second call), with the same text and nothing more. **Sends** names the service that receives the prompt and recent dialogue. With Clef or Clef Flash that is Cloudflare, not typesafe.ai; with OpenAI it is OpenAI; with Ollama it stays on this machine. Give the Cloudflare token Workers AI permissions only.
251
250
 
252
251
  The routing policy thresholds were tuned against Jev's probabilities. Clef's, OpenAI's, and Ollama's probabilities have not been compared with Jev's, so the same prompt can switch tiers at a different point. Watch **Classifier support** for a few sessions before you rely on a new classifier.
253
252
 
@@ -276,7 +275,7 @@ Keep the plugin enabled: in v1 it is the Mod. The Jev key option keeps its saved
276
275
 
277
276
  Claude Code updates a marketplace install at startup when auto-update is on for the marketplace. To update now, run `claude plugin marketplace update alexei-led-claude-router`, then `claude plugin update router@alexei-led-claude-router`, and restart. For a local checkout, update the files and restart Claude Code with the same `--plugin-dir`.
278
277
 
279
- To stop routing for a session, run `/router off`. To keep tier routing but stop the activity overrides, run `/router activities off`, or `/router activities shadow` to keep seeing what they would do. To stop loading the Mod, run `claude plugin disable router@alexei-led-claude-router`, or restart without `--plugin-dir` for a checkout. The Mod keeps no session ledger and starts no process.
278
+ To stop routing for a session, run `/router off`. To keep tier routing but stop the activity overrides, run `/router activities off`. To stop loading the Mod, run `claude plugin disable router@alexei-led-claude-router`, or restart without `--plugin-dir` for a checkout. The Mod keeps no session ledger and starts no process.
280
279
 
281
280
  ## Troubleshooting
282
281
 
@@ -651,7 +651,6 @@ async function decideTurn($, router, e, signal, step) {
651
651
  estimate: selected.decision.estimate ?? null,
652
652
  activityChoice: activity.predicted,
653
653
  activityProbabilities: result.advice?.activity?.probabilities ?? null,
654
- wouldRoute: selected.decision.wouldRoute ?? null,
655
654
  }
656
655
  : {}),
657
656
  });
@@ -813,9 +812,6 @@ async function recordActivity($, router, turn) {
813
812
  tierSwitches: turn.switched === 'tier' ? 1 : 0,
814
813
  activitySwitches: turn.switched === 'activity' ? 1 : 0,
815
814
  lateral: turn.lateral,
816
- wouldDiffer: turn.wouldDiffer,
817
- wouldUsd: turn.wouldUsd,
818
- shadow: turn.mode === 'shadow',
819
815
  }),
820
816
  });
821
817
  const resets = router.statsResets;
@@ -831,8 +827,6 @@ async function recordActivity($, router, turn) {
831
827
  observed,
832
828
  runEnded: ended,
833
829
  lateral: turn.lateral,
834
- wouldDiffer: turn.wouldDiffer,
835
- wouldUsd: turn.wouldUsd,
836
830
  });
837
831
  const measured = recordMetrics(own.record, {
838
832
  classifier: turn.classifier,
@@ -858,7 +852,7 @@ async function recordActivity($, router, turn) {
858
852
  async function flushRun($, run) {
859
853
  try {
860
854
  const store = readStore(await $.store.get(STORE_KEY));
861
- const ended = { predicted: null, observed: null, runEnded: run, lateral: null, wouldDiffer: null, wouldUsd: null };
855
+ const ended = { predicted: null, observed: null, runEnded: run, lateral: null };
862
856
  await $.store.set(STORE_KEY, recordStore(store, ended));
863
857
  } catch {}
864
858
  }
@@ -946,41 +940,28 @@ async function decideSpawn($, router, cfg, e, definition, signal) {
946
940
  }
947
941
 
948
942
  // One model per subagent, chosen before its cache exists. `on` waits for the decision and sends its model, which
949
- // Claude Code uses in place of the Agent call's `model` and the agent's frontmatter. `shadow` spawns as Claude Code
950
- // would at once and records the decision once it is in, so it never delays an agent's start. Routing off or
951
- // unavailable keeps every model Claude Code chooses, and records nothing.
943
+ // Claude Code uses in place of the Agent call's `model` and the agent's frontmatter. Routing off or unavailable keeps
944
+ // every model Claude Code chooses, and records nothing.
952
945
  async function spawnAgent($, router, e, next) {
953
946
  const cfg = router.config;
954
- const mode = cfg.subagentRouting;
955
- if (mode === 'off') return next(e);
947
+ if (cfg.subagentRouting === 'off') return next(e);
956
948
  const view = router.view ?? (await readView($, router));
957
949
  if (view.phase === 'unavailable' || (await modeOf($, router, view.mode)) === 'manual') return next(e);
958
950
  const definition = await agentDefinition($, router, e);
959
951
  const pass = passReason(cfg, e, definition);
960
- const deciding = pass ? null : decideSpawn($, router, cfg, e, definition, next.signal).catch(() => null);
961
- const decided = mode === 'on' ? await deciding : null;
962
- const routed = Boolean(decided?.model);
963
- const result = await next(routed ? { ...e, model: decided.model } : e);
964
- if (!result.agentId) return result;
965
- // In shadow the agent may reply, and even finish, before the decision lands: a pending entry keeps its replies.
966
- if (mode !== 'on' && deciding !== null)
967
- router.agents.set(result.agentId, { pending: true, usages: [], finished: false });
968
- try {
969
- const decision = mode === 'on' ? decided : await deciding;
970
- if (pass || decision) await noteSpawn($, router, { cfg, mode, e, pass, decision, routed, result, definition });
971
- else router.agents.delete(result.agentId);
972
- } catch {
973
- if (router.agents.get(result.agentId)?.pending) router.agents.delete(result.agentId);
974
- }
952
+ const decision = pass ? null : await decideSpawn($, router, cfg, e, definition, next.signal).catch(() => null);
953
+ const routed = Boolean(decision?.model);
954
+ const result = await next(routed ? { ...e, model: decision.model } : e);
955
+ if (result.agentId && (pass || decision))
956
+ await noteSpawn($, router, { cfg, e, pass, decision, routed, result, definition }).catch(() => {});
975
957
  return result;
976
958
  }
977
959
 
978
- // The spawn's record, kept until the session ends. In `on` core's model is an estimate (coreModelOf); otherwise it is
979
- // the model the agent started on.
980
- async function noteSpawn($, router, { cfg, mode, e, pass, decision, routed, result, definition }) {
960
+ // The spawn's record, kept until the session ends. When routed, core's model is an estimate (coreModelOf); otherwise it
961
+ // is the model the agent started on.
962
+ async function noteSpawn($, router, { cfg, e, pass, decision, routed, result, definition }) {
981
963
  const parentKey = `${e.parentAgentId ?? 'main'} ${e.subagentType}`;
982
964
  const finishedAt = router.finished.get(parentKey);
983
- const ttl = await subagentTtlOf($).catch(() => null);
984
965
  const coreModel = routed
985
966
  ? coreModelOf(cfg, e, {
986
967
  envModel: await $.env.get('CLAUDE_CODE_SUBAGENT_MODEL'),
@@ -990,7 +971,6 @@ async function noteSpawn($, router, { cfg, mode, e, pass, decision, routed, resu
990
971
  : result.model;
991
972
  const record = spawnRecord({
992
973
  sessionId: await $.session.id(),
993
- mode,
994
974
  spawn: e,
995
975
  pass,
996
976
  choice: decision?.choice ?? null,
@@ -999,14 +979,7 @@ async function noteSpawn($, router, { cfg, mode, e, pass, decision, routed, resu
999
979
  failed: decision?.failed,
1000
980
  respawn: Number.isFinite(finishedAt) && Date.now() - finishedAt < RESPAWN_WINDOW_MS,
1001
981
  });
1002
- // Read after the last await, so no reply lands in the pending entry after its replay.
1003
- const pending = router.agents.get(result.agentId);
1004
- const replies = pending?.pending ? pending.usages : [];
1005
- router.agents.set(
1006
- result.agentId,
1007
- replies.reduce((agent, usage) => addAgentReply(cfg, agent, usage, ttl), { ...record, parentKey }),
1008
- );
1009
- if (pending?.finished) await finishAgent($, router, result.agentId);
982
+ router.agents.set(result.agentId, { ...record, parentKey });
1010
983
  }
1011
984
 
1012
985
  // A subagent's prompt-cache lifetime, by Claude Code's rule for requests outside the main conversation.
@@ -1028,8 +1001,7 @@ async function* stepAgent($, router, e, next) {
1028
1001
  try {
1029
1002
  const ttl = await subagentTtlOf($);
1030
1003
  const agent = router.agents.get(e.agentId);
1031
- if (agent?.pending) agent.usages.push(response.usage);
1032
- else if (agent) router.agents.set(e.agentId, addAgentReply(router.config, agent, response.usage, ttl));
1004
+ if (agent) router.agents.set(e.agentId, addAgentReply(router.config, agent, response.usage, ttl));
1033
1005
  } catch {}
1034
1006
  }
1035
1007
  return response;
@@ -1039,11 +1011,6 @@ async function* stepAgent($, router, e, next) {
1039
1011
  async function finishAgent($, router, agentId) {
1040
1012
  const agent = router.agents.get(agentId);
1041
1013
  if (!agent) return;
1042
- // A pending agent is flushed when its decision lands (noteSpawn).
1043
- if (agent.pending) {
1044
- agent.finished = true;
1045
- return;
1046
- }
1047
1014
  router.finished.set(agent.parentKey, Date.now());
1048
1015
  router.agents.set(agentId, flushedAgent(agent));
1049
1016
  await flushSubagents($, router, [agent]);
@@ -1225,7 +1192,7 @@ function paneActions($, router, view) {
1225
1192
  router.run = null;
1226
1193
  router.afterDown = null;
1227
1194
  router.turnSavings.clear();
1228
- for (const [id, agent] of router.agents) if (!agent.pending) router.agents.set(id, flushedAgent(agent));
1195
+ for (const [id, agent] of router.agents) router.agents.set(id, flushedAgent(agent));
1229
1196
  const clear = (key, value) =>
1230
1197
  $.store
1231
1198
  .set(key, value)
@@ -1357,7 +1324,7 @@ export function register(on, options) {
1357
1324
  await $.command.register({
1358
1325
  name: 'router',
1359
1326
  description: 'Open the Router pane, or switch routing: auto, off, pin <tier>, activities <mode>.',
1360
- argumentHint: '[auto|off|pin <tier>|activities off|shadow|on]',
1327
+ argumentHint: '[auto|off|pin <tier>|activities off|on]',
1361
1328
  immediate: true,
1362
1329
  });
1363
1330
  const model = await $.session.model();
@@ -34,22 +34,6 @@ const CONFUSION_ROWS = [...ACTIVITY_VALUES, 'none'];
34
34
 
35
35
  const count = (n) => (Number.isFinite(n) && n > 0 ? Math.floor(n) : 0);
36
36
 
37
- // The shadow readout: turns in shadow, those `on` would have routed differently, and of those the ones with a
38
- // next-request estimate (`estimated`) and the sum of their [min, max] ranges in USD at configured list prices.
39
- const emptyShadow = () => ({ differs: 0, turns: 0, estimated: 0, minUsd: 0, maxUsd: 0 });
40
- const isRange = (r) => Number.isFinite(r?.minUsd) && Number.isFinite(r?.maxUsd);
41
-
42
- function addShadow(shadow, wouldDiffer, range) {
43
- const priced = wouldDiffer && isRange(range);
44
- return {
45
- differs: shadow.differs + (wouldDiffer ? 1 : 0),
46
- turns: shadow.turns + 1,
47
- estimated: shadow.estimated + (priced ? 1 : 0),
48
- minUsd: shadow.minUsd + (priced ? range.minUsd : 0),
49
- maxUsd: shadow.maxUsd + (priced ? range.maxUsd : 0),
50
- };
51
- }
52
-
53
37
  function addRoutes(before, added) {
54
38
  const next = { ...before };
55
39
  for (const [route, n] of Object.entries(added ?? {})) if (count(n)) next[route] = (next[route] ?? 0) + count(n);
@@ -69,15 +53,12 @@ export function emptySession() {
69
53
  switches: { tier: 0, activity: 0 },
70
54
  lateral: { taken: 0, refused: 0 },
71
55
  agreement: { matched: 0, total: 0 },
72
- shadow: emptyShadow(),
73
56
  };
74
57
  }
75
58
 
76
59
  // One finished turn. `activity` is the turn's label (null: none), `answer` the classifier's accepted activity, which
77
- // agreement compares with the tools (null: not counted), `lateral` the turn's lateral outcome (turnActivity, counted
78
- // outside shadow only), `shadow` marks a turn in shadow mode, `wouldDiffer` says whether 'on' would have routed it
79
- // differently (null: no would-route) and `wouldUsd` prices that difference. `routedUsd` is the list price of the
80
- // turn's priced replies (null: none had a price), `pricedRequests` how many of its replies had one, and `routes` counts
60
+ // agreement compares with the tools (null: not counted), `lateral` the turn's lateral outcome (turnActivity).
61
+ // `routedUsd` is the list price of the turn's priced replies (null: none had a price), `pricedRequests` how many of its replies had one, and `routes` counts
81
62
  // its routed replies by the `model@effort` they went out with.
82
63
  export function recordTurn(
83
64
  session,
@@ -94,9 +75,6 @@ export function recordTurn(
94
75
  tierSwitches,
95
76
  activitySwitches,
96
77
  lateral,
97
- wouldDiffer,
98
- wouldUsd,
99
- shadow,
100
78
  },
101
79
  ) {
102
80
  const key = activity ?? 'none';
@@ -121,19 +99,13 @@ export function recordTurn(
121
99
  tier: session.switches.tier + count(tierSwitches),
122
100
  activity: session.switches.activity + count(activitySwitches),
123
101
  },
124
- // In shadow the lateral outcome is the would-route's, which no route followed; the Shadow line covers it.
125
- lateral:
126
- !shadow && (lateral === 'taken' || lateral === 'refused') ? { ...moves, [lateral]: moves[lateral] + 1 } : moves,
102
+ lateral: lateral === 'taken' || lateral === 'refused' ? { ...moves, [lateral]: moves[lateral] + 1 } : moves,
127
103
  agreement: answer
128
104
  ? {
129
105
  matched: session.agreement.matched + (agrees(answer, observed) ? 1 : 0),
130
106
  total: session.agreement.total + 1,
131
107
  }
132
108
  : session.agreement,
133
- // A view saved by 1.6.0 has no estimate fields.
134
- shadow: shadow
135
- ? addShadow({ ...emptyShadow(), ...session.shadow }, wouldDiffer === true, wouldUsd)
136
- : { ...emptyShadow(), ...session.shadow },
137
109
  };
138
110
  }
139
111
 
@@ -146,7 +118,7 @@ const LATENCY_BUCKETS = LATENCY_BOUNDS.length + 1;
146
118
  const LATENCY_CLASSIFIERS = 8;
147
119
 
148
120
  export function emptyStore() {
149
- return { version: 1, confusion: {}, runs: {}, lateral: { taken: 0, refused: 0 }, shadow: emptyShadow() };
121
+ return { version: 1, confusion: {}, runs: {}, lateral: { taken: 0, refused: 0 } };
150
122
  }
151
123
 
152
124
  // The p95 of a latency histogram: the upper bound of its bucket in ms, `over` when it lies above the last bound, and
@@ -171,21 +143,9 @@ const countsOf = (v, keys) => onlyKeys(v, keys) && Object.values(v).every(isCoun
171
143
  const exactCountsOf = (v, keys) =>
172
144
  isRecord(v) && Object.keys(v).length === keys.length && keys.every((k) => isCount(v[k]));
173
145
 
174
- const SHADOW_COUNTS = ['differs', 'turns'];
175
- const SHADOW_ESTIMATE = ['estimated', 'minUsd', 'maxUsd'];
176
- // 1.6.0 kept the shadow counts only; 1.6.1 adds the estimate. Either shape, never a part of the estimate.
177
- const isShadow = (v) =>
178
- exactCountsOf(v, SHADOW_COUNTS) ||
179
- (onlyKeys(v, [...SHADOW_COUNTS, ...SHADOW_ESTIMATE]) &&
180
- Object.keys(v).length === 5 &&
181
- SHADOW_COUNTS.every((k) => isCount(v[k])) &&
182
- isCount(v.estimated) &&
183
- Number.isFinite(v.minUsd) &&
184
- Number.isFinite(v.maxUsd));
185
-
186
- // The stored value if it has a known shape, filled to the current one, else an empty store: a hand-edited or
187
- // unknown file must not break stats. The shape is 1.7.0's, which rejects any other key: a new count goes under its own
188
- // key, such as METRICS_KEY, so a downgrade keeps these.
146
+ // The stored value if it has a known shape, else an empty store: a hand-edited or unknown file must not break stats.
147
+ // Any other key is rejected: a new count goes under its own key, such as METRICS_KEY. A store saved before 1.10.1 also
148
+ // holds the shadow readout, which reads as dropped; a release before 1.10.1 resets a store saved without it.
189
149
  export function readStore(value) {
190
150
  const ok =
191
151
  onlyKeys(value, ['version', 'confusion', 'runs', 'lateral', 'shadow']) &&
@@ -196,22 +156,21 @@ export function readStore(value) {
196
156
  Object.values(value.runs).every(
197
157
  (lengths) => Array.isArray(lengths) && lengths.length === RUN_BUCKETS && lengths.every(isCount),
198
158
  ) &&
199
- exactCountsOf(value.lateral, ['taken', 'refused']) &&
200
- isShadow(value.shadow);
201
- return ok ? { ...value, shadow: { ...emptyShadow(), ...value.shadow } } : emptyStore();
159
+ exactCountsOf(value.lateral, ['taken', 'refused']);
160
+ if (!ok) return emptyStore();
161
+ const { shadow: _retired, ...store } = value;
162
+ return store;
202
163
  }
203
164
 
204
- // One finished turn. `predicted` is the classifier's answer (null: none), `runEnded` a run that closed this turn,
205
- // `lateral` the outcome of a lateral switch decision, `wouldDiffer` the shadow readout (null: not in shadow) and
206
- // `wouldUsd` its estimate. Unknown labels are dropped, so the store keeps a fixed set of keys.
207
- export function recordStore(store, { predicted, observed, runEnded, lateral, wouldDiffer, wouldUsd }) {
165
+ // One finished turn. `predicted` is the classifier's answer (null: none), `runEnded` a run that closed this turn and
166
+ // `lateral` the outcome of a lateral switch decision. Unknown labels are dropped, so the store keeps a fixed set of keys.
167
+ export function recordStore(store, { predicted, observed, runEnded, lateral }) {
208
168
  const row = predicted ?? 'none';
209
169
  const next = {
210
170
  version: 1,
211
171
  confusion: { ...store.confusion },
212
172
  runs: { ...store.runs },
213
173
  lateral: { ...store.lateral },
214
- shadow: { ...store.shadow },
215
174
  };
216
175
  if (CONFUSION_ROWS.includes(row) && OBSERVED.includes(observed))
217
176
  next.confusion[row] = { ...next.confusion[row], [observed]: (next.confusion[row]?.[observed] ?? 0) + 1 };
@@ -221,7 +180,6 @@ export function recordStore(store, { predicted, observed, runEnded, lateral, wou
221
180
  next.runs[runEnded.activity] = lengths;
222
181
  }
223
182
  if (lateral === 'taken' || lateral === 'refused') next.lateral[lateral] += 1;
224
- if (typeof wouldDiffer === 'boolean') next.shadow = addShadow(next.shadow, wouldDiffer, wouldUsd);
225
183
  return next;
226
184
  }
227
185
 
@@ -334,31 +292,25 @@ const lateralOf = (decision) =>
334
292
  decision?.lateral === 'taken' || decision?.lateral === 'refused' ? decision.lateral : null;
335
293
 
336
294
  // What one routed turn adds to the stats, from its config, the classifier's advice, and the decisions before and
337
- // after it. `label` is the turn's activity: the applied one in `on`, the accepted answer in `shadow`; `answer` is the
338
- // accepted answer in both, which the tools are checked against and runs follow. `switched` names
339
- // what moved the route from the previous turn's: 'activity' for a lateral move, 'tier' for any other, null for none
340
- // or a pin. `lateral` reads the decision that carries an activity, the would-route in `shadow`.
295
+ // after it. `label` is the activity applied in `on`; `answer` is the accepted answer, which the tools are checked
296
+ // against and runs follow. `switched` names what moved the route from the previous turn's: 'activity' for a lateral
297
+ // move, 'tier' for any other, null for none or a pin.
341
298
  export function turnActivity(config, advice, previous, decision) {
342
299
  const mode = config.activityRouting;
343
- const would = decision.wouldRoute ?? null;
300
+ const on = mode === 'on';
344
301
  const switched =
345
302
  previous?.model && !decision.pinned && differs(previous, decision)
346
303
  ? lateralOf(decision) === 'taken'
347
304
  ? 'activity'
348
305
  : 'tier'
349
306
  : null;
350
- const answer = mode === 'off' ? null : acceptActivity(config, advice);
351
- const wouldDiffer = mode === 'shadow' ? Boolean(would && differs(would, decision)) : null;
352
307
  return {
353
308
  mode,
354
- answer,
355
- label: mode === 'on' ? (decision.activity ?? null) : mode === 'shadow' ? answer : null,
309
+ answer: on ? acceptActivity(config, advice) : null,
310
+ label: on ? (decision.activity ?? null) : null,
356
311
  predicted: advice?.activity?.choice ?? null,
357
312
  switched,
358
- lateral: lateralOf(mode === 'shadow' ? would : mode === 'on' ? decision : null),
359
- // A shadow turn always counts, so the session and store denominators agree.
360
- wouldDiffer,
361
- wouldUsd: wouldDiffer ? (would.difference ?? null) : null,
313
+ lateral: on ? lateralOf(decision) : null,
362
314
  };
363
315
  }
364
316
 
@@ -394,6 +346,5 @@ export function storeSummary(store) {
394
346
  focus,
395
347
  disagreements: misses.sort((a, b) => b.n - a.n).slice(0, 2),
396
348
  lateral: store.lateral,
397
- shadow: store.shadow,
398
349
  };
399
350
  }
package/lib/band.mjs CHANGED
@@ -91,14 +91,11 @@ const pendingMeter = () => [...BARS].map((bar) => part(bar, { color: COLOR.accen
91
91
 
92
92
  const route = (view) => routeLabel(view.actualModel ?? view.selectedModel ?? view.nativeModel, view.effort);
93
93
 
94
- // The turn's activity between the tier and the route, as a verb in orange italic; dim and marked in shadow, where the
95
- // route shown is still the one in use. One part with its arrow, so a narrow band drops both before the reason.
94
+ // The turn's activity between the tier and the route, as a verb in orange italic. One part with its arrow, so a
95
+ // narrow band drops both before the reason.
96
96
  function activityPart(config, view) {
97
97
  if (!view.activity || config.activityRouting === 'off') return null;
98
- const verb = activityVerb(view.activity);
99
- return config.activityRouting === 'shadow'
100
- ? { ...part(`${verb} (shadow) → `, { dimColor: true }), priority: 2 }
101
- : { ...part(`${verb} → `, { color: COLOR.activity, italic: true }), priority: 2 };
98
+ return { ...part(`${activityVerb(view.activity)} → `, { color: COLOR.activity, italic: true }), priority: 2 };
102
99
  }
103
100
 
104
101
  function served(view) {
package/lib/config.mjs CHANGED
@@ -5,12 +5,15 @@ export const EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'];
5
5
  // What kind of work a turn does, named by what it produces. Closed: the classifier question is built for this set.
6
6
  export const ACTIVITIES = ['code', 'debug', 'explore', 'plan', 'review', 'ops', 'docs'];
7
7
  export const ACTIVITY_VALUES = [...ACTIVITIES, 'uncertain'];
8
- // `off` asks nothing new and routes as 1.5; `shadow` asks and records but keeps the 1.5 route; `on`, the default since
9
- // 1.7, applies overrides.
10
- export const ACTIVITY_MODES = ['off', 'shadow', 'on'];
11
- // `subagentRouting` takes the same modes: `off` asks and records nothing, `shadow` decides and records but keeps core's
12
- // model, `on` applies the decision at agent.spawn.
8
+ // `off` asks nothing new and routes as 1.5; `on`, the default since 1.7, applies overrides.
9
+ export const ACTIVITY_MODES = ['off', 'on'];
10
+ // `subagentRouting` takes the same modes: `off` asks and records nothing, `on` applies the decision at agent.spawn.
13
11
  export const SUBAGENT_MODES = ACTIVITY_MODES;
12
+ // Both modes took `shadow` until 1.10.1. A file that still sets it is read as not setting the key, and a write from the
13
+ // pane drops it.
14
+ const MODE_KEYS = ['activityRouting', 'subagentRouting'];
15
+ const withoutShadow = (file) =>
16
+ Object.fromEntries(Object.entries(file).filter(([key, value]) => !(value === 'shadow' && MODE_KEYS.includes(key))));
14
17
  // A `subagents.types` value that asks the classifier instead of naming a model.
15
18
  export const CLASSIFY = 'classify';
16
19
  const SONNET_HIGH = { model: 'sonnet', effort: 'high' };
@@ -61,7 +64,7 @@ export const DEFAULTS = {
61
64
  // not a multiplier (Opus 5.5 reads at 0.05x input, the rest at the standard 0.1x). `longContext` multiplies every
62
65
  // rate of a request whose prompt (input, cache read and cache write) is over `above` tokens: Haiku 5.5 lists its
63
66
  // rates for prompts up to 100,000 tokens and 5x above. A price change must also change
64
- // test/fixtures/list-prices.json, with its source and date. `output` feeds the shadow estimate and the downgrade tax.
67
+ // test/fixtures/list-prices.json, with its source and date. `output` feeds the downgrade tax.
65
68
  // `efforts` lists what the model accepts; an empty list means no effort field and no adaptive thinking. A change
66
69
  // must also change test/fixtures/effort-support.json, from a new probe against the real API.
67
70
  models: {
@@ -195,7 +198,7 @@ export const MIGRATION_HINT =
195
198
 
196
199
  export function loadConfig({ userFile = null } = {}) {
197
200
  if (userFile !== null) checkShape(userFile);
198
- const merged = merge(DEFAULTS, userFile ?? {});
201
+ const merged = merge(DEFAULTS, withoutShadow(userFile ?? {}));
199
202
  // A user entry without `api` speaks the System One protocol that every entry spoke before 1.5.
200
203
  const config = {
201
204
  ...merged,
@@ -325,7 +328,7 @@ export function editActivity(draft, current, activity, tier, kind, value = null)
325
328
  // route in `file` (the merge would bring the built-in back otherwise), so call this after withRoutes.
326
329
  export function withActivities(file, draft) {
327
330
  const { base } = draft;
328
- const { activities: kept = {}, activityRouting: keptMode, ...rest } = file;
331
+ const { activities: kept = {}, activityRouting: keptMode, ...rest } = withoutShadow(file);
329
332
  const activities = {};
330
333
  for (const activity of ACTIVITIES) {
331
334
  for (const tier of TIERS) {
package/lib/cost.mjs CHANGED
@@ -90,7 +90,7 @@ export function switchingTaxUsd(config, candidate, incumbent, facts, now) {
90
90
  }
91
91
 
92
92
  // The next request on `candidate` against `incumbent` as a range: the input bounds crossed, plus the output difference
93
- // at the last reply's length when both routes have an output price, as shadowEconomics compares.
93
+ // at the last reply's length when both routes have an output price, as switchEconomics compares.
94
94
  export function nextTurnRange(config, candidate, incumbent, facts, now) {
95
95
  const tokens = nextContextTokens(facts);
96
96
  const proposed = inputBounds(config, candidate, tokens, facts, now);
@@ -101,7 +101,7 @@ export function nextTurnRange(config, candidate, incumbent, facts, now) {
101
101
  return { minUsd: proposed.min - current.max + output, maxUsd: proposed.max - current.min + output };
102
102
  }
103
103
 
104
- export function shadowEconomics(config, candidate, incumbent, facts, now) {
104
+ export function switchEconomics(config, candidate, incumbent, facts, now) {
105
105
  const tokens = nextContextTokens(facts);
106
106
  const proposed = ratesAt(routeSpec(config, candidate), tokens);
107
107
  const current = ratesAt(routeSpec(config, incumbent), tokens);
@@ -120,7 +120,7 @@ export function shadowEconomics(config, candidate, incumbent, facts, now) {
120
120
  }
121
121
 
122
122
  export function downgradeTaxUsd(config, candidate, incumbent, facts, now, turns) {
123
- const estimate = shadowEconomics(config, candidate, incumbent, facts, now);
123
+ const estimate = switchEconomics(config, candidate, incumbent, facts, now);
124
124
  if (!estimate) return Math.max(0, switchingTaxUsd(config, candidate, incumbent, facts, now));
125
125
  return Math.max(0, estimate.nextTurnUsd + (turns - 1) * estimate.laterTurnUsd);
126
126
  }
package/lib/display.mjs CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  } from './config.mjs';
11
11
  import { ratesAt } from './cost.mjs';
12
12
  import { PROBE_RESULTS } from './probe-results.mjs';
13
- import { cellForModel, isSameModel } from './route.mjs';
13
+ import { cellForModel } from './route.mjs';
14
14
  import { emptyTotals, readout, readSavingsStore } from './savings.mjs';
15
15
 
16
16
  // Cost order, cheapest first, so the colors read as a scale. Hex values: every surface draws them.
@@ -186,21 +186,9 @@ export function activityReading(view) {
186
186
  return { choice, share: Number.isFinite(share) ? percent(share) : null, others };
187
187
  }
188
188
 
189
- // The route the turn's cell resolves to, against the tier's base route: `on` names the override, `shadow` what `on`
190
- // would run beside the route in use. Null in `off`, or before a turn has a tier.
191
- export function activityRouteText(config, view) {
192
- const mode = config.activityRouting;
193
- if (mode === 'shadow') {
194
- const would = view.wouldRoute;
195
- if (!would?.tier) return null;
196
- const current = view.selectedModel ?? view.nativeModel;
197
- const same = isSameModel(would.model, current) && (would.effort ?? null) === (view.effort ?? null);
198
- return (
199
- `${would.tier}${would.activity ? ` + ${would.activity}` : ''} would use ${routeLabel(would.model, would.effort)}` +
200
- ` (shadow; ${same ? 'same route' : `using ${routeLabel(current, view.effort)}`})`
201
- );
202
- }
203
- if (mode !== 'on' || !view.tier) return null;
189
+ // The route the turn's cell resolves to, against the tier's base route. Null outside `on`, or before a turn has a tier.
190
+ function activityRouteText(config, view) {
191
+ if (config.activityRouting !== 'on' || !view.tier) return null;
204
192
  const cell = `${view.tier}${view.activity ? ` + ${view.activity}` : ''}`;
205
193
  const route = resolveRoute(config, view.tier, view.activity ?? null);
206
194
  const base = resolveRoute(config, view.tier);