@darkbear9494/dsh-model-manager 0.1.0

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.
package/README.md ADDED
@@ -0,0 +1,1231 @@
1
+ # @darkbear9494/dsh-model-manager
2
+
3
+ A host-half plugin for DeepSeek Harness that assigns models to four roles — `main`,
4
+ `planning`, `execution`, `vision` — applies them on the `agent/request` waterfall, and
5
+ reports which model every subagent actually used, with its role, the reason, and its live
6
+ status.
7
+
8
+ ## What it is
9
+
10
+ DSH already ships the primitives: the `subagent` tool accepts an explicit
11
+ `provider`/`model` per delegation, and the `subagent-model-selection-settings` row
12
+ constrains which routes an agent may name. What it does not ship is a layer above that:
13
+ nothing assigns models to *kinds of work* (planning, implementation, image reading), and
14
+ nothing tells you afterwards which model a given subagent ended up on.
15
+
16
+ This plugin is that layer. It keeps one ordered route list per role, classifies each
17
+ delegated child from the label the delegating agent gives it, rewrites the child's resolved
18
+ route to the role's route when inheritance is provable, and exposes a read-only
19
+ `model_manager` tool that reports what happened. It is deliberately small: one ESM host
20
+ file, one config schema, and one hand-written client file that contributes a
21
+ configuration card to the Plugins page. There is no build step for either half.
22
+
23
+ ## Install
24
+
25
+ One command — straight from GitHub, or from a working copy:
26
+
27
+ ```bash
28
+ # from GitHub, no publishing step; needs git access to the repo
29
+ dsh plugin --profile desktop add github:jyshangguan/dsh-model-manager
30
+
31
+ # from a working copy (path must be absolute)
32
+ git clone https://github.com/jyshangguan/dsh-model-manager.git
33
+ dsh plugin --profile desktop add /absolute/path/to/dsh-model-manager
34
+
35
+ # from npm — only after `npm publish`; see "Not on npm yet" below
36
+ dsh plugin --profile desktop add @darkbear9494/dsh-model-manager@latest
37
+ ```
38
+
39
+ Use the profile your app actually boots. `dsh web` and the Web GUI run the `web` profile; the
40
+ desktop app (DeepSeek Harness.app) runs **`desktop`**, so a plugin installed into `web` is
41
+ invisible there. When in doubt, check the running process's working directory: it is
42
+ `$DSH_HOME/profiles/<name>`.
43
+
44
+ `dsh plugin` forwards everything after `--profile <name>` to **pnpm, run inside the profile
45
+ directory** under a file lock (`lib/bin.js` → `runPlugin` → `runPluginCommand` in
46
+ `@deepseek-ai/dsh-plugin-manager`). It is the same code path the GUI's `install_bundle` action
47
+ uses, so both leave an identical result.
48
+
49
+ What makes it one command instead of three: after the install, `reconcile()` walks every *new*
50
+ profile dependency, reads its manifest, and when it declares `dsh.bundle.patch` it validates that
51
+ patch and appends the package name to `dsh.profile.bundles`, writing `package.json` atomically. A
52
+ dependency that declares no `dsh.bundle` prints `installed as a plain dependency, not a profile
53
+ layer` and is never mounted. The profile-layer registration you would otherwise hand-edit is the
54
+ installer's job.
55
+
56
+ Then **restart the harness once** and confirm the row mounted: `plugin_manager` `list_plugins`
57
+ should show row id `model-manager`, `enabled: true`, `fiberPhase: active`.
58
+
59
+ ### Add plugin, from the Plugins page
60
+
61
+ The Plugins page's **Add plugin** field reads *"Enter the plugin's package name, GitHub repository
62
+ address, or local directory path."* It is the GUI's `install_bundle`, and it parses the string
63
+ through the same `parseInstallSpec` (`@deepseek-ai/dsh-plugin-manager/lib/types/install-spec.js`)
64
+ before handing it to pnpm. Paste any one of:
65
+
66
+ | Field input | Spec kind |
67
+ | --- | --- |
68
+ | `github:jyshangguan/dsh-model-manager` | git — the `https://github.com/…` URL works too |
69
+ | `/Users/you/src/dsh-model-manager` | absolute local directory (relative paths are refused) |
70
+ | `/Users/you/dsh-model-manager-0.1.0.tgz` | local tarball — `npm pack` makes one, no registry needed |
71
+ | `@darkbear9494/dsh-model-manager` | registry — needs the package published first |
72
+
73
+ The **Add plugin** field prompts for a package name, and that is the one form that does not work
74
+ yet; the other three do. Verified end-to-end on this runtime: the git and local-path forms both
75
+ install, `reconcile()` appends the bundle, and the composed tree mounts row `model-manager`.
76
+
77
+ ### Not on npm yet
78
+
79
+ `@darkbear9494/dsh-model-manager` is **not published**. Asking for it by name fails at pnpm with
80
+ `ERR_PNPM_FETCH_404: GET https://registry.npmjs.org/@jyshangguan%2Fdsh-model-manager: Not Found`.
81
+ Publishing is the only thing standing between this plugin and the package-name form — the manifest
82
+ is already public-access, unprivate, and `files` lists exactly what a mounted bundle needs, so
83
+ `npm publish` from the repository root is the whole step. Until then use the **git** or **local
84
+ path** form: both install the same tree a published tarball would contain, because every shipped
85
+ file is committed and `files` limits the pack to them (verified — the git install delivers
86
+ `lib/index.js`, `client.js`, `cordis.patch.yml`, `locale/*.json` and no `node_modules`).
87
+
88
+ ### Why the package is scoped, and why the scope is `@darkbear9494`
89
+
90
+ The unscoped name `dsh-model-manager` is **already taken on npm by a different plugin**: another
91
+ DeepSeek Harness package whose Chinese display name is also 模型管理器, and which also declares
92
+ `dsh.bundle.patch`. Installing by that bare name fetches theirs and auto-registers it into your
93
+ boot graph; were both ever mounted together their loader rows could collide on one id, which
94
+ aborts startup with `duplicate loader entry id`. `test/packaging.test.mjs` pins the scoped name
95
+ so this cannot silently regress.
96
+
97
+ The scope is not decoration. npm accepts a **user-scoped** package only when the scope equals the
98
+ authenticated npm username; anything else is refused at publish time with
99
+ `404 Not Found - PUT https://registry.npmjs.org/@<scope>%2f<name> - Scope not found`, unless the
100
+ scope is an organization you belong to. This package was briefly `@jyshangguan/dsh-model-manager`,
101
+ which failed to publish for exactly that reason — `@jyshangguan` is a GitHub handle, not the npm
102
+ account. `@darkbear9494` is the npm account, so scope and account agree and no organization is
103
+ needed. If the publishing account ever changes, the package name has to change with it.
104
+
105
+ ### The runtime version gate
106
+
107
+ `peerDependencies["@deepseek-ai/dsh"]` is `>=0.1.7-rc.2 <0.3.0`. The harness checks exactly that
108
+ peer — only names equal to `@deepseek-ai/dsh` or beginning `@deepseek-ai/dsh-` — with semver,
109
+ **prereleases included** (`semver.satisfies(runtime, range, { includePrerelease: true })` in
110
+ `@deepseek-ai/dsh-app-boot`), and refuses an incompatible install while printing the exemption
111
+ command:
112
+
113
+ ```bash
114
+ dsh plugin --profile desktop allow-version @darkbear9494/dsh-model-manager@0.1.0 \
115
+ --dsh-version <exact runtime version> --accept-risk
116
+ ```
117
+
118
+ Without that peer this plugin would install silently onto a harness too old to have
119
+ `sessionProjections.stateOf` or the `model/selection` event, and then degrade with no
120
+ explanation. Profiles ship `autoInstallPeers: false`, so declaring the peer does not pull a
121
+ second copy of dsh into the profile.
122
+
123
+ The range was `>=0.1.7-rc.2 <0.2.0` through 0.1.0, and that upper bound did not mean what it
124
+ looked like. In semver a prerelease sorts *below* its release, so `0.2.0-rc.2 < 0.2.0` is true:
125
+ the old range admitted **every 0.2.0 prerelease** while excluding `0.2.0` itself. It therefore
126
+ permitted exactly the builds nobody had tested and blocked the release it appeared to target.
127
+ `<0.3.0` is what it was meant to say, and it now covers the whole 0.2.0 line deliberately.
128
+
129
+ The 0.2.0 line is admitted because the host half is verified against it. Against **dsh
130
+ 0.2.0-rc.2** — the core bundled in DeepSeek Harness.app 0.2.0-rc.2 and the `latest` tag on npm —
131
+ every API this plugin touches is unchanged from 0.1.7-rc.2: `dsh-session-projection`
132
+ (`stateOf`), `dsh-plan-mode`, `dsh-agent`, `dsh-subagent`, `dsh-tool-subagent` +
133
+ `model-selection-settings`, `dsh-tools`, `dsh-llm`, `dsh-session` and `dsh-client-modules` are
134
+ byte-identical, all five subscribed events and every probed service still exist, and all 22
135
+ failover `failure.code` values are still emitted. A real boot on that runtime applied the host
136
+ half, bound every event, resolved every injection and registered the `model_manager` tool. The
137
+ client half is unchanged too: `window.__ModuleLoader__.load({ id, factory })`, the `dsh.client`
138
+ manifest keys and every injected namespace still match what 0.2.0 provides.
139
+
140
+ What did change between the two runtimes touches nothing here: `dsh-agent-loop` adds
141
+ `ToolCallRecovery` on step failure, `dsh-session` refactors tail repair, `dsh-config-editor`
142
+ changes how inherited config composes, and `dsh-api-remotes` gains transport code plus two
143
+ namespaces (`productAnalytics`, `userQuestions`) with **no removals**.
144
+
145
+ ### Renaming or moving a linked install
146
+
147
+ Both of these were hit for real while scoping this package, on DSH 0.1.7-rc.2:
148
+
149
+ `remove_bundle` drops the dependency from the profile's `package.json` and removes it from
150
+ `dsh.profile.bundles`, but **leaves the symlink behind** in the profile's `node_modules`. Delete
151
+ that orphan yourself: a directory whose name no longer matches the `name` in its own manifest is
152
+ precisely what a resolution scanner should not have to reason about. (Clearing it did *not* fix
153
+ the symptom below, so it is hygiene rather than a remedy.)
154
+
155
+ And a **running host cannot import a package name that did not exist when it booted**. The runtime
156
+ resolution is computed from the installation and the bundles selected at startup, then handed to
157
+ Node's ESM and CommonJS resolvers, so after a rename the entry reports `failed to import` —
158
+ `inactiveEntries` finding `entry.fiber === undefined` — however many times you toggle the bundle.
159
+ The package itself is fine: `node -e "import('<new name>')"` from the profile directory succeeds,
160
+ and `dsh --profile <name> --dump-config` composes the row correctly, override config included.
161
+ Only a restart picks it up. Remove the old name, install the new one, then restart once.
162
+
163
+ | File | Purpose |
164
+ | --- | --- |
165
+ | `lib/index.js` | Host half: Cordis identity `model-manager`, exported `Config`, `apply`, the `agent/request` routing, the `agent/request-error` failover, and the `model_manager` tool. |
166
+ | `client.js` | Client half: the configuration card, contributed as a page in the Settings panel. |
167
+ | `locale/en.json`, `locale/zh.json` | Display metadata only — the bundle's `title` and `description` in the plugin list. |
168
+ | `cordis.patch.yml` | Bundle layer: inserts exactly one row, id `model-manager`. |
169
+ | `package.json` | Package `@darkbear9494/dsh-model-manager`, declaring `dsh.bundle.patch`, `dsh.client`, and the `@deepseek-ai/dsh` version gate. |
170
+ | `test/` | The test suite; `npm test` runs all of it. See [Testing](#testing). |
171
+
172
+ ### Making the schema dependency resolvable
173
+
174
+ `@deepseek-ai/schemastery` is declared as an **optional peer**: the harness ships it, and this
175
+ package deliberately does not install its own copy, so the `Config` schema is built by the same
176
+ schemastery instance the loader validates with.
177
+
178
+ But a path-based install is *linked*, not copied, so Node resolves this package's imports from
179
+ its own directory upward — which never reaches the profile's `node_modules`. Point it at the
180
+ harness's copy once per machine:
181
+
182
+ ```bash
183
+ mkdir -p node_modules/@deepseek-ai
184
+ ln -s "$(npm root -g)/@deepseek-ai/dsh/node_modules/@deepseek-ai/schemastery" \
185
+ node_modules/@deepseek-ai/schemastery
186
+ ```
187
+
188
+ `npm root -g` is the global install root; adjust if your `dsh` lives somewhere else.
189
+ `node_modules/` is git-ignored, so this step is not carried by the repository.
190
+
191
+ Skipping it does not break the plugin: `Config` degrades to `undefined`, cordis's
192
+ `resolveConfig` passes the raw config straight through, and routing keeps working. What you
193
+ lose is the Settings card — the harness only serves a settings namespace for a row that has a
194
+ Config schema, so the card would report the namespace as unavailable.
195
+
196
+ **The test suite needs it too**, and fails less gracefully than the plugin does: without a
197
+ resolvable schemastery, `edge` dies on `TypeError: plugin.Config is not a constructor` and
198
+ `client-diagnostic` loses one assertion. This is a known rough edge — the suites should skip
199
+ those cases with a warning instead of crashing. Create the symlink before running `npm test` on
200
+ a fresh clone.
201
+
202
+ **Restart the harness once after installing.** The client half reaches the browser through
203
+ a boot manifest: the node half of `client-modules` scans the loader's entries for packages
204
+ declaring `dsh.client`, and package metadata — including the negative "not a client
205
+ package" verdict — is cached per loader specifier *until restart*. It is the same restart
206
+ the host half needs, so do both at once. Before it, the Plugins page simply shows no
207
+ configure control for this bundle.
208
+
209
+ ```json
210
+ {
211
+ "exports": {
212
+ ".": "./lib/index.js",
213
+ "./client": "./client.js",
214
+ "./locale/*.json": "./locale/*.json",
215
+ "./package.json": "./package.json"
216
+ },
217
+ "dsh": {
218
+ "bundle": {
219
+ "patch": "./cordis.patch.yml"
220
+ },
221
+ "client": {
222
+ "platform": "web",
223
+ "immediately": true,
224
+ "inject": [
225
+ "@deepseek-ai/dsh-client-locale",
226
+ "@deepseek-ai/dsh-client-ui-settings",
227
+ "@deepseek-ai/dsh-api-remotes"
228
+ ]
229
+ }
230
+ }
231
+ }
232
+ ```
233
+
234
+ `platform: "web"` is what makes this a browser module for the web shell, and `immediately:
235
+ true` marks it for stage-one prefetch, so its factory is registered during module-face boot
236
+ instead of on demand. `inject` is a *dependency edge*, not a mount whitelist: each named package
237
+ has to arrive first because it declares something this half uses —
238
+ `@deepseek-ai/dsh-client-locale` for `ctx.locale.register`, `@deepseek-ai/dsh-client-ui-settings`
239
+ for the `settings.section` slot, and `@deepseek-ai/dsh-api-remotes` for the `remote.llm` and
240
+ `remote.session` faces the card reads the model catalog and the usage projection through. If one
241
+ is missing from the composition that registration has nothing to attach to; the host half still
242
+ routes, and the boot log names the surface that never appeared.
243
+
244
+ To smoke-test it before installing anything, mount the entry by path in a throwaway
245
+ patch layer and boot the whole plugin tree headless — a plugin that breaks startup fails
246
+ here instead of in your running server:
247
+
248
+ ```yaml
249
+ # smoke.patch.yml
250
+ - insert:
251
+ - id: model-manager-smoke
252
+ name: '/absolute/path/to/dsh-model-manager/lib/index.js'
253
+ config:
254
+ roles:
255
+ planning:
256
+ models:
257
+ - provider: pku-corpus
258
+ model: qwen3.8-max-0902
259
+ execution:
260
+ models:
261
+ - provider: pku-corpus
262
+ model: qwen3.8-flash
263
+ strategy:
264
+ mode: hybrid
265
+ ```
266
+
267
+ ```bash
268
+ dsh --profile web --patch ./smoke.patch.yml headless "say ok"
269
+ ```
270
+
271
+ ## The four roles
272
+
273
+ Each role holds an ordered list of routes and a `pick` strategy. A role with no models
274
+ resolves to no route, and requests classified into it pass through unchanged — except
275
+ `vision`, which falls back to `execution`. A subagent never uses `main`.
276
+
277
+ | Role | What it is for | When it applies | Bundled default |
278
+ | --- | --- | --- | --- |
279
+ | `main` | The top-level agent outside plan mode. | Requests from a non-subagent session while plan mode is **not** active. | `models: []` (no route — the composer choice is left alone) |
280
+ | `planning` | Reasoning, design, analysis, research. | Top-level requests while plan mode is active; subagents whose label matches a planning keyword (and no vision keyword). | `pku-corpus/qwen3.8-max-0902` |
281
+ | `execution` | Default tier for delegated implementation. | Every subagent that matches neither keyword list, including a child with an empty label; also the fallback for vision when `vision` has no models. | `pku-corpus/qwen3.8-flash` |
282
+ | `vision` | Image, screenshot, chart and OCR work. | Subagents whose label matches a vision keyword. | `models: []` (falls back to `execution`) |
283
+
284
+ A route is `{ provider, model, reasoningEffort? }`; `pick` is `first` (default) or
285
+ `round-robin`. With one model in the list, `pick` has no effect. A role may also carry a
286
+ `note` — free text for humans, printed under the role in the `routes` table and never
287
+ used for routing.
288
+
289
+ ## Configure in the UI
290
+
291
+ The client half contributes a configuration card to the Plugins page. It writes exactly the
292
+ values documented under [Configuration](#configuration) — `roles.<role>.models` and
293
+ `strategy.mode` — so the two paths are interchangeable: use the card to try a routing
294
+ choice, the YAML to pin it. This package's own `cordis.patch.yml` is the declarative source
295
+ that ships with the bundle and is re-read on every boot, and a profile patch overrides it by
296
+ row id; the card never edits patch files, so if a patch layer pins a value, edit the patch.
297
+
298
+ ### Where the card appears
299
+
300
+ `client.js` registers **two** surfaces and deliberately nothing on the Plugins page:
301
+
302
+ | Slot | Registration id | What it renders |
303
+ | --- | --- | --- |
304
+ | `settings.section` | `model-manager` | The configuration card: the four roles and their model lists, the pick strategy, the distribution mode. |
305
+ | `conversation.session.header.utilities` | `model-manager-usage` | The per-session model-usage summary the host half folds from the durable log. |
306
+
307
+ So the path is **设置 → 模型管理器** — not Plugins → the row → configure. `plugins.item` and
308
+ `plugins.row.config` are *not* registered: one card in one place was the requirement, and a
309
+ second copy on the Plugins page would only be a second place for the same values to disagree.
310
+
311
+ Both entries are registered **unconditionally** rather than behind the shipped
312
+ `configForms.whileServed([ns], …)` gate. The Host serves a settings namespace only for a row
313
+ whose Config schema has volatile fields, so that gate would hide the card entirely whenever the
314
+ optional schemastery dependency failed to resolve — making a packaging problem look exactly like
315
+ a missing feature. The entry is therefore always reachable, and the card itself reports why it
316
+ cannot show values.
317
+
318
+ The usage surface only subscribes to a finished value: the host half folds `modelManagerUsage`
319
+ out of the durable session log and ships it as a wired projection, so there is no folding and no
320
+ polling on the client, and the numbers survive a restart.
321
+
322
+ ### What the card offers
323
+
324
+ | Control | Writes | Notes |
325
+ | --- | --- | --- |
326
+ | Model rows, one per role (`Main model`, `Planning and reasoning`, `Execution`, `Image recognition`) | `set roles.<role>.models` | Each configured route is its own row with a `<select>` grouped by provider in `<optgroup>`s, fed by `ctx.remote.session.modelCatalog()` and labelled `name — id`. A route the catalog stopped advertising stays selectable and is marked `(not in catalog)` rather than being silently swapped. An empty list is the YAML default: no route for that role, and `vision` falls back to `execution`. |
327
+ | Add a model | `set roles.<role>.models` | One dashed control under the rows, listing every catalog model the role has not already used, so a model cannot be added twice. |
328
+ | `up` / `remove` | `set roles.<role>.models` | Reorder and delete. The whole list is rewritten in one atomic operation, so a reorder cannot interleave into a partial state. The up control is **disabled on the first row** rather than absent, so the column never changes width. |
329
+ `reasoning.efforts`** in the catalog. `(model default)` writes a route with no `reasoningEffort`, letting the adapter choose; naming a tier explicitly is how you satisfy a model that rejects a request without one. |
330
+ | Reasoning-effort picker | `set roles.<role>.models` (single route with `reasoningEffort`) | Appears **only when the selected model advertises `reasoning.efforts`** in the catalog. `(model default)` writes a route with no `reasoningEffort`, letting the adapter choose; naming a tier explicitly is how you satisfy a model that rejects a request without one. |
331
+ | `Pick` (`first` / `round-robin`) | `set roles.<role>.pick` | Shown for a role holding two or more models. `first` always uses index 0 and only advances when a route fails; `round-robin` spreads consecutive requests. |
332
+ | Distribution mode | `set strategy.mode` | `hybrid` / `managed` / `advisory`, labelled with the same one-line explanations this README uses. A stored mode the card does not know displays as `hybrid`, mirroring the host half's fallback. |
333
+
334
+ **Layout.** One CSS grid per role, with fixed column tracks `auto minmax(0, 1fr) auto auto` — index, model, effort, actions. That choice is the whole reason the rows line up: in a flex row a control with `flex: 1 1 16rem` takes width from its siblings, so any row that omits one control (a model with no reasoning tiers, a first row with no reorder button) pulls every other row's right edge out of alignment. Under the grid a row with no effort control still emits an empty cell, so the action column sits at the same x everywhere. The two actions are glyphs rather than words, so the column is also the same width in either locale; each keeps an `aria-label` and a native `title`. The add affordance is deliberately unlike a model row — dashed border, no fill, muted text, spanning the value columns — and the pick line uses its own label style instead of the numeric index style.
335
+
336
+ Each role also carries a hint line (`Top-level agent outside plan mode. Leave unset to keep
337
+ following the composer selection.`, `Used for image, screenshot and OCR work. Pick a model
338
+ that accepts images.`, …) so the card explains itself without this README open.
339
+
340
+ The card cannot tell you whether a model accepts images: the session model catalog carries
341
+ ids, names and reasoning efforts, and no modality field. Use
342
+ `model_manager(action: "routes")` for the vision capability audit, which asks the host half's
343
+ `llm` service instead.
344
+
345
+ ### How a change reaches the router
346
+
347
+ **Immediately, with no Save button.** Every control writes on `change`, and the host half
348
+ re-reads its config on `loader/volatile-update`, so the next request uses the new value
349
+ without a restart. A short status line confirms the outcome (`Saved`, or the host's refusal
350
+ or error message) in the theme's success/error colour.
351
+
352
+ **The UI never writes settings storage itself.** The page owner hands the card a `form`
353
+ built from the row's settings namespace (`model-manager`): `form.state` with the accepted
354
+ `value`, the current `revision`, `writable` and `status`, and `form.mutate(ops, revision)`
355
+ for ordered path operations. The card always submits with the revision it just read, and a
356
+ mutate that returns falsy or throws is reported rather than assumed to have worked. That is
357
+ why this card cannot race the host's own settings writes: a stale write is fenced off by the
358
+ revision rather than silently overwriting a newer one.
359
+
360
+ ### When the card cannot show anything
361
+
362
+ A component that throws blanks its whole slot entry, so each unavailable state renders a
363
+ notice instead — and every optional collaborator is probed, with any failure logged as
364
+ `[model-manager] <step>: <message>` through a wrapper that keeps applying:
365
+
366
+ | State | Cause | Rendered copy |
367
+ | --- | --- | --- |
368
+ | No `form` on a page render | the host rendered this slot without values — a defensive path, not the row page | `This page did not supply configuration values, so the model roles cannot be edited here. Open this plugin's own row on the Plugins page to configure it.` (warning colour) |
369
+ | No `form` on the summary render | the row-list render always omits it | renders nothing: the card returns `null` and the row's description stands |
370
+ | Catalog loading | `modelCatalog()` in flight | every control renders **disabled**, the add control offers only its own `Add a model…` placeholder, a configured route the catalog has not returned yet still shows as `provider/model (not advertised)` so its value is never silently swapped, and `Loading models…` appears below |
371
+ | Not available to this client | `form.state.status === 'unavailable'` — the namespace is not exposed here | `These settings are not available to this client right now.` (warning colour) |
372
+ | Read-only deployment | `status === 'ready'` but `writable === false` | role rows render disabled, plus `This deployment stores settings read-only.` |
373
+ | Nothing advertised | catalog ready with zero provider groups | `No models are advertised yet. Configure a provider route, then reopen this page.` |
374
+ | Partial failure | catalog `failures` non-empty | `Some providers could not be listed: <name, name>` (warning colour) |
375
+ | Fetch failed | `modelCatalog()` returned an error or threw | the error message, in the error colour |
376
+
377
+ The notices are ordered so a read-only deployment says so before anything about the catalog,
378
+ and the write-result line (`Saved` / refusal) is last, because it is the most transient.
379
+
380
+ The catalog is fetched once per page load and refreshed on the `llm/adapters-updated` and
381
+ `settings/document-updated` remote events, so adding a provider route makes its models
382
+ appear without a reload. A `generation` counter discards a response that is older than the
383
+ most recent request, and a throwing subscriber cannot break the other subscribers.
384
+
385
+ **A configured route the catalog no longer advertises stays selectable**, appended as an
386
+ extra option labelled `pku-corpus/some-retired-model (not advertised)` and kept as the
387
+ selected value. Without that, a `<select>` whose value matches no `<option>` renders as its
388
+ first option instead — so the card would appear to name a model the config does not select,
389
+ and saving anything else on that row would overwrite the real route.
390
+
391
+ Note also that picking a *different* model for a role preserves a `reasoningEffort` already
392
+ stored on that route. If the new model advertises no efforts, the effort picker disappears
393
+ while the stored effort remains in the config; clear it by writing the role's models from
394
+ the patch layer.
395
+
396
+ ### How the card is built
397
+
398
+ - **It requires exactly one module: `react`.** The harness's plugin practices forbid
399
+ `require`-ing Harness Client packages from a hand-written client half — including
400
+ `@deepseek-ai/dsh-client-ui-primitives` — because a second copy of a UI package in the
401
+ browser graph is a breakage waiting to happen. So the `<select>` controls here are written
402
+ locally in `client.js` rather than imported.
403
+ - **Styling uses only `--dsw-alias-*` theme tokens**: `bg-layer-1`, `border-l1`,
404
+ `label-primary`, `label-secondary`, `state-success-primary`, `state-error-primary`,
405
+ `state-warn-primary`. Light and dark follow the host, and a future token rename degrades
406
+ to an inherited colour instead of breaking the entry.
407
+ - **Its copy is localized.** `apply` registers a `dsh-model-manager` locale namespace with
408
+ inline English and Chinese dictionaries through `ctx.locale`, and binds it for rendering;
409
+ if the binding fails, labels degrade to their key names. The `locale/en.json` and
410
+ `locale/zh.json` files in the package are separate: they are the bundle's `title` and
411
+ `description` as shown in the plugin list.
412
+
413
+ **Verification status, stated honestly:** the client half was verified by JavaScript syntax,
414
+ manifest validation, a structural load of the `window.__ModuleLoader__.load` factory — which
415
+ confirms that only `react` is required, that `apply` registers the `dsh-model-manager` locale
416
+ namespace with the same 46 keys in English and Chinese (the test compares the sorted key *sets*,
417
+ not just their counts), that exactly two surfaces are injected — `settings.section` under
418
+ `model-manager` and `conversation.session.header.utilities` under `model-manager-usage` — and
419
+ that `apply` still returns normally when every injected collaborator throws. It was also checked
420
+ against the live slot contract in `@deepseek-ai/dsh-client-ui-settings`. **Visual verification of
421
+ the rendered card is not available in this environment:** the harness's own verification guidance
422
+ forbids emulating React/DOM or building mock previews as a substitute for a browser, so the
423
+ rendered appearance is unverified. Remember the restart after installing, since the live slot only
424
+ populates once the client-module boot manifest has been rebuilt.
425
+
426
+ ## Distribution strategy
427
+
428
+ ### Modes
429
+
430
+ `strategy.mode` decides whether the selected role route is written into the request.
431
+
432
+ | Mode | Behaviour |
433
+ | --- | --- |
434
+ | `hybrid` (default) | Top-level requests are rewritten whenever the role has a route. A subagent is rewritten **only when inheritance is provable** — its resolved route equals the parent's effective route, or equals a route this manager already applied to that child (see below). Anything else is respected as the child's own choice. |
435
+ | `managed` | The role route is always applied, overriding an explicit per-delegation `provider`/`model`. Use this if you want routing regardless of lineage. |
436
+ | `advisory` | Never rewrites anything. It classifies the request and records the model actually used. |
437
+
438
+ `hybrid` is what makes per-delegation choices work: pass nothing and the role decides;
439
+ pass an explicit `provider`/`model` to the delegation tool and your choice survives.
440
+
441
+ ### `main` and the composer's model picker
442
+
443
+ These are two different mechanisms, and they used to collide: the composer writes the
444
+ session's own route (`session.selectModel`), while the manager rewrote it at request time
445
+ whenever `main` was configured — so the picker kept displaying a model that was never used.
446
+
447
+ In `hybrid` the manager now backs off when you have actually chosen. The test is
448
+ **durable, not a guess**: selecting a model in the composer appends a
449
+ `model/selection` event to the session log — that event has exactly one append site in the
450
+ whole install (`selectForNextRequest`) — and this plugin folds it into a
451
+ `modelManagerSelection` session projection. A session with such an event keeps your pick and
452
+ records `explicit session selection (respected)`; a session that never had one is running on
453
+ the deployment default, which is the route `main` exists to replace.
454
+
455
+ Three things follow from that. `managed` is unchanged — it means "the manager owns every
456
+ route", including a session you picked by hand. A respected selection **does not consume the
457
+ round-robin rotation**, because rotation commits only when a route is applied; the first
458
+ request the manager does take over still gets the first model. And the choice survives a
459
+ restart, a resume and a fork, because it is read from the log rather than remembered in
460
+ process state.
461
+
462
+ One caveat worth knowing: **the composer's picker also overwrites the deployment default**
463
+ (implementation note: `selectModel` calls `selectForNextRequest` *and*
464
+ `agentDefaultModel.saveSelection` in the same action). Picking a model for one session
465
+ therefore changes what brand-new sessions start on too, which is the harness's behaviour, not
466
+ this plugin's.
467
+
468
+ ### What "inherited" means
469
+
470
+ Three rules decide whether a subagent request is treated as inherited.
471
+
472
+ **The parent's effective route.** Read the same way DSH itself computes the route it
473
+ passes to a child: the parent's latest request header
474
+ (`agent.session.requestHeader()?.config`) owns `provider`/`model`, and the parent's
475
+ creation options (`agent.options`) are only the pre-first-request fallback. That matters
476
+ because after request-time selection the header reflects what the parent actually ran on
477
+ — including a route this plugin applied. Comparing against `agent.options` instead would
478
+ misread a manager-rewritten parent as an explicit child choice and silently stop routing.
479
+
480
+ **Manager-owned children.** Once the manager routes a child, that child's own request
481
+ header changes, so on its next request it no longer equals the parent's route. Without a
482
+ second rule, a long-running child would be reclassified as an explicit choice and quietly
483
+ stop being managed. So a child is also treated as inherited when its route equals the
484
+ route the manager itself last applied to it. This is tracked by an internal `applied` flag
485
+ recorded per request, and it is `true` only when a route was really applied — `advisory`,
486
+ respected-explicit and `passthrough` all record `false`, so **an explicit choice is never
487
+ re-adopted**. Manager-ownership is checked before lineage, so a child the manager already
488
+ routed stays managed even if its parent goes away.
489
+
490
+ **Unresolvable lineage fails closed.** If no delegating parent can be found and the child
491
+ is not manager-owned, the plugin cannot prove inheritance: it **respects the child's own
492
+ route** and records `lineage unresolved (child route respected)`. If you want the role
493
+ route applied no matter what, use `managed`.
494
+
495
+ All comparisons are by value. A `round-robin` advance is committed **only when a route is
496
+ actually applied**: `advisory` passes, a respected explicit route, and a respected
497
+ unresolved-lineage route all leave the rotation where it was.
498
+
499
+ ### Label-driven classification
500
+
501
+ Only a session whose `session.header.origin` is `'subagent'` is classified by label. The
502
+ label is the `description` the delegating agent passed to the `subagent` tool, which the
503
+ harness stores as the child's label. Matching is case-insensitive and anchored at a
504
+ leading word boundary, in this order:
505
+
506
+ 1. Empty label → `execution`.
507
+ 2. Any `visionKeywords` match → `vision`.
508
+ 3. Else any `planningKeywords` match → `planning`.
509
+ 4. Else `execution`.
510
+
511
+ Vision is tested before planning, so a label that matches both lands on `vision`.
512
+
513
+ | Delegation `description` | Matched by | Role | Applied route (bundled defaults) |
514
+ | --- | --- | --- | --- |
515
+ | `"plan: design the migration"` | `plan`, `design` | `planning` | `pku-corpus/qwen3.8-max-0902` |
516
+ | `"vision: read this screenshot"` | `vision`, `screenshot` | `vision` | falls back to `execution` → `pku-corpus/qwen3.8-flash` |
517
+ | `"fix the typo"` | nothing | `execution` | `pku-corpus/qwen3.8-flash` |
518
+ | `"analyze the parser design"` | `analyze`, `design` | `planning` | `pku-corpus/qwen3.8-max-0902` |
519
+ | `"summarize the changelog"` | nothing | `execution` | `pku-corpus/qwen3.8-flash` |
520
+
521
+ A non-subagent session is never classified by label: it gets `planning` while plan mode
522
+ is active and `main` otherwise.
523
+
524
+ ### The vision → execution fallback
525
+
526
+ If `vision.models` is empty when a vision request is routed, the plugin serves it from the
527
+ execution role's models instead. The role recorded for that request is still `vision`;
528
+ the model is the execution role's, and `execution`'s `pick` strategy and `round-robin`
529
+ counter are the ones used. The `routes` table marks such a role `(via execution)`. If
530
+ `execution` is empty as well, there is no route and the request passes through. This is
531
+ why the bundled default (`vision: []`) is safe: vision work is served by the execution
532
+ tier until you configure a dedicated vision model.
533
+
534
+ ### Vision image capability check
535
+
536
+ A text-only model cannot serve image work: the harness rejects image blocks on requests to
537
+ a model that does not declare image input. Because the vision role has a fallback and can
538
+ name any provider, `routes` verifies the models it will actually use, through
539
+ `ctx.get('llm')` → `resolveModelInfo(provider, model)` → `inputModalities`. The check
540
+ follows the **effective** vision route, so with the bundled default it audits the execution
541
+ model the fallback would use.
542
+
543
+ | Verdict | Condition | Detail text |
544
+ | --- | --- | --- |
545
+ | `ok` | `inputModalities` includes `image` | `accepts images` |
546
+ | `NO IMAGES` | `inputModalities` present without `image` | `declares <modalities> — image work routed here will fail` |
547
+ | `unknown` | no `inputModalities` on the resolved info (absent means unknown) | `image support not declared` |
548
+ | `unresolved` | `resolveModelInfo` threw | `could not resolve (<error message>)` |
549
+
550
+ ```text
551
+ Vision role (image capability):
552
+ ok pku-corpus/kimi-k3 — accepts images
553
+ NO IMAGES pku-corpus/qwen3.8-flash — declares text — image work routed here will fail
554
+ unknown pku-corpus/mystery — image support not declared
555
+ unresolved pku-corpus/broken — could not resolve (no adapter registered for provider "pku-corpus")
556
+ ```
557
+
558
+ The check reports three distinct states on purpose, and they are never conflated.
559
+
560
+ **Checked** — the block above. With the bundled default (no dedicated vision model) it
561
+ audits the execution model the fallback would use:
562
+
563
+ ```text
564
+ Vision role (image capability):
565
+ NO IMAGES pku-corpus/qwen3.8-flash — declares text — image work routed here will fail
566
+ ```
567
+
568
+ **Nothing to check** — no effective vision route, i.e. `vision` *and* `execution` are both
569
+ empty. Image-labelled children then keep their parent's route:
570
+
571
+ ```text
572
+ Vision role: no route configured, so image-labelled delegations have no dedicated model
573
+ and will simply inherit the delegating parent's route.
574
+ ```
575
+
576
+ **Not checked** — no `llm` service in this composition:
577
+
578
+ ```text
579
+ Vision role: not checked (no llm service in this composition).
580
+ ```
581
+
582
+ At boot the plugin runs the same check once and warns only for the `NO IMAGES` case, since
583
+ that is the one that fails at run time:
584
+
585
+ ```text
586
+ warn [model-manager] vision role route(s) declare no image input and image work routed to them will fail: pku-corpus/qwen3.8-flash. Point roles.vision.models at an image-capable model.
587
+ ```
588
+
589
+ `unknown` and `unresolved` are reported by `routes` but not warned about: a model with
590
+ undeclared modalities may well accept images, and an unresolvable route is already reported
591
+ by the allow-list audit.
592
+
593
+ ## Configuration
594
+
595
+ Config is the `config` of the row id `model-manager`. This bundle ships a layer that
596
+ inserts it; a profile can override it by id, and the harness also presents it on the
597
+ Settings page — `roles` and `strategy` are declared `volatile`, so the form is
598
+ auto-generated from the schema and a saved edit is committed in place without a remount. The
599
+ [card on the Plugins page](#configure-in-the-ui) writes the same paths into the same
600
+ namespace, so the YAML below and the card are two views of one config; the patch remains the
601
+ declarative copy that ships with the package.
602
+
603
+ **Saved Settings edits apply live.** The loader commits a volatile-only save and returns
604
+ *before* re-running `apply`, so the plugin listens on `loader/volatile-update` and
605
+ re-reads the config itself — including rebuilding the keyword matchers. A keyword or role
606
+ change saved on the Settings page — or from the [card on the Plugins
607
+ page](#configure-in-the-ui), which writes the same volatile namespace — takes effect on the
608
+ next request, with no restart. The
609
+ event logs `settings reloaded — mode …` on success; a value that cannot be re-read logs
610
+ `could not reload settings; routing keeps the previous config: …` and the previously
611
+ active config stays in force.
612
+
613
+ Complete key set, with the schema defaults shown in comments:
614
+
615
+ ```yaml
616
+ - id: model-manager
617
+ config:
618
+ roles:
619
+ main:
620
+ models: [] # default: [] — empty means "leave the composer/model selection alone"
621
+ pick: first # default: first; "first" | "round-robin"
622
+ note: '' # default: none — optional free text, printed by `routes` under the role
623
+ planning:
624
+ models: [] # schema default: [] (this package's own layer sets pku-corpus/qwen3.8-max-0902)
625
+ pick: first
626
+ execution:
627
+ models: [] # schema default: [] (this package's own layer sets pku-corpus/qwen3.8-flash)
628
+ pick: first
629
+ vision:
630
+ models: [] # schema default: [] — empty falls back to the execution role
631
+ pick: first
632
+ strategy:
633
+ mode: hybrid # default: hybrid; "hybrid" | "managed" | "advisory"
634
+ # visionKeywords: omitted = the 20 built-ins; any list you write replaces them
635
+ # planningKeywords: omitted = the 24 built-ins; [] DISABLES that classifier
636
+ historyLimit: 300 # default: 300; any positive value floors to at least 1
637
+ ```
638
+
639
+ The two keyword lists are shown commented out because their default is the built-in list
640
+ rather than a literal value: omitting the key keeps the built-ins, while writing any list —
641
+ including `[]` — replaces them, and `[]` switches that classifier off entirely.
642
+
643
+ Each entry of `models` is:
644
+
645
+ | Key | Required | Default | Meaning |
646
+ | --- | --- | --- | --- |
647
+ | `provider` | yes | — | Provider id, e.g. `pku-corpus`. |
648
+ | `model` | yes | — | Model id, e.g. `qwen3.8-flash`. |
649
+ | `reasoningEffort` | no | none | Applied as the route's reasoning effort when the manager writes the route. |
650
+
651
+ Behaviours of `readConfig` worth knowing:
652
+
653
+ - A route missing `provider` or `model` is dropped rather than failing the plugin. A role
654
+ whose every route is invalid behaves exactly like an empty role.
655
+ - Unknown keys are reported rather than ignored, at three levels: the row, a role, and an
656
+ individual route. A route written with the snake_case alias is called out by name —
657
+ `unknown key "roles.planning.models[].reasoning_effort" ignored — the key is
658
+ "reasoningEffort"`.
659
+ - `historyLimit` accepts any positive number, floored to an integer and raised to a
660
+ minimum of 1, so a fractional value cannot floor to 0 and silently disable usage
661
+ tracking. `0`, a negative number, a non-number or an absent key all mean 300.
662
+ - When the manager switches a request to a different route it **drops an inherited
663
+ reasoning effort** unless the role names one, because the destination model may not
664
+ accept the previous effort and `prepareCall` rejects unsupported explicit efforts
665
+ instead of clamping them.
666
+
667
+ > A profile patch entry with an `id` and no `insert` replaces the target row's fields,
668
+ > and `config` is **replaced wholesale, never deep-merged**. An override that sets only
669
+ > `strategy.mode` therefore also drops every role route. Restate every key you want to
670
+ > keep.
671
+
672
+ The bundled layer this package ships is:
673
+
674
+ ```yaml
675
+ - insert:
676
+ - id: model-manager
677
+ name: '@darkbear9494/dsh-model-manager'
678
+ config:
679
+ roles:
680
+ main:
681
+ models: []
682
+ planning:
683
+ models:
684
+ - provider: pku-corpus
685
+ model: qwen3.8-max-0902
686
+ execution:
687
+ models:
688
+ - provider: pku-corpus
689
+ model: qwen3.8-flash
690
+ vision:
691
+ models: []
692
+ strategy:
693
+ mode: hybrid
694
+ ```
695
+
696
+ ## Seeing which model each subagent used
697
+
698
+ ### First: the harness already shows this per Turn
699
+
700
+ Before reaching for the tool, note that the Web UI already attributes each completed Turn to
701
+ the exact provider/model that served it. On every completed Turn's footer there is a button
702
+ labelled **用量 {total}** ("Usage {total}", with a database icon); clicking it opens the
703
+ **本轮用量** ("Turn usage") dialog, whose rows are Uncached input, Output (with its reasoning
704
+ subset), Cached input, Cache write, Cache hit, and **Provider / model**.
705
+
706
+ Two conditions decide whether it appears:
707
+
708
+ - **Settings → General → Performance & usage** must be `detailed`, not `compact`. `detailed`
709
+ is the default. `compact` hides per-Turn usage entirely.
710
+ - Accounting is deliberately all-or-nothing. A Turn discloses usage only when the loaded
711
+ window includes `turn/start` and **every** started model attempt reported safe, exact
712
+ usage. The harness hides a partial total rather than showing a misleading one.
713
+
714
+ That second rule interacts with this plugin's failover, and it is worth understanding before
715
+ filing it as a bug: a failed attempt settles as an `assistant/attempt` event, which carries no
716
+ token usage unless its stream reported some. `deriveTurnTokenUsage` then marks the whole Turn
717
+ invalid and discloses nothing. So **on a Turn where a model failed and the manager switched to
718
+ another, the usage row will be absent** — the accounting genuinely cannot prove an exact total
719
+ for that Turn. This is the harness's own rule and it applies equally to the harness's built-in
720
+ retries; failover simply produces such Turns more often.
721
+
722
+ There is no per-model **aggregate for one whole session** in the harness itself: its session-level
723
+ projections (`tokenUsage`, `contextPressure`, `contextBreakdown`) accumulate four token buckets with
724
+ no route split. This plugin supplies exactly that, as a **Model usage** button in the session header.
725
+
726
+ It is a session projection folded from the durable log (`modelManagerUsage`), not a live counter, so
727
+ the numbers survive a restart and are identical after fork, resume, and replay. Each row shows
728
+ provider/model, uncached input, output, cached input and cache write when reported, request count,
729
+ and a total. Only attempts carrying an exact usage sample **and** a provider/model on the committed
730
+ message are counted — the same refusal the per-Turn dialog makes, so the two never disagree about
731
+ which numbers are provable.
732
+
733
+ Because the host half declares the projection and wires a view, the client half only subscribes to a
734
+ finished value: no folding in the browser, no polling, no fetch route. That is the sanctioned path —
735
+ *"a domain ships projection support with zero client code."*
736
+
737
+ ### The tool
738
+
739
+ The plugin registers one read-only tool, `model_manager`, with four actions:
740
+
741
+ | Action | Returns |
742
+ | --- | --- |
743
+ | `report` (default) | A `Top-level agents` table — session id, role, model, reason, live status, and whether the session's model was picked by hand or left at the deployment default — then the per-subagent table: child id, role, model, reason, live status, delegation label, and finally the active mode with subagent-only totals by role/model. |
744
+ | `routes` | Role table (role, `pick`, effective models, role `note`), active mode, allow-list audit with a YAML snippet for unlisted routes, the vision image-capability check, and the first 8 keywords of each list. |
745
+ | `usage` | Request and subagent counts per role/model across the whole process, including top-level turns. |
746
+ | `client` | Whether the Host composed this package's Web client half into the browser boot graph, the route serving its bundle, and the current graph revision. Use it when the settings card does not appear. |
747
+
748
+ Both `report` and `usage` read **process-local in-memory state**: they answer for the current
749
+ `dsh` process only, and a restart clears them. A subagent that finished before a restart
750
+ therefore reappears as `(not yet routed)` with role `?`, because it was re-registered on resume
751
+ but issued no request in this process. For history that survives a restart, use the per-Turn
752
+ usage dialog described above — it is derived from the durable session log.
753
+
754
+ Asking for the report:
755
+
756
+ ```text
757
+ model_manager(action: "report")
758
+ ```
759
+
760
+ Sample output, generated by running the real renderer against a mock harness instead of typed by
761
+ hand — a hand-typed example is exactly how this file shipped a misaligned table. The `session` and
762
+ `child` columns hold 10-character id prefixes:
763
+
764
+ ```text
765
+ Top-level agents — 1
766
+
767
+ session role model reason status the session model was
768
+ ----------- --------- ------------------------------- ------------------------------------------- -------- --------------------------------
769
+ a1b2c3d4-e main user-picked/glm-5.2 explicit session selection (respected) running picked by hand, so main yields
770
+
771
+ A reason ending in (respected) is the verdict itself: a human choice won and the
772
+ manager stepped back. Under managed it never does, and a session that never had
773
+ a manual pick is rewritten by the main role.
774
+
775
+ Subagent model report — 3 subagent(s)
776
+
777
+ child role model reason status label
778
+ ---------- --------- ------------------------------- ------------------------------------------- -------- --------------------
779
+ 7c1f0a92-a planning pku-corpus/qwen3.8-max-0902 applied running "plan: design the migration"
780
+ 925d4c6e-a execution pku-corpus/deepseek-v4-flash-0731 applied running "fix the typo"
781
+ e0c7b551-a vision pku-corpus/kimi-k3 applied running "vision: read this screenshot"
782
+
783
+ mode: hybrid
784
+
785
+ Subagent requests by role/model:
786
+ 1 req / 1 subagent(s) execution pku-corpus/deepseek-v4-flash-0731
787
+ 1 req / 1 subagent(s) planning pku-corpus/qwen3.8-max-0902
788
+ 1 req / 1 subagent(s) vision pku-corpus/kimi-k3
789
+ ```
790
+
791
+ Reading it:
792
+
793
+ - `e0c7b551-e` is a `vision` row served by the first vision model; with `vision: []` it
794
+ would show the execution model instead. Role and model are reported independently.
795
+ - `925d4c6e-d` was dispatched with an explicit route, so `hybrid` left it alone.
796
+ - `b84e2d10-b` issued two requests. The first was routed by the manager; on the second the
797
+ child's own header already carried the applied route, so it reads
798
+ `applied (manager-owned)` rather than being mistaken for an explicit choice. Hence the
799
+ planning total of `3 req / 2 subagent(s)`.
800
+ - `0a1b2c3d-f` has no resolvable delegating parent and no manager-applied route, so
801
+ `hybrid` failed closed: the child kept the route it was given, and with it no label the
802
+ catalog could resolve.
803
+ - The totals are **subagent-only**, so the top-level turn this parent made is not counted
804
+ here. `usage` is the action that covers the whole process.
805
+
806
+ The `status` column is the child's live status as the harness reports it (`running`,
807
+ `idle`, …), `live` when the harness exposes the agent without a status, and `inactive`
808
+ when `agents.get` cannot resolve the child — for example after it has gone away.
809
+
810
+ The `reason` column is the outcome for that request:
811
+
812
+ | Reason | Meaning |
813
+ | --- | --- |
814
+ | `applied` | The role route was written into the request. |
815
+ | `applied (manager-owned)` | The child's route matched what the manager last applied to it, so it stayed under management and the role route was written again. |
816
+ | `explicit session selection (respected)` | `hybrid`, top-level: the session log carries a `model/selection` event, so the model running is one a person chose in the composer. `main` is skipped and the rotation is not advanced. |
817
+ | `explicit child route (respected)` | `hybrid` found the child's resolved route differed from the parent's effective route, so it was treated as the delegating agent's own choice and left alone. |
818
+ | `lineage unresolved (child route respected)` | No delegating parent could be resolved and the child was not manager-owned, so inheritance was not provable and the child kept its route. |
819
+ | `advisory (not applied)` | `advisory` mode classified the request but changed nothing; the model shown is the one actually used. |
820
+ | `passthrough (role unconfigured)` | The role resolved to no route at all, so the request was returned unchanged. |
821
+
822
+ Verbatim example rows for the two reasons not shown above:
823
+
824
+ ```text
825
+ 99aa11bb-0 execution pku-corpus/qwen3.8-max advisory (not applied) running "fix the typo"
826
+ 4d5e6f70-0 execution pku-corpus/qwen3.8-max passthrough (role unconfigured) running "fix the typo in README"
827
+ ```
828
+
829
+ A subagent the catalog knows about but which has not issued a request yet shows
830
+ `(not yet routed)` in the model column and `-` as its reason. Labels are collapsed to a
831
+ single line, truncated at 42 characters, and any `"` in them is displayed as `'` so the
832
+ column can never be misread.
833
+
834
+ `usage` counts every request the process recorded, including top-level turns — its header
835
+ says so, and a top-level bucket shows `0 subagent(s)`:
836
+
837
+ ```text
838
+ Requests by role/model (whole process, including top-level turns)
839
+
840
+ 1 req 1 subagent(s) execution pku-corpus/deepseek-v4-flash-0731
841
+ 1 req 1 subagent(s) execution pku-corpus/qwen3.8-flash
842
+ 1 req 1 subagent(s) execution pku-corpus/qwen3.8-max
843
+ 1 req 0 subagent(s) main pku-corpus/qwen3.8-max
844
+ 3 req 2 subagent(s) planning pku-corpus/qwen3.8-max-0902
845
+ 1 req 1 subagent(s) vision pku-corpus/kimi-k3
846
+ ```
847
+
848
+ ## The allow-list gotcha
849
+
850
+ The profile's `subagent-model-selection-settings` row (`.allowedModels`) constrains what
851
+ an agent may **name**. `assertAllowedModelSelection` in the subagent tool returns early
852
+ when the delegation call names no `provider`, `model` or `reasoning_effort`, so:
853
+
854
+ - **Role routing is not blocked by the allow-list.** The manager rewrites *inherited*
855
+ delegations at request time, and an inherited delegation names nothing, so a route
856
+ outside the list still serves it.
857
+ - What the list does affect: an agent that **explicitly** names a route outside it is
858
+ refused at delegation time with an error of the form
859
+ `child LLM route "pku-corpus/qwen3.8-max-0902" is not allowed for this Session`, and that
860
+ route is absent from what `list_subagent_models` advertises — so the model is invisible
861
+ to agents even while the manager uses it.
862
+
863
+ Two further properties matter in practice:
864
+
865
+ - The list is sampled per Session when the session receives its delegation tools, so a
866
+ session started before you edited it keeps the old list until the session is recreated.
867
+ - With `enabled: false`, no subagent can select a model at all. `routes` says so
868
+ explicitly when it detects that state.
869
+
870
+ The plugin cannot fix the list for you. Inserting a second `subagent-model-selection-settings`
871
+ row would abort startup with `duplicate loader entry id`, so the plugin only reads it. If
872
+ any role's **effective** route is unlisted — including a `vision` → `execution` fallback —
873
+ it logs a warning at boot naming the routes, and `routes` renders the audit plus the exact
874
+ YAML to add. Unlisted routes are de-duplicated, one snippet entry each:
875
+
876
+ ```text
877
+ model_manager(action: "routes")
878
+ ```
879
+
880
+ ```text
881
+ Model manager roles
882
+
883
+ Role pick effective model(s)
884
+ ------------ ------------ ------------------------------------------
885
+ main first (unconfigured — passes through)
886
+ planning first pku-corpus/qwen3.8-max-0902
887
+ note: use for architecture and migration design
888
+ execution first pku-corpus/qwen3.8-flash
889
+ vision first pku-corpus/kimi-k3, pku-corpus/qwen3.8-flash, pku-corpus/mystery, pku-corpus/broken
890
+
891
+ Strategy mode: hybrid (apply when the child inherited the parent route)
892
+
893
+ Allow-list: enabled, 4 route(s) currently dispatchable
894
+ allowed planning pku-corpus/qwen3.8-max-0902
895
+ allowed execution pku-corpus/qwen3.8-flash
896
+ allowed vision pku-corpus/kimi-k3
897
+ allowed vision pku-corpus/qwen3.8-flash
898
+ BLOCKED vision pku-corpus/mystery
899
+ BLOCKED vision pku-corpus/broken
900
+
901
+ 2 role route(s) are not in the subagent allow-list.
902
+ This does NOT block role routing: the harness gates only *explicit* model-facing
903
+ choices, and the manager routes pure-inheritance delegations at request time. What
904
+ it does affect: an agent that names one of these routes explicitly will be refused,
905
+ and the route will not appear in `list_subagent_models`. Add them to
906
+ `subagent-model-selection-settings` (`.allowedModels`) — in the profile patch, or on
907
+ the Subagent settings page — to make them selectable:
908
+
909
+ - provider: pku-corpus
910
+ model: mystery
911
+ - provider: pku-corpus
912
+ model: broken
913
+
914
+ Vision role (image capability):
915
+ ok pku-corpus/kimi-k3 — accepts images
916
+ NO IMAGES pku-corpus/qwen3.8-flash — declares text — image work routed here will fail
917
+ unknown pku-corpus/mystery — image support not declared
918
+ unresolved pku-corpus/broken — could not resolve (no adapter registered for provider "pku-corpus")
919
+
920
+ Delegation labels select the tier. The `description` you pass to a delegation
921
+ becomes the child label, which the manager matches against (word-anchored):
922
+ vision : vision, visual, image, images, screenshot, screen shot, ocr, figure, …
923
+ planning : plan, planning, design, architect, architecture, analyse, analyze, analysis, …
924
+ else : execution
925
+ ```
926
+
927
+ When nothing is missing the audit says so, and the role table marks a fallback
928
+ `(via execution)` while the audit row is labelled with the role that uses it:
929
+
930
+ ```text
931
+ Allow-list: enabled, 2 route(s) currently dispatchable
932
+ allowed planning pku-corpus/qwen3.8-max-0902
933
+ allowed execution pku-corpus/qwen3.8-flash
934
+ allowed vision pku-corpus/qwen3.8-flash
935
+ All role routes are allow-listed.
936
+ ```
937
+
938
+ To add a route, paste the snippet under `allowedModels:` in the profile patch, restating
939
+ the whole config because an id override replaces `config` wholesale:
940
+
941
+ ```yaml
942
+ - id: subagent-model-selection-settings
943
+ config:
944
+ enabled: true
945
+ allowedModels:
946
+ - provider: pku-corpus
947
+ model: qwen3.8-flash
948
+ - provider: pku-corpus
949
+ model: qwen3.8-max-0902 # a route the audit reported
950
+ - provider: pku-corpus
951
+ model: deepseek-v4-flash-0731
952
+ ```
953
+
954
+ ### When the audit cannot read the list
955
+
956
+ `routes` distinguishes three outcomes, because they call for different fixes.
957
+
958
+ **No such service** in this composition — a missing feature, not a mistake:
959
+
960
+ ```text
961
+ Allow-list: unavailable (no subagent model-selection settings service in this composition).
962
+ ```
963
+
964
+ **Model selection is disabled** — subagents cannot choose a model at all:
965
+
966
+ ```text
967
+ Allow-list: model selection is DISABLED — subagents cannot select a model at all.
968
+ ```
969
+
970
+ **The settings owner refused to report** — a configuration error, not a missing feature.
971
+ Its `current()` throws when selection is enabled with an empty `allowedModels`, which is a
972
+ broken deployment that every delegation would hit:
973
+
974
+ ```text
975
+ Allow-list: the subagent model-selection settings refused to report its routes:
976
+ enabled subagent model selection requires at least one allowed model
977
+ Fix `subagent-model-selection-settings` in the profile patch (an enabled policy needs a
978
+ non-empty `allowedModels`), then reload.
979
+ ```
980
+
981
+ The same refusal is logged at boot as
982
+ `subagent model-selection settings refused to report its routes: <error>`, so it is not
983
+ mistaken for a normal "no routes listed" state.
984
+
985
+ ## Tuning the classification
986
+
987
+ `strategy.visionKeywords` and `strategy.planningKeywords` are the whole classification
988
+ policy.
989
+
990
+ - **An absent key uses the built-ins. An explicit `[]` disables that classifier.** That
991
+ is the only way to switch one off: `visionKeywords: []` sends every vision word to the
992
+ planning and execution tests instead. Treat a disabled classifier as intentional —
993
+ with `planning: []` the planning role becomes unreachable for subagents, and with
994
+ `vision: []` no subagent is ever classified `vision`.
995
+ - **Matching is case-insensitive and anchored at a leading word boundary.** A keyword must
996
+ begin at the start of a word, so `spec` no longer matches `"inspect"` and `design` no
997
+ longer matches `"redesign"`, while `screenshot` still matches `"screenshots"` and the
998
+ multi-word `ui mock` still matches. It is not a full-word match, so `plan` still matches
999
+ `"planet"` and `render` still matches `"rendering"`. Prefer distinctive words.
1000
+ - Vision is tested before planning, so a label matching both goes to vision.
1001
+ - Regex metacharacters in a keyword are escaped, so `pkg.io` or `a+b` match literally.
1002
+ - The matchers are rebuilt on a saved Settings edit, so a keyword change applies live.
1003
+
1004
+ The built-in lists, used when a keyword list is absent:
1005
+
1006
+ ```text
1007
+ vision (20): vision, visual, image, images, screenshot, screen shot, ocr, figure,
1008
+ diagram, chart, plot, photo, picture, png, jpg, jpeg, webp, gif,
1009
+ ui mock, render
1010
+ planning (24): plan, planning, design, architect, architecture, analyse, analyze,
1011
+ analysis, research, investigate, review, critique, strategy, reasoning,
1012
+ reason, compare, evaluate, assess, spec, specification, decompose,
1013
+ breakdown, proposal, root cause
1014
+ ```
1015
+
1016
+ `routes` prints the first 8 entries of each list, appending `…` only when there are more,
1017
+ and prints `(disabled)` for an explicitly emptied list:
1018
+
1019
+ ```text
1020
+ Delegation labels select the tier. The `description` you pass to a delegation
1021
+ becomes the child label, which the manager matches against (word-anchored):
1022
+ vision : vision, visual, image, images, screenshot, screen shot, ocr, figure, …
1023
+ planning : (disabled)
1024
+ else : execution
1025
+ ```
1026
+
1027
+ Replace a list with the keywords you want, remembering that a patch override replaces
1028
+ `config` wholesale:
1029
+
1030
+ ```yaml
1031
+ - id: model-manager
1032
+ config:
1033
+ roles:
1034
+ planning:
1035
+ models:
1036
+ - provider: pku-corpus
1037
+ model: qwen3.8-max-0902
1038
+ execution:
1039
+ models:
1040
+ - provider: pku-corpus
1041
+ model: qwen3.8-flash
1042
+ strategy:
1043
+ mode: hybrid
1044
+ planningKeywords: # replaces the 24 built-ins entirely
1045
+ - plan
1046
+ - design
1047
+ - audit
1048
+ - benchmark
1049
+ visionKeywords: [] # disables the vision classifier
1050
+ ```
1051
+
1052
+ The plugin also contributes a system-prompt section (name `model-manager`, order 60) that
1053
+ tells the delegating agent to start a delegation description with `plan:` for reasoning
1054
+ work, `vision:` for image work, or leave it plain for execution, and lists each role's
1055
+ effective models (including a fallback). It is empty text when no role has any models, so
1056
+ the prompt is not padded with a description of routing that does nothing.
1057
+
1058
+ ## How it stays safe
1059
+
1060
+ Both halves obey the same rule: neither may be able to break the harness it is loaded into.
1061
+ A host `apply` that throws fails the loader entry and therefore startup, and a client
1062
+ component that throws blanks its whole slot entry, so every risky path is probed and
1063
+ degrades to a notice or a log line.
1064
+
1065
+ - **Its own schema dependency cannot fail startup.** `@deepseek-ai/schemastery` is loaded
1066
+ through a guarded dynamic import and the schema is built inside a guard. If the
1067
+ dependency is missing *or incompatible* (a version whose `.default()` / `.volatile()`
1068
+ chain differs), the plugin still loads and still routes: `Config` is left undefined, so
1069
+ cordis's `resolveConfig` passes the raw config straight through and `readConfig`
1070
+ normalizes it defensively. Only schema validation and the auto-generated Settings page
1071
+ are skipped.
1072
+ - **No settings API.** `settings.installSection` / `installSettingsSection` /
1073
+ `settingsNamespace` were removed in DSH 0.1.7, and calling them fails `apply`, which
1074
+ fails the loader entry and therefore startup. The host half never touches that API: it
1075
+ exports a volatile `Config` and lets the harness auto-generate the Settings form
1076
+ (`autoGenerate` defaults to true). It claims no settings namespace either — and neither
1077
+ does the client half, which writes the row's *existing* namespace through the `form` the
1078
+ plugins page hands it, so the card cannot register a second store or race the host.
1079
+ - **The host half imports nothing but its own schema dependency.** It does not import
1080
+ `@deepseek-ai/dsh-tools`, `dsh-llm` or `cordis`, which are not resolvable from a
1081
+ profile-installed plugin; the tool is registered in the normalized shape the registry
1082
+ expects, using plain JSON Schema, and the `llm` service is reached through
1083
+ `ctx.get('llm')` rather than an import.
1084
+ - **The client half requires one module: `react`.** Harness Client packages — including
1085
+ `@deepseek-ai/dsh-client-ui-primitives` — are not `require`d from a hand-written client
1086
+ half, so the controls are local and styled with `--dsw-alias-*` tokens only. Its
1087
+ collaborators (`slots`, `locale`, `remote`) arrive as injected services, and each use of
1088
+ them sits inside a `safely(label, fn)` wrapper that logs
1089
+ `[model-manager] <step>: <message>` and continues: a missing locale seat, a failed
1090
+ catalog fetch, a rejected subscription or an absent slot registry leaves the card
1091
+ unreadable, never fatal. Every value read from the host is re-narrowed before use
1092
+ (`isObject` guards on `form.state.value`, `roles`, each catalog group and route), so a
1093
+ shape change degrades to "unset" rather than a render error.
1094
+ - **Every optional integration is probed and wrapped.** Plan mode, the agent list and
1095
+ lineage, the parent's request header, subagent listing, the allow-list service, the
1096
+ model-capability lookup, `tools` and `systemPrompt` are each reached through a guarded
1097
+ accessor and a `try`/`catch`; a missing service means that feature is inert, not that the
1098
+ plugin fails. The `agent/request` handler catches its own errors, logs one warning
1099
+ (`routing skipped for one request: …`) and returns the request it was given, unchanged.
1100
+ - **`apply` never throws.** The whole body sits behind a backstop that logs
1101
+ `failed to initialise; model routing is disabled: …` and returns, so a misconfiguration
1102
+ degrades routing instead of preventing the harness from booting. Malformed configs
1103
+ (`roles: "not-an-object"`, `strategy: null`, an unknown mode, a negative `historyLimit`,
1104
+ routes with empty ids) all apply cleanly; bad routes are filtered out and the mode falls
1105
+ back to `hybrid`.
1106
+ - **A bad live edit cannot break a running router.** The `loader/volatile-update` handler
1107
+ is wrapped: a config it cannot re-read logs
1108
+ `could not reload settings; routing keeps the previous config: …` and the previous
1109
+ config stays in force. The boot capability check is an async probe with its own catch, so
1110
+ a slow or failing `llm` service cannot disturb startup.
1111
+ - **Typos are reported, not silently ignored.** Schemastery does not reject unknown keys,
1112
+ so `readConfig` returns a `warnings` array and `apply` logs each entry at warn level:
1113
+ `unknown config key "bogus" ignored`, `unknown role "nope" ignored`,
1114
+ `unknown key "roles.planning.mispelled" ignored`, `unknown key "strategy.nope" ignored`,
1115
+ and the route-level form with its `reasoningEffort` hint.
1116
+ - **The pure helpers are exported for testing:** `name`, `Config`, `apply` plus
1117
+ `readConfig`, `applyRoute`, `effectiveRouteOf` and the two default keyword lists.
1118
+ - **It does not touch the subagent allow-list row**, precisely to avoid the duplicate
1119
+ loader entry id that would abort startup.
1120
+ - **The `model_manager` tool is read-only.** Its description says so and the
1121
+ implementation only reads state.
1122
+
1123
+ ## Testing
1124
+
1125
+ ```bash
1126
+ npm test
1127
+ ```
1128
+
1129
+ Runs eight suites in child processes and aggregates the result — **683 assertions** at the time
1130
+ of writing. Each suite also runs on its own: `node test/<name>.test.mjs`.
1131
+
1132
+ | Suite | Assertions | What it pins |
1133
+ | --- | --- | --- |
1134
+ | `packaging.test.mjs` | 31 | The package identity that nothing else cross-checks: the scoped name is the one string the bundle patch's loader row, the client half's module id and the host half's `PACKAGE_NAME` must all agree on, while the cordis row id, the client row namespace and the locale namespace must all *stay* unscoped. Plus publishability (not private, public access, a real `@deepseek-ai/dsh` version gate, schemastery still optional) and tarball completeness — every `exports` target and every `files` pattern resolved against disk, so a published package cannot mount-less. The gate is not string-matched: a self-validating semver comparator (prerelease-aware, and checked against the ordering trap first) proves the declared range admits 0.1.7-rc.2, 0.2.0-rc.2 **and** 0.2.0 while refusing 0.1.6 and 0.3.0 — because `<0.2.0` reads as "every 0.2.0 prerelease" while excluding 0.2.0 itself. Each identity assertion was mutation-checked: breaking any one of the four name sites, or "tidying" the row id or locale namespace to match, fails exactly one assertion; reverting the upper bound to `<0.2.0` fails exactly two. |
1135
+ | `routing.test.mjs` | 9 | The four roles route as documented; label classification; an explicit child route is respected; the tool and system-prompt section register; `apply` survives malformed configs. |
1136
+ | `edge.test.mjs` | 503 | Hostile configs, keyword anchoring and trimming, explicit-`[]`-disables versus absent-uses-defaults, round-robin committing only on apply, LRU eviction, the manager-owned rule, volatile settings reload, every `reason` string, the report/usage/routes output, and the generated allow-list YAML round-tripped through the **real** harness validator. |
1137
+ | `failover.test.mjs` | 24 | The failover chain and every guard: it walks to the end of the list and then stops rather than wrapping; `ABORTED`, `INVALID_REQUEST` and `IMAGE_OFFLOAD_REQUIRED` never fail over; a downstream recovery decision is passed through untouched; the per-step cap holds and resets on a new step; `round-robin` does wrap; single-model and disabled roles do nothing; a route outside the role's list is left alone; hostile payloads never throw; subagent chains fail over too. |
1138
+ | `client-structure.test.mjs` | 32 | The client half loads through `window.__ModuleLoader__`, requires **only** `react`, exports `{ inject, apply }`, registers its locale dictionaries and exactly two surfaces, and — because the check mirrors the real `SlotCore.register` validation — fails if a registration ever loses its `name`. It also declares each `remote.<namespace>` used must appear in `inject`, drives the settings-form bindings, and renders the usage surface against a stubbed projection face in both its collapsed and expanded states, with an empty-projection case proving those render assertions are not vacuous. |
1139
+ | `client-diagnostic.test.mjs` | 17 | Every branch of `model_manager` with `action: "client"`, including the two that matter most: a bundle the Host will not serve, and a bundle that serves but registers the wrong id. |
1140
+ | `usage-projection.test.mjs` | 42 | The per-session model-usage fold: bucket sums against the harness's own field names, refusal of unsafe or fractional counts without aborting the fold, usage recovered from an embedded stream, separate attribution per provider/model, immutable state transitions, reference stability that suppresses republishing, and both schemas rejecting junk through the only method cordis calls (`.parse`). |
1141
+ | `explicit-selection.test.mjs` | 25 | The rule that `main` yields to a hand-picked session model, and nothing else does: respected under `hybrid`, still applied under `managed`, untouched by a respected call in the round-robin rotation, and falling back to the old rewriting behaviour when the projection service is absent, when `stateOf` throws, or when the key was never registered. A disabled manager is checked too. Plus the `Top-level agents` report table: the hand-picked versus default-driven verdict, no orphaned subagent header when no subagent exists, a row that outlives its agent degrading to `unknown, agent no longer live`, and — read back out of the renderer's own source — proof that the reason column is still padded past the longest reason string it can print. |
1142
+
1143
+ The suites are plain Node scripts — no test framework, and no dependency beyond Node itself.
1144
+
1145
+ Two of them optionally pin their expectations against the **real** harness internals rather
1146
+ than a transcription of them: `dsh-subagent`'s `resolveChildAgentOptions` (what a delegated
1147
+ child actually inherits) and `SubagentModelSelectionConfig.current` (the allow-list gate that
1148
+ rejects a repeated route). `test/paths.mjs` discovers the DSH installation from the `dsh`
1149
+ executable on `PATH`, or from `DSH_INSTALL_DIR` if you set it. When neither resolves, those
1150
+ assertions fall back to a local re-implementation and print a `WARN` — the suite still passes,
1151
+ but it is then testing my model of the harness rather than the harness, so prefer running it
1152
+ where `dsh` is installed.
1153
+
1154
+ Nothing in the suite touches the network, a profile, or a running harness, and nothing writes
1155
+ outside the repository.
1156
+
1157
+ ## Limitations
1158
+
1159
+ - **Classification is label-driven, not content-driven.** At `agent/request` time the
1160
+ plugin has no supported way to read a child's message blocks, so it matches the child's
1161
+ delegation label and nothing else. Image detection is therefore label-based: a
1162
+ delegation about an image whose `description` contains no vision keyword is classified
1163
+ `execution`.
1164
+ - **Leading-boundary matching still matches word prefixes** (`plan` in `"planet"`,
1165
+ `render` in `"rendering"`), and the first match wins with vision tested before planning.
1166
+ Two classifier lists cannot express precedence beyond that.
1167
+ - **`hybrid` compares routes by value.** A child that deliberately names the same route as
1168
+ the parent's effective route is indistinguishable from one that inherited it, and will
1169
+ be rewritten to the role route.
1170
+ - **Under `hybrid`, an unresolved lineage means the child keeps its own route.** The
1171
+ manager will not touch a delegation whose inheritance it cannot prove; if you want
1172
+ routing regardless of lineage, use `managed`. The report shows
1173
+ `lineage unresolved (child route respected)` for those requests, so a broken lineage
1174
+ integration is visible rather than silent — but it does also mean a child that should
1175
+ have been managed was not.
1176
+ - **Manager-ownership is sticky.** Once a route has been applied to a child, that child
1177
+ keeps being managed as long as its route matches the applied one, even after its parent
1178
+ is gone. If a child legitimately changes its own model to one the parent also uses, the
1179
+ manager takes it back.
1180
+ - **`round-robin` is per-process and per-role.** Counters live in an in-memory `Map` and
1181
+ reset to index 0 on restart. A role with a single model never advances, and an advance is
1182
+ committed only when a route is applied, so `advisory` passes and both kinds of respected
1183
+ route do not rotate. Routing happens per LLM request, not per turn, so a `round-robin`
1184
+ role can still rotate models between the steps of one turn.
1185
+ - **Usage history is in-process.** A `Map` capped at `strategy.historyLimit` (300),
1186
+ evicted least-recently-used: an active subagent stays, an idle one goes first. Nothing is
1187
+ persisted, so after a restart `report` and `usage` start empty.
1188
+ - **`report` lists top-level rows but its totals stay subagent-only.** The `Top-level agents`
1189
+ table covers every session this process saw a request for, top-level or not; the
1190
+ `Subagent requests by role/model:` block beneath it counts subagents only. `usage` counts the
1191
+ whole process, including top-level `main`/`planning` turns (shown as `0 subagent(s)`). So the
1192
+ two tables inside `report` answer for different populations, and neither one matches `usage`.
1193
+ - **The `status` column needs the live agent list.** It is the status the harness reports,
1194
+ `live` when a live agent exposes no status, and `inactive` when `agents.get` cannot
1195
+ resolve the child. If the `agents` service is unavailable or has no `get`, every row
1196
+ reads `inactive` whether or not the subagent is alive.
1197
+ - **The image-capability check covers only the vision role's effective models.** A planning
1198
+ or execution child handed an image is not checked, `unknown` and `unresolved` verdicts are
1199
+ reported but never warned about at boot, and with the bundled default (`vision: []`) the
1200
+ check audits the execution fallback rather than a dedicated vision model.
1201
+ - **The allow-list audit is informational for routing.** Since the harness gates only
1202
+ explicit choices, a `BLOCKED` row does not mean role routing failed — it means agents
1203
+ cannot name that route and `list_subagent_models` will not show it.
1204
+ - **The `child` column is a 10-character id prefix**, so two session ids sharing their
1205
+ first 10 characters are indistinguishable in the table.
1206
+ - **Labels are flattened for display.** Newlines collapse to spaces, the text is truncated
1207
+ at 42 characters with `…`, and `"` becomes `'`.
1208
+ - **`roles.<role>.note` affects only the `routes` table.** It is human annotation; no
1209
+ routing decision, report or count reads it, and the boot log does not print it.
1210
+ - **`main` empty is the simplest policy, and now not the only one.** With `main: []` a
1211
+ top-level turn outside plan mode is never rewritten. With `main` configured under
1212
+ `hybrid`, a session whose model was picked by hand keeps it (see "`main` and the composer's
1213
+ model picker") and only untouched sessions are rewritten; under `managed` every top-level
1214
+ request is rewritten, chosen by hand or not.
1215
+ - **The card can only pick what the catalog advertises.** A route the catalog stopped returning keeps its row and stays editable, labelled `(not advertised)`, but you cannot add such a route — or any model absent from the catalog — from the UI. Provider and model are never free text here, so a typo cannot be written into the config; use the patch layer for a route the host does not advertise.
1216
+ - **The card has no image-capability information.** `session/modelCatalog` exposes ids,
1217
+ names and reasoning efforts, not modalities, so nothing in the UI stops you picking a
1218
+ text-only model for `vision`; the host half's `routes` audit is the check.
1219
+ - **A stored effort can be invisible.** Picking a different model keeps the route's previous
1220
+ `reasoningEffort`, and the effort picker only renders when the newly selected model
1221
+ advertises efforts — so a stale effort can remain in the config with no control to clear
1222
+ it. Remove it in the patch layer.
1223
+ - **The card lives in exactly one place: 设置.** It registers `settings.section` under
1224
+ `model-manager`, and nothing on the Plugins page — `plugins.item` and `plugins.row.config` are
1225
+ deliberately not registered, so there is one copy of these values and one place to edit them.
1226
+ The second surface, `conversation.session.header.utilities` under `model-manager-usage`, is
1227
+ read-only: it shows the per-session model usage the host half folds from the durable log, and
1228
+ writes nothing.
1229
+ - **The card needs one restart after installing**, because the client-module boot manifest
1230
+ caches package metadata per loader specifier until restart. Before that the Settings entry is
1231
+ simply absent.