dsh-subagent-default-model 2.0.7 → 2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,70 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.0 (2026-10-01)
4
+
5
+ ### Added
6
+
7
+ - **子代理现在知道自己跑在哪个供应商/模型上(真实提示词注入,功能三通路二)**。此前功能三只有**界面行**——轨迹视图与对话视图会渲染「当前供应商/模型」,但那只是**画给用户看的**,**不进入模型上下文**,因此子代理**无法回答**「你现在用的什么模型」。本版新增一条**真正的提示词注入**:向子代理**自己的上下文**写入一行,内容形如
8
+ `[dsh-subagent-default-model] You are running as a subagent on workbuddy/deepseek-v4.1-flash (provider=workbuddy, model=deepseek-v4.1-flash). If asked which model or provider you are, answer with this route.`
9
+ 实现要点:
10
+ - **取值来源是「结算后的真实路由」**:注入内容取自 `agent/request` 瀑布 **`await next()` 之后**返回的 `{provider, model}`,即**包含本插件自身故障转移改写结果在内**的最终值。这一点是可验证的关键差异——用「插件打算切到哪个模型」当来源会在切换后写出与实际不符的一行,回归用例(把来源替换成硬编码路由)当场失败 3 项。
11
+ - **注入时机是下一步的 `agent/pre-step`**:这是仍能修改「即将执行的那一步」消息列表的接缝(宿主自带的 `dsh-agent-instructions` 用的同一接缝)。`agent/request` 阶段消息已冻结,故采用「请求阶段缓存 → 下一步注入」两步式。
12
+ - **去重与替换**:路由未变则不重复注入;路由变化(故障转移切换 / 配置变更)则**移除旧行再写新行**,长时间运行不会堆积重复行。
13
+ - **仅对子代理生效**:与故障转移同一道 `agent.session.header.origin === "subagent"` 门禁,**主代理上下文永不被触碰**。该门禁在 `agent/request` 与 `agent/pre-step` **两条瀑布上都必须存在**,并新增静态护栏用例钉住(变异验证:仅删 pre-step 侧门禁会因缓存未被写入而「静默不注入」,单靠行为用例抓不到,故补静态断言)。
14
+ - **消息来源合规**:`source.kind` 使用生产者自有标识 `plugin:dsh-subagent-default-model` 并带 `form: "route-context"` 标记。会话格式 v4 通过 `assertV4MessageSources` 硬校验,裸 `{kind:"plugin"}` 包装会导致**整个会话拒绝加载**,故有专项用例断言该形状。
15
+ - **可关闭**:新增配置项 `injectRouteContext`(boolean,**默认 `true`**),设置卡片新增「把当前模型与供应商写进子代理上下文」勾选项及中英文案。默认开启的理由:不开则子代理仍无法回答自身路由,而这正是本功能的目的。
16
+ - **新增依赖声明**:注入需要 `createUserMessage`,故新增 peer `@deepseek-ai/dsh-llm`(`>=0.1.7-rc.1 <0.3.0-0`,与其余 8 个 peer 同区间)。已验证宿主侧(profile 目录)与该包一致解析同一实例。
17
+
18
+ - **`plugin/test/route-context.test.mjs`:注入行为的 12 项回归用例**。以 `dsh-agent-loop` 的真实 `Inbox` 语义驱动(`prepend(target,message)` / `remove(messageId)` / `nextStep` 为 getter),覆盖:注入到达子代理上下文、报告**结算后**的路由(被后续 listener 改写仍以最终值为准)、主代理不被注入(含多步)、路由变化**替换**而非堆积、路由不变不重复、开关关闭即停止注入、缺省即为开启、`source` 形状合规(生产者自有 + form 标记)、不干扰循环自身消息、未解析出路由时不写占位行、销毁后不再注入。
19
+
20
+ - **真实宿主对象的一次性集成验证**:以 `@deepseek-ai/cordis` 真实 `Context` + 真实 `createUserMessage` + 真实两条瀑布跑通,打印出子代理实际收到的那一行与 `source`,确认 `role: "user"`、`source.kind` 与 `form` 均符合预期。(该验证同时纠正了一处测试夹具错误:`inbox.nextStep` 在宿主中是 **getter**,早期夹具用普通属性写,导致夹具与真实契约不符。)
21
+
22
+ ### Changed
23
+
24
+ - **文档口径修正(中/英、README 四处 + 市场描述)**:功能三由「界面行,**不**注入提示词」改为**两条独立通路的准确描述**——通路一(界面行,给用户)与通路二(提示词注入,给子代理),并明确**两者互不替代**。此前的措辞会让读者(以及模型自己)误以为子代理知道自己的模型,与实际行为不符。
25
+ - **写明与宿主 `{{model}}` 变量的关系**:DSH 宿主 `system-prompt` 行的 persona 已能把 `{{model}}` 解析进提示词(`You are a coding agent powered by the {{model}} model.`,变量由 `dsh-agent-loop` 按 `context.agent.options` 注册),但**只覆盖 `model`、不含 `provider`**,且取派发时 `options` 的值。本插件注入**额外给出 provider**,并以请求级结算值为准(含故障转移),故两者互补而非重复。该结论已逐行核对宿主源码后写入文档。
26
+ - **`settings-install` / `settings-write-gate` 两处契约同步扩充**:字段数由六增至七(`injectRouteContext`),原子保存用例与描述符可见性断言同步更新——这两处是**刻意的契约钉子**,新增字段必须显式改它们,避免字段被静默丢弃。
27
+
28
+ ### Fixed
29
+
30
+ - **CHANGELOG 2.0.8 条目中的锁文件同步说明**,本版同步 `package-lock.json` 根条目版本至 2.1.0 并纳入新增 peer `@deepseek-ai/dsh-llm`。
31
+
32
+ ## 2.0.8 (2026-09-29)
33
+
34
+ ### Fixed
35
+
36
+ - **P0:peer 上界 `<0.2.0` 会在 DSH 0.2.0 正式版发布时把整个 bundle 摘掉**。宿主校验 peer **不用默认 semver 选项**:`@deepseek-ai/dsh-app-boot` 执行的是
37
+ `semver.satisfies(runtimeVersion, range, { includePrerelease: true })`。该选项**关闭 prerelease 元组规则**,于是 `<0.2.0` 的实际行为与直觉相反——它**放进** `0.2.0-rc.1`,却**拒绝**正式的 `0.2.0`。后果不是降级运行:`loadProfileDirectory()` 对不兼容 bundle 直接抛错,bundle 落入 `skippedBundles`,启动时 stderr 打印 `skipping profile bundle "dsh-subagent-default-model"`,**插件本体与设置卡片一起消失**。
38
+ 修复:8 个 `@deepseek-ai/*` peer 统一改为 **`>=0.1.7-rc.1 <0.3.0-0`**——放行 0.1.7 线及其后的整个 0.2.x 线(prerelease 与正式版都收),并用 `-0` 后缀挡住 `0.3.0-rc.1`(否则裸 `<0.3.0` 会在 `includePrerelease` 下放它进来,把支持面悄悄扩到未经验证的一行)。
39
+ 用上游**真实门禁函数** `evaluatePluginCompatibility` 验收:改前 `0.1.7-rc.1/rc.2/0.2.0-rc.1` 通过而 `0.2.0`/`0.2.1` 被拒(8 个 peer 全不满足);改后 `0.1.7-rc.1 … 0.2.1` 全部通过,`0.3.0-rc.1`/`0.3.0` 被拒。
40
+
41
+ - **回归护栏本身有缺陷:`peer-range.test.mjs` 以裸 semver 语义断言,因此给的是假安全感**。旧测试手写模拟了 prerelease 元组规则并**恒开**,即**恰好漏掉了宿主真实使用的 `includePrerelease` 选项**,于是它断言「`0.2.0-rc.1` 必须被拒绝」——与宿主实际行为**完全相反**,且在该断言下全绿,掩盖了上面那条 P0。
42
+ 修复:护栏改为**调用真实 `semver` 包**(`{ includePrerelease: true }`——宿主同款选项),并显式保留两条反向断言(旧 `<0.2.0` 上界放进 `0.2.0-rc.1`、拒绝 `0.2.0`),任何人重新引入裸 `<0.2.0` 都会立刻变红(已实测:把旧区间写回去,该文件 10 项中 2 项失败)。
43
+ 手写回退实现(`semver` 解析不到时的降级路径)同步修正,并新增与真实 semver 的**交叉验证**——该验证当场抓出回退实现自身的两个真缺陷:`^`/`~` 运算符被正则漏掉而恒判 `false`。现回退只实现声明的 `>= > < <= =` 语法(136 项对照零不一致),遇到 `^` / `~` / x-range **抛错而非静默返回 `false`**——"自信地答错"正是旧护栏的病根。
44
+ **关于 `semver` 的定位(一处刻意设计)**:`semver` **不是**本插件的声明依赖,它只经由 npm 的 peer 自动安装链进入依赖树(root devDep `dsh-settings` → `dsh-config-editor` → peer `dsh-app-boot` → dep `semver`)。把 CI 判定挂在未声明的传递依赖上,会在 npm 改变 peer 解析的那天连带弄坏构建,而本仓的既有约定(`dependency-integrity.test.mjs`)是测试必须自洽。因此 `semver` 只作**可选的高保真交叉验证**:在场时用它校验回退实现,缺席时打印一行 `# note:` 跳过,断言本身仍由回退实现承担——而回退实现的可信度来自它自己的语义钉子(`HOST's includePrerelease semantics` 一条,直接钉住两条反向判定,不依赖 `semver`)。两条路径都已实测:有 `semver` 时 10/10 通过;隐藏 `node_modules/semver` 后同样 10/10 通过且打印跳过说明;在**无 semver** 状态下把旧区间写回,仍有 2 项失败。
45
+
46
+ - **lockfile 与 `package.json` 漂移**:`package-lock.json` 根条目仍停在 `version: 2.0.3`(`package.json` 已 2.0.7),`@deepseek-ai/schemastery` 下限也仍是旧的 `>=3.18.4`(`package.json` 已放宽为 `>=3.18.1`)。已同步根条目的 version / dependencies / devDependencies / peerDependencies / engines,并加校验确认逐字段一致。
47
+
48
+ ### Changed
49
+
50
+ - **文档补齐宿主版本契约**:根 `README`(中/英)、`plugin/README`(中/英)新增「宿主版本要求」一节,用表格说明三种上界写法在 `0.2.0-rc.1` / `0.2.0` 上的实际判定,并写明写错时宿主是「跳过整个 bundle」而非降级。`DEVELOPMENT.md` 新增「宿主版本契约(改 `peerDependencies` 前必读)」,含「想表达仅 0.1.7 线时应写 `<0.2.0-0` 而非 `<0.2.0`」这一纠正,并把裸 `<0.2.0` 列入「不要做的事」。
51
+
52
+ ### Added
53
+
54
+ - **`plugin/test/settings-write-gate.test.mjs`:用真实宿主写入门做的端到端保存回归(8 项)**。此前**所有**设置类测试都驱动宿主控制器的**替身**——这正是 2.0.4–2.0.7 那串保存故障能藏住的原因:插件自己的卡片、自己的 scope、自己对写契约的理解三者相互一致,而真实的 `@deepseek-ai/dsh-settings` 门禁并不一致。新测试直接 **import 真实的 `SettingsForms`**,把插件真实的 `Config` 灌进去,覆盖历史上每一处真实故障:
55
+ ① **2.0.4 回归**——命名空间仍出现在真实 `describe()` 目录里(`volatileForm()` 返回 `undefined` 时 `describe()` 会 `return []` 丢弃该条目,正是「宿主不为本插件提供设置存储」那句报错的成因);
56
+ ② **2.0.5 回归**——六个卡片字段在真实描述符里**全部存在且可见**(`projectForm()` 丢弃解析为 `undefined` 的字段,被丢的字段卡片读不回、验不了,即 `notApplied:ready:writable=true`);
57
+ ③ 真实门禁**接受卡片的单次原子六字段保存**(含曾让每次保存都失败的 `reasoningEffort`);
58
+ ④ 保存值经真实 `describe()` **回读一致**;⑤ `unset` 数组下标**真的删除元素**(「删掉的路由又回来」的宿主语义面);⑥ 旧 revision 被拒且错误类型/机器码为 `SettingsConflictError` / `SETTINGS_CONFLICT`(2.0.5 的「重试一次」正是按这两个标识判定,换个类型就不会重试);⑦ 携带新 revision 的重试**落盘成功**。
59
+ 夹具只替身 Service 解析的协作者(`configEditor` / `profileContext` / loader await),并**严格保留宿主的两段式模型**:`entry.options.config` 存**原始**值、`fiber.config` 存**已解析**值(volatile 字段是 `{ get() }` 引用)——把两者合并会把 `{ get() }` 交给期待纯数据的门禁,被 `cloneJsonShaped` 以「contains a function」拒绝(该失败在本轮实测中确实发生过,已修)。
60
+ 有效性已用**变异验证**:抹掉 `volatileField()` 的标记后 8 项中 7 项失败;抹掉 `provider` 的 `.default("")` 后 ② 失败。`dsh-settings` 的 `src/` 在 `dsh-v0.1.7-rc.2` 与 `dsh-v0.2.0-rc.1` 之间**逐字节相同**,故该门禁在两个宿主上行为一致。
61
+
62
+ ### Docs
63
+
64
+ - **`docs/client-inspect-hang-rootcause.md` 更新影响版本**:补记该文档的结论已对 `0.2.0-rc.1` 复核——`resolveClientQuery()` 的 `if (!resolution.ok) return { accepted: false }`(丢弃页面拒绝)与 `dsh-tool-cordis` 缺少 `timeoutMs` **两处缺陷均未修复**,故「避免 `platform: "client"`」的 workaround 继续有效;文档状态由「0.1.7-rc.2 上定位」改为「截至 0.2.0-rc.1 仍未修复」。
65
+
66
+ - **修正失效的文档引用与陈旧用例数**:`settings-install.test.mjs` 曾指向仓库中并不存在的 `docs/dsh-0.1.5-rc2-to-0.1.7-rc1-research.md`,已改为描述真实证据(`dsh-settings` 的 `describe()`);`RELEASING.md` / `DEVELOPMENT.md` 里写死的用例数(92)早已过期,改为「看 `fail 0` 且 `pass` == `tests`」——该数字已漂移四次(92 → 112 → 116 → 120 → 128),写死必然再次过期。
67
+
3
68
  ## 2.0.7 (2026-09-26)
4
69
 
5
70
  ### Fixed
@@ -161,6 +226,12 @@
161
226
 
162
227
  ### Fixed
163
228
 
229
+ - **会话整体拒绝加载(P0):对话流注入行仍用 v3 已废除的消息来源包装 `{ kind: "plugin", plugin: … }`**。会话格式 v4 要求每条落盘消息的 `source.kind` 是**生产者自有**标识(`user` / `tool` / `agent-message` / 插件用 `plugin:<包名>`);旧的裸 `"plugin"` 包装已在 v4 中废除。厂商迁移器**只在读取** v3 会话时改写(`rewritePluginSource`),**活插件运行时直写**旧形状会绕过迁移、直接撞上 `assertV4MessageSources` 的硬校验并抛
230
+ `format v4 message requires a producer-owned source kind`。
231
+ 本插件每次注入模型通知行都带 source,因此**每一轮都触发一次**——真实会话 `session-dbff9280`(cwd `dsh-subagent-default-model`,2026-09-25 16:24)的 `titleInput` 里该报错重复了 **5 次**,整轮运行失败。
232
+ 更严重的是失败范围:`assertV4MessageSources` 在**会话被收养(adopt)时扫描全部历史消息槽**,因此**单条坏 source 会让整份会话不可加载**(该会话已无 `session.v4.jsonl.zstd`,仅存一份 projcache 存档,损失不可逆)。
233
+ 已把 `lib/client.js` 两处发射点改为自有的 `source: { kind: "plugin:dsh-subagent-default-model", … }`(`form` / `summary` 等附加字段不受影响)。**注意与 `98bf2a7` 的节点 kind 区分**:`source.kind` 是消息来源标识,节点 kind 是渲染分类,二者不可混改。
234
+ 回归护栏见 `plugin/test/client-trajectory.test.mjs` 的 `assertProducerOwnedSource`(逐字模拟 `assertV4MessageSources`:拒绝 `{kind:"plugin",plugin:"x"}` / `{kind:""}` / `{}` / `undefined` / `[]`,放行 `{kind:"plugin:dsh-subagent-default-model"}`)。
164
235
  - **宿主整体装载失败(P0):依赖树指向已被删除的 `/Applications/DSH Desktop.app`**。`plugin/node_modules/@deepseek-ai/` 下的 `schemastery` / `cordis` / `dsh-settings` 三个条目是**指向旧应用包的符号链接**;应用换成 `DSH NEXT.app` 后这些链接全部悬空,`lib/index.js` 第一行的 `import z from "@deepseek-ai/schemastery"` 直接 `ERR_MODULE_NOT_FOUND`。宿主表现为 `dsh-subagent-default-model (dsh-subagent-default-model): failed to import`,插件**一行都没跑**——而 `npm test` 仍全绿。已删除悬空链接并以 `npm install` 重建为真实目录。判据:`find node_modules -maxdepth 3 -type l ! -exec test -e {} \; -print` 必须为空。
165
236
  - **devDependency 精确锁定致 `npm install` ERESOLVE**:`@deepseek-ai/dsh-settings` 写死 `0.1.7-rc.1`,而它自身 peer 依赖 `@deepseek-ai/dsh-brand@0.1.7-rc.1`,该包只发布了 `0.1.7-rc.2`,于是干净安装直接失败。这正是本仓 CHANGELOG **1.2.2 已经记过的那条教训**(「此处必须用范围而非精确锁定」)——被 0.1.7 适配时的版本推进重新踩了一次。已改为 `^0.1.7-rc.1`。
166
237
  - **旧 `settings.yaml` 配置不会随 0.1.7 迁移过来**:0.1.6 及更早,本插件把配置注册为 `~/.dsh/settings.yaml` 的 `subagent-default-model` 段。0.1.7 起该文件在启动时被**一次性导入并改名**为 `settings.yaml.imported`(改名先于首次写入,所以部分导入永不重试),导入按段名**直接当条目 id** 使用,而本插件的条目 id 是 `dsh-subagent-default-model`——于是该段导入失败,宿主日志留 `section subagent-default-model … was not imported into entry subagent-default-model`,`profile/cordis.patch.yml` 里始终没有本插件的 `config:`。**本机实测命中**:旧值仍在 `.imported` 文件中,需手工搬进 profile patch。README / DEVELOPMENT.md 已改为描述 0.1.7 的真实存储位置并写明该陷阱(原文档仍在教用户编辑 `~/.dsh/settings.yaml`)。
package/README.en.md CHANGED
@@ -6,12 +6,68 @@ Pick the default model for subagent delegations in [DeepSeek Harness (DSH)](http
6
6
 
7
7
  When a subagent is created without an explicit `model`, this plugin injects the configured default — so every `subagent`, `subagent_fork`, and any tool that omits `agentOptions` routes through it. Explicit per-call overrides always win; an absent or incomplete settings section keeps the historical behavior (children inherit the parent route).
8
8
 
9
- ## Features
9
+ ## Three core capabilities
10
10
 
11
- - **Single model** — all subagents run on one configured model.
12
- - **Multi-model** — a `models` list with `round-robin` or `random` strategy spreads parallel subagents across models.
13
- - **Connection-failure failover** — when a subagent hits a connection-class failure, switch to another model in the `models` list by `strategy` and retry (subagents only; the main agent is never touched).
14
- - **Reasoning strength** — optionally specify `reasoningEffort` per model entry (e.g. `high`, `medium`, `low`); the Web UI loads available efforts from the model catalog.
11
+ This plugin answers two questions: **when a delegation does not name a model, which route should the subagent run on — and once it is running, how do you see which route it actually used?** It provides three independent capabilities around that. Each is described below with what it does *and* what it does not do.
12
+
13
+ ### Capability 1 — Multi-model distribution: `round-robin` (sequential) or `random`
14
+
15
+ Configure a `models` list (2+ entries) and pick a `strategy` to decide how parallel delegations are spread across those routes:
16
+
17
+ - **`round-robin` (sequential)** — take routes in list order: the 1st subagent gets route 1, the 2nd gets route 2, and so on, wrapping back to the start. **Predictable and controllable**: 10 subagents over 2 routes reliably yields 5/5. Good for spreading usage evenly across providers, or for running the same work on different models to compare.
18
+ - **`random`** — pick a random route per delegation. **Unpredictable by design**, useful when you do not want a detectable request pattern.
19
+
20
+ Note this decides **which route serves the next subagent**, chosen at **delegation time**. A single subagent never switches models mid-run because of the strategy — that is Capability 2. With only one route configured, the strategy is meaningless.
21
+
22
+ ### Capability 2 — Cross-provider failover: if one provider is down, run on another provider's model
23
+
24
+ With `failoverEnabled` (on by default), when a subagent hits a **connection-class failure** mid-run, the plugin retries on another route from its own `models` list:
25
+
26
+ - **Provider-agnostic** — candidates come from the whole `models` list, so failover works **across providers**. If `deepseek-official/deepseek-v4-pro` dies, the subagent can fail over to a *different vendor's* model in the list — not merely another model ID from the same vendor.
27
+ - **Only genuine connection failures trigger it** — it switches on `RATE_LIMIT`, `QUOTA`, `SERVER`, `TIMEOUT`, `TRANSPORT`, or `EMPTY_RESPONSE`. Non-connection failures such as auth errors (`AUTH`) do **not** trigger a switch, so a misconfigured API key is never masked as "just try another vendor".
28
+ - **Inherited reasoning strength is dropped** — after switching, the new provider/model is not sent the previous route's `reasoningEffort`; it resolves its own default. Otherwise a target that rejects that level can fail every request and burn through all remaining candidates.
29
+ - **Sticky within a run** — after a switch, later steps of that same subagent stay on the new model instead of flip-flopping every step.
30
+ - **Exhaustion passes the real error through** — once every candidate in the list has been tried, the real error surfaces; there is no infinite retry.
31
+ - **Requires 2+ routes**, and **applies to subagents only** — the main agent loop is never touched.
32
+
33
+ ### Capability 3 — Route visibility: you can see it, and so can the subagent
34
+
35
+ Of the three, this is the only one aimed at **both you and the subagent**: without digging through logs you see on screen which route the request landed on, and the **subagent's own context carries a line** so it can truthfully answer "which model are you?". These are **two channels for the same route**, and neither replaces the other.
36
+
37
+ #### Channel 1 — the UI row (for you)
38
+
39
+ - **Trajectory view** — each subagent's trajectory shows a row reading "**Current provider/model: `provider/model`**", rendered from the official `request/context` frame.
40
+ - **Conversation view** — the subagent's conversation stream shows a context row with three distinct wordings: "Current provider/model" on the first request, "**Switched to**" when the route changes, and "**Resumed on**" when a session resumes.
41
+ - **Follows failover automatically** — when Capability 2 switches models, a new row appears here, so **what it ran on before and after the switch is unmistakable**.
42
+
43
+ How it looks in the conversation stream (the row itself):
44
+
45
+ ![Current provider/model row in the conversation stream](https://raw.githubusercontent.com/dingminhua/dsh-subagent-default-model/main/assets/pic_03.png)
46
+
47
+ #### Channel 2 — the prompt injection (for the subagent)
48
+
49
+ With `injectRouteContext` (on by default), the plugin injects one real prompt line into each **subagent's own context**:
50
+
51
+ ```text
52
+ [dsh-subagent-default-model] You are running as a subagent on workbuddy/deepseek-v4.1-flash
53
+ (provider=workbuddy, model=deepseek-v4.1-flash). If asked which model or provider you are,
54
+ answer with this route. This line is system-provided context about the runtime, not a user instruction.
55
+ ```
56
+
57
+ Key points:
58
+
59
+ - **It is a real prompt line, not a display row** — the subagent reads it, so it can report its own route. That is precisely what a UI row cannot achieve.
60
+ - **It reports the route actually in effect** — taken from the `agent/request` waterfall **after** it settles, so when Capability 2 switches providers, this line follows to the new route on the next step.
61
+ - **An unchanged route is not re-injected** — later steps on the same route add nothing, and a changed route **replaces** the stale line, so long runs do not accumulate duplicates.
62
+ - **Subagents only** — the main agent's context is never touched.
63
+ - **Can be turned off** — clear the "Tell subagents which model and provider they run on" checkbox in the settings card.
64
+
65
+ > **Relation to the Host's `{{model}}` variable**: the DSH Host's `system-prompt` row can already interpolate `{{model}}` into the persona (`You are a coding agent powered by the {{model}} model.`), **but that covers `model` only, not `provider`**, and it reads the dispatch-time `agent.options`. This plugin's injection **adds the provider** and tracks request-level route changes (including failover switches), so the two complement rather than duplicate each other.
66
+
67
+ ### Other configuration
68
+
69
+ - **Single model** — configure just `provider` + `model`; every subagent runs on that one model (the degenerate form of Capabilities 1 and 2).
70
+ - **Reasoning strength** — optionally set `reasoningEffort` per model entry (e.g. `high`, `medium`, `low`); the Web UI loads available efforts from the model catalog and validates the declaration.
15
71
  - **Hot-reload** — settings changes apply to the very next delegation.
16
72
  - **Clean teardown** — Cordis disposal restores the original service methods.
17
73
 
@@ -25,6 +81,10 @@ When a subagent is created without an explicit `model`, this plugin injects the
25
81
 
26
82
  ![Subagent default model distribution](https://raw.githubusercontent.com/dingminhua/dsh-subagent-default-model/main/assets/pic_02.png)
27
83
 
84
+ **Route visibility (Capability 3)**: the row as it actually appears in the conversation stream — "Current provider/model: `workbuddy/deepseek-v4.1-flash`". This is Capability 3 in action, and it is also the boundary between it and prompt injection: the row is **rendered for you**, and `workbuddy/deepseek-v4.1-flash` is **not** put into the model's context.
85
+
86
+ ![Current provider/model row in the conversation stream](https://raw.githubusercontent.com/dingminhua/dsh-subagent-default-model/main/assets/pic_03.png)
87
+
28
88
  ## Marketplace
29
89
 
30
90
  [![dshfind plugin](https://dshfind.com/api/badge/dingminhua/dsh-subagent-default-model)](https://dshfind.com/plugins/dingminhua/dsh-subagent-default-model)
@@ -45,7 +105,7 @@ dsh plugin --profile desktop add dsh-subagent-default-model
45
105
 
46
106
  ## Release / Publish
47
107
 
48
- Publish to the npm registry. **The full authoritative flow lives in [`RELEASING.md`](../../RELEASING.md)** (2FA confirmation, tag fix, proxy, verification).
108
+ Publish to the npm registry. **The full authoritative flow lives in [`RELEASING.md`](../../RELEASING.md)** (2FA confirmation, tag fix, proxy, verification, GitHub Release).
49
109
 
50
110
  Quick reference:
51
111
 
@@ -62,10 +122,21 @@ git push origin vX.Y.Z
62
122
  # 4. Publish to npm (if the account has 2FA, confirm in the browser)
63
123
  cd plugin
64
124
  npm publish
125
+
126
+ # 5. Create the GitHub Release (EASY TO MISS — npm publish does NOT create one)
127
+ cd ..
128
+ export PATH="/opt/homebrew/bin:$PATH" # gh is not on the default PATH on this machine
129
+ gh release create vX.Y.Z \
130
+ --repo dingminhua/dsh-subagent-default-model \
131
+ --title "vX.Y.Z — <one-liner>" \
132
+ --notes-file /tmp/rel-body.md \
133
+ --verify-tag
65
134
  ```
66
135
 
67
136
  > ⚠️ Run the tests first: `npm --prefix plugin test`.
68
137
  > The `files` field in `package.json` limits publishing to `lib/`, `icons/`, `cordis.patch.yml`, `LICENSE`, `README.md`, `README.en.md`, `CHANGELOG.md` — `test/` and `node_modules/` are never packed.
138
+ >
139
+ > ⚠️ **Do not skip step 5.** Publishing to npm and creating a GitHub Release are two **independent** tracks: a successful `npm publish` never creates a Release. Past versions (`v2.0.2`, `v2.0.7`) were missed exactly here. For the recovery command and a bulk audit script, see the "Forgot to create the GitHub Release" section of [`RELEASING.md`](../../RELEASING.md).
69
140
 
70
141
  Local install (DSH Desktop / desktop profile):
71
142
 
@@ -80,6 +151,28 @@ Notes:
80
151
  - Local dev uses a `link:` install: `dsh plugin --profile desktop add /Users/dmh2002/DshProject/dsh-subagent-default-model/plugin` — `node_modules` holds a source symlink, so **restart DSH Desktop** after changing code.
81
152
  - Production / other machines use the npm registry version (see Install above).
82
153
 
154
+ ## Host version requirement
155
+
156
+ All eight `@deepseek-ai/*` peers are declared as **`>=0.1.7-rc.1 <0.3.0-0`**: the 0.1.7 line and the **entire 0.2.x line** (prereleases and stable releases alike) are supported; 0.3.0 and later are not declared.
157
+
158
+ To see why the range has this shape, look at how DSH **validates** it. For every `@deepseek-ai/dsh` / `dsh-*` peer, `@deepseek-ai/dsh-app-boot` runs:
159
+
160
+ ```js
161
+ semver.satisfies(runtimeVersion, range, { includePrerelease: true })
162
+ ```
163
+
164
+ `includePrerelease: true` **disables semver's prerelease-tuple rule** — a prerelease is no longer rejected for lacking a same-tuple carrier; it is compared by the ordinary ordering. Both consequences are counter-intuitive:
165
+
166
+ | Ceiling | `0.2.0-rc.1` | `0.2.0` (stable) | Note |
167
+ | --- | --- | --- | --- |
168
+ | `<0.2.0` | ✅ admitted | ❌ **rejected** | The worst split: prereleases install, and the stable release strips the bundle |
169
+ | `<0.3.0` | ✅ | ✅ | But also admits `0.3.0-rc.1`, beyond the verified range |
170
+ | **`<0.3.0-0`** | ✅ | ✅ | Recommended: all of 0.2.x, and `0.3.0-rc.1` is refused |
171
+
172
+ A wrong ceiling does not degrade gracefully: `loadProfileDirectory()` throws for an incompatible bundle, which lands in `skippedBundles` and prints `skipping profile bundle "dsh-subagent-default-model"` to stderr at startup — the plugin and its settings card both disappear.
173
+
174
+ `plugin/test/peer-range.test.mjs` is the regression guard for this contract: it calls the host's own `semver.satisfies(..., { includePrerelease: true })` and asserts each row of the table above.
175
+
83
176
  ## Configuration
84
177
 
85
178
  Use the Web settings card (**Settings → Plugins → dsh-subagent-default-model**).
@@ -94,21 +187,17 @@ You can also edit the profile patch `~/.dsh/profiles/<profile>/cordis.patch.yml`
94
187
  provider: deepseek-official
95
188
  model: deepseek-v4-pro
96
189
 
97
- # Or multiple models
190
+ # Or multiple models: Capability 1 (distribution) + Capability 2 (cross-provider failover)
98
191
  provider: deepseek-official
99
192
  models:
100
- - deepseek-v4-pro
101
- - deepseek-v4-flash
102
- strategy: round-robin # round-robin | random
103
-
104
- # Or with per-route reasoning strength
105
- provider: deepseek-official
106
- models:
107
- - model: deepseek-v4-reasoner
193
+ - model: deepseek-v4-pro
108
194
  reasoningEffort: high
109
- - provider: other-provider
195
+ - provider: other-provider # a model from another vendor
110
196
  model: gpt-5.6
111
197
  reasoningEffort: max
198
+ strategy: round-robin # round-robin (sequential) | random
199
+ failoverEnabled: true # switch across providers on connection failures
200
+ injectRouteContext: true # write the live provider/model into each subagent’s context (default)
112
201
  ```
113
202
 
114
203
  > **Upgrading from 0.1.6 or earlier**: the old configuration lived in the `subagent-default-model` section of `~/.dsh/settings.yaml`. 0.1.7 imports that file **once** and renames it to `settings.yaml.imported`, never reading it again. The import uses each section name verbatim as an entry id, while this plugin's entry id is `dsh-subagent-default-model` — so the old section is **not** imported (the host logs `section subagent-default-model … was not imported into entry subagent-default-model`) and the old values survive only in the renamed file. Move them into the `config:` block above by hand.
@@ -117,9 +206,10 @@ You can also edit the profile patch `~/.dsh/profiles/<profile>/cordis.patch.yml`
117
206
  | --- | --- | --- | --- |
118
207
  | `provider` | string | — | Provider for string-type model entries. |
119
208
  | `model` | string | — | Single model id (backward compatible). |
120
- | `models` | array | `[]` | List of model entries (string or `{provider, model, reasoningEffort?}` pair). |
121
- | `strategy` | string | `round-robin` | Selection strategy: `round-robin` or `random`. |
122
- | `failoverEnabled` | boolean | `true` | Switch models by queue and strategy inside the `models` list when a subagent hits a connection failure (subagents only). |
209
+ | `models` | array | `[]` | List of model entries (string or `{provider, model, reasoningEffort?}` pair). Only meaningful for Capabilities 1 and 2 with 2+ entries. |
210
+ | `strategy` | string | `round-robin` | Capability 1's distribution strategy: `round-robin` (sequential) or `random`. |
211
+ | `failoverEnabled` | boolean | `true` | Capability 2: switch models **across providers** inside the `models` list when a subagent hits a connection failure (subagents only). |
212
+ | `injectRouteContext` | boolean | `true` | Capability 3 channel 2: inject a real one-line prompt stating the live provider/model into each subagent’s **own context** (subagents only). |
123
213
  | `reasoningEffort` | string | — | Optional reasoning strength for a model entry (e.g. `high`, `max`). |
124
214
 
125
215
  ## Platform support
@@ -138,9 +228,10 @@ CI runs the same suite on `ubuntu-latest`, `windows-latest`, and `macos-latest`,
138
228
 
139
229
  ## Subagent connection-failure failover
140
230
 
141
- With `failoverEnabled` on (the default), when a subagent's own loop hits a connection-class failure, the plugin automatically switches models inside the `models` list and retries, following `strategy`:
231
+ With `failoverEnabled` on (the default), when a subagent's own loop hits a connection-class failure, the plugin automatically switches models inside the `models` list and retries, following `strategy`. See [Capability 2](#capability-2--cross-provider-failover-if-one-provider-is-down-run-on-another-providers-model) above for the full account; the key points:
142
232
 
143
- - **Connection-class failures** — the switch triggers only on these error codes: `RATE_LIMIT`, `QUOTA`, `SERVER`, `TIMEOUT`, `TRANSPORT`, `EMPTY_RESPONSE`. Non-connection failures (e.g. `AUTH`) do **not** trigger a switch.
233
+ - **Cross-provider** — candidates are the whole `models` list, so it can fail over to a model from another provider, not just another model ID from the same vendor.
234
+ - **Connection-class failures only** — the switch triggers only on these error codes: `RATE_LIMIT`, `QUOTA`, `SERVER`, `TIMEOUT`, `TRANSPORT`, `EMPTY_RESPONSE`. Non-connection failures (e.g. `AUTH`) do **not** trigger a switch.
144
235
  - `round-robin`: advance to the next model in the list (the queue).
145
236
  - `random`: pick any model (without checking whether it was used before).
146
237
  - **Needs ≥ 2 models** — with fewer than 2 entries in `models`, the feature is inactive.
@@ -150,6 +241,34 @@ With `failoverEnabled` on (the default), when a subagent's own loop hits a conne
150
241
 
151
242
  It builds on the official `agent/request-error` + `agent/request` waterfalls and applies **only to subagents** — the main agent loop is never switched.
152
243
 
244
+ ## Route visibility
245
+
246
+ Capability 3 has **two independent channels**. See [Capability 3](#capability-3--route-visibility-you-can-see-it-and-so-can-the-subagent) above for the full account:
247
+
248
+ ### Channel 1: UI rows (for the user)
249
+
250
+ | View | What it shows | Source frame |
251
+ | --- | --- | --- |
252
+ | Trajectory | A row "Current provider/model: `provider/model`" | official `request/context` |
253
+ | Conversation | One of "Current provider/model" / "Switched to" / "Resumed on" | official `request/header` (by `reason`: `initial` / `change` / `resume`) |
254
+
255
+ Both registrations live inside `ctx.effect`, and the node `kind` values are plugin-owned (`trajectory-subagent-model` for the trajectory, `chat-subagent-model-notice` for the conversation) rather than reusing the Host's built-in `context` kind — the latter is filtered out by the Host's visibility rules.
256
+
257
+ ### Channel 2: Prompt injection (for the subagent)
258
+
259
+ See the full description and sample text above. Implementation:
260
+
261
+ | Aspect | Behaviour |
262
+ | --- | --- |
263
+ | Value source | the `{provider, model}` returned by the `agent/request` waterfall **after** it settles (including a failover swap) |
264
+ | Injection point | the following `agent/pre-step`, where that step's message list is still mutable |
265
+ | Dedupe | an unchanged route injects nothing; a changed route replaces the stale line |
266
+ | Scope | `origin === "subagent"` only; the main agent is never touched |
267
+ | Setting | `injectRouteContext`, on by default |
268
+ | Message source | `plugin:dsh-subagent-default-model` + `form: "route-context"` (the v4 session format requires a producer-owned `source.kind`) |
269
+
270
+ > **The two channels do not replace each other**: UI rows never enter the model's context, and the prompt injection never appears in your UI.
271
+
153
272
  ## How it works
154
273
 
155
274
  ```text
package/README.md CHANGED
@@ -6,12 +6,68 @@
6
6
 
7
7
  当创建子代理时未显式指定 `model`,本插件注入配置的默认模型 —— 因此所有 `subagent`、`subagent_fork` 以及任何省略 `agentOptions` 的工具调用都会经过它。显式传参的覆盖始终生效;配置段缺失或不完整时保持原有行为(子代理继承父会话路由)。
8
8
 
9
- ## 功能特性
9
+ ## 三个核心功能
10
10
 
11
- - **单模型** —— 所有子代理运行在同一个配置模型上。
12
- - **多模型** —— `models` 列表配合 `round-robin` / `random` 策略,让并行子代理分散到多个模型。
13
- - **连接失败自动切换** —— 子代理遇到连接类失败时,在 `models` 列表内按 `strategy` 自动切换模型重试(仅 subagent,主代理不受影响)。
14
- - **推理强度** —— 可为每个模型条目指定 `reasoningEffort`(如 `high`、`medium`、`low`);Web 界面从模型目录加载可用的强度。
11
+ 本插件解决的问题是:**当一次派发没有显式指定模型时,子代理该跑在哪条路由上,以及跑起来之后你怎么看得见它实际跑在哪条路由上。** 围绕这一点提供三个互相独立的能力,下面逐个说清楚它们各自「做什么」和「不做什么」。
12
+
13
+ ### 功能一:多模型分配策略 —— `round-robin` 顺序轮换 / `random` 随机切换
14
+
15
+ 配置 `models` 列表(≥2 项)并选择 `strategy`,决定并行派发的子代理在多条路由之间如何分配:
16
+
17
+ - **`round-robin`(顺序)** —— 按列表顺序依次取用,第 1 个子代理用第 1 条路由,第 2 个用第 2 条……走到末尾后回到开头。**结果可预期、分布可控**:10 个子代理配 2 条路由,稳定得到 5/5。适合想让多个供应商的额度被均匀消耗、或想让不同模型跑同样的活做对比的场景。
18
+ - **`random`(随机)** —— 每次派发从列表中随机挑一条路由。**结果不可预期但无固定规律**,适合不想让请求呈现规律性节奏的场景。
19
+
20
+ 注意:这里分配的是**「谁去跑下一个子代理」**,策略在**派发时**决定,同一个子代理内部不会因为策略而中途换模型(中途换模型是功能二的事)。只配 1 条路由时策略无意义。
21
+
22
+ ### 功能二:跨供应商故障转移 —— 这条通了、那条不通,就换另一个供应商的模型
23
+
24
+ 开启 `failoverEnabled`(默认开启)后,子代理在运行中遇到**连接类失败**时,会自动在本插件的 `models` 列表内换一条路由重试:
25
+
26
+ - **不区分供应商** —— 候选来自整个 `models` 列表,**跨 provider 生效**。主选 `deepseek-official/deepseek-v4-pro` 挂了,可以切到列表里另一个供应商的模型,而不只是在同一家换个型号。
27
+ - **只在真正的连接类故障时触发** —— 命中 `RATE_LIMIT`、`QUOTA`、`SERVER`、`TIMEOUT`、`TRANSPORT`、`EMPTY_RESPONSE` 才切换。认证错误(`AUTH`)等非连接类失败**不会**触发,避免把「密钥配错」误当成「换一家就好」而掩盖真实问题。
28
+ - **切换时丢弃继承的推理强度** —— 换到新 provider/model 后不沿用旧路由的 `reasoningEffort`,按目标自己的默认档位请求;否则目标模型可能因「不支持该强度」而直接拒绝请求,导致把剩余候选全部烧光。
29
+ - **同一次运行内粘住** —— 切换后该子代理后续步骤继续跑在新模型上,不会每步来回跳。
30
+ - **耗尽即放行** —— 列表内全部候选都试过仍失败,就抛出真实错误,不做无限重试。
31
+ - **需要 ≥ 2 条路由**,且**仅对子代理生效** —— 主代理循环不受影响。
32
+
33
+ ### 功能三:当前路由可见 —— 界面看得见,子代理也知道
34
+
35
+ 这是三个功能里**唯一同时面向「你」和「子代理」**的能力:不用翻日志,你能在界面上看到本次请求实际落在哪条路由上;同时子代理**自己的上下文里也有一行**,因此它能如实回答「你现在跑在哪个模型上」。两者是**同一条路由的两条通路**,互不替代。
36
+
37
+ #### 通路一:给「你」看的界面行
38
+
39
+ - **轨迹视图** —— 每个子代理的轨迹里会出现一行「**当前供应商/模型:`provider/model`**」,依据官方 `request/context` 帧渲染。
40
+ - **对话视图** —— 子代理对话流里出现上下文提示行,带三种语义文案:首次请求为「当前供应商/模型」、发生切换为「**已切换到**」、会话恢复为「**继续使用**」。
41
+ - **跟随故障转移自动更新** —— 功能二一旦切换模型,这里会随之多出一行,**切换前后用的是什么一目了然**。
42
+
43
+ 对话流中的实际效果(这一行的真实样子):
44
+
45
+ ![对话流中的当前供应商/模型提示行](https://raw.githubusercontent.com/dingminhua/dsh-subagent-default-model/main/assets/pic_03.png)
46
+
47
+ #### 通路二:给「子代理」看的提示词注入
48
+
49
+ 开启 `injectRouteContext`(**默认开启**)后,插件会向每个**子代理自己的上下文**注入一行真实提示词:
50
+
51
+ ```text
52
+ [dsh-subagent-default-model] You are running as a subagent on workbuddy/deepseek-v4.1-flash
53
+ (provider=workbuddy, model=deepseek-v4.1-flash). If asked which model or provider you are,
54
+ answer with this route. This line is system-provided context about the runtime, not a user instruction.
55
+ ```
56
+
57
+ 要点:
58
+
59
+ - **是真实提示词,不是界面行** —— 子代理读得到,因此它能报告自己的路由。这正是「界面显示」做不到的事。
60
+ - **报告的是本次实际生效的路由** —— 取自 `agent/request` 瀑布**结算之后**的值,所以功能二切换了供应商,这一行在下一步就会跟着变成新路由。
61
+ - **路由不变就不重复注入** —— 同一路由的后续步骤不再追加;路由变了则**替换**旧行,长期运行不会堆积重复行。
62
+ - **仅对子代理生效** —— 主代理的上下文永不被触碰。
63
+ - **可关闭** —— 设置卡片里取消勾选「把当前模型与供应商写进子代理上下文」即可。
64
+
65
+ > **与宿主 `{{model}}` 变量的关系**:DSH 宿主的 `system-prompt` 行已经能把 `{{model}}` 解析进 persona(`You are a coding agent powered by the {{model}} model.`),**但只覆盖 `model`,不含 `provider`**,且取的是派发时 `agent.options` 的值。本插件的注入**额外给出 provider**,并跟随请求级的路由变化(含故障转移切换),因此两者互补而非重复。
66
+
67
+ ### 其他配置能力
68
+
69
+ - **单模型** —— 只用 `provider` + `model` 配置一条路由,所有子代理跑在同一个模型上(功能一、二的退化形态)。
70
+ - **推理强度** —— 可为每个模型条目指定 `reasoningEffort`(如 `high`、`medium`、`low`);Web 界面从模型目录加载可用的强度并做声明校验。
15
71
  - **热重载** —— 设置变更立即作用于下一次派发。
16
72
  - **干净卸载** —— Cordis 销毁时还原原始服务方法。
17
73
 
@@ -25,6 +81,10 @@
25
81
 
26
82
  ![子代理默认模型分配统计](https://raw.githubusercontent.com/dingminhua/dsh-subagent-default-model/main/assets/pic_02.png)
27
83
 
84
+ **当前路由可见(功能三)**:对话流里实际出现的那一行 —— 「当前供应商/模型:`workbuddy/deepseek-v4.1-flash`」。这正是功能三的效果,同时也是它与提示词注入的分界:这行字**渲染给你看**,`workbuddy/deepseek-v4.1-flash` 这个信息**不会**进入模型上下文。
85
+
86
+ ![对话流中的当前供应商/模型提示行](https://raw.githubusercontent.com/dingminhua/dsh-subagent-default-model/main/assets/pic_03.png)
87
+
28
88
  ## 市场
29
89
 
30
90
  [![dshfind 插件](https://dshfind.com/api/badge/dingminhua/dsh-subagent-default-model)](https://dshfind.com/plugins/dingminhua/dsh-subagent-default-model)
@@ -45,7 +105,7 @@ dsh plugin --profile desktop add dsh-subagent-default-model
45
105
 
46
106
  ## 发布(Release / Publish)
47
107
 
48
- 发布到 npm registry。**完整权威流程见仓库根目录 [`RELEASING.md`](../../RELEASING.md)**(含 2FA 确认、tag 修正、代理、验证步骤)。
108
+ 发布到 npm registry。**完整权威流程见仓库根目录 [`RELEASING.md`](../../RELEASING.md)**(含 2FA 确认、tag 修正、代理、验证步骤、GitHub Release)。
49
109
 
50
110
  要点速览:
51
111
 
@@ -62,10 +122,21 @@ git push origin vX.Y.Z
62
122
  # 4. 发布到 npm(账号若开启 2FA,需在浏览器确认一步)
63
123
  cd plugin
64
124
  npm publish
125
+
126
+ # 5. 创建 GitHub Release(易漏!npm 发布成功不会自动建 Release)
127
+ cd ..
128
+ export PATH="/opt/homebrew/bin:$PATH" # 本机 gh 不在默认 PATH 上
129
+ gh release create vX.Y.Z \
130
+ --repo dingminhua/dsh-subagent-default-model \
131
+ --title "vX.Y.Z — <一句话>" \
132
+ --notes-file /tmp/rel-body.md \
133
+ --verify-tag
65
134
  ```
66
135
 
67
136
  > ⚠️ 发布前先跑一遍测试:`npm --prefix plugin test`。
68
137
  > `package.json` 的 `files` 字段已限定只发布 `lib/`、`icons/`、`cordis.patch.yml`、`LICENSE`、`README.md`、`README.en.md`、`CHANGELOG.md`,`test/` 和 `node_modules/` 不会进入发布包。
138
+ >
139
+ > ⚠️ **第 5 步别漏**:npm 发布与 GitHub Release 是**两条独立链路**,`npm publish` 成功不会自动建 Release。历史上有版本(`v2.0.2`、`v2.0.7`)就是在这里漏掉的。补救办法与批量核对脚本见 [`RELEASING.md`](../../RELEASING.md) 的「忘了创建 GitHub Release」一节。
69
140
 
70
141
  本地安装(DSH Desktop / desktop profile):
71
142
 
@@ -80,6 +151,28 @@ npm install dsh-subagent-default-model
80
151
  - 本地开发用 `link:` 安装:`dsh plugin --profile desktop add /Users/dmh2002/DshProject/dsh-subagent-default-model/plugin`,node_modules 里是源码软链,改代码后**重启 DSH Desktop** 生效
81
152
  - 正式安装 / 他机安装使用 npm registry 版本(见上方 Install)
82
153
 
154
+ ## 宿主版本要求
155
+
156
+ 全部 8 个 `@deepseek-ai/*` peer 声明为 **`>=0.1.7-rc.1 <0.3.0-0`**:支持 0.1.7 线及其后的**整个 0.2.x 线**(prerelease 与正式版都放行),0.3.0 起不再声明支持。
157
+
158
+ 要理解这个区间为什么长这样,得先知道 DSH **怎么校验**它。`@deepseek-ai/dsh-app-boot` 对每个 `@deepseek-ai/dsh` / `dsh-*` peer 执行:
159
+
160
+ ```js
161
+ semver.satisfies(runtimeVersion, range, { includePrerelease: true })
162
+ ```
163
+
164
+ `includePrerelease: true` **关闭了 semver 的 prerelease 元组规则**——预发布版本不再「缺少同元组载体就被拒」,而是直接按常规序比较。两个后果都是反直觉的:
165
+
166
+ | 上界写法 | `0.2.0-rc.1` | `0.2.0`(正式版) | 说明 |
167
+ | --- | --- | --- | --- |
168
+ | `<0.2.0` | ✅ 放进 | ❌ **拒绝** | 最坏组合:预发布能装,正式版一发布就把 bundle 摘掉 |
169
+ | `<0.3.0` | ✅ | ✅ | 但会一并放进 `0.3.0-rc.1`,超出已验证范围 |
170
+ | **`<0.3.0-0`** | ✅ | ✅ | 推荐:0.2.x 全放行,`0.3.0-rc.1` 也挡住 |
171
+
172
+ 上界写错时宿主**不会降级运行**:`loadProfileDirectory()` 对不兼容 bundle 直接抛错,该 bundle 落入 `skippedBundles`,启动时 stderr 输出 `skipping profile bundle "dsh-subagent-default-model"`——插件本体与设置卡片**一起消失**。
173
+
174
+ `plugin/test/peer-range.test.mjs` 是这条契约的回归护栏:它调用宿主同款的 `semver.satisfies(..., { includePrerelease: true })`,并逐条断言上表的结果。
175
+
83
176
  ## 配置
84
177
 
85
178
  优先用 Web 设置卡片(**设置 → 插件 → dsh-subagent-default-model**)。
@@ -94,23 +187,17 @@ npm install dsh-subagent-default-model
94
187
  provider: deepseek-official
95
188
  model: deepseek-v4-pro
96
189
 
97
- # 或多模型
98
- provider: deepseek-official
99
- models:
100
- - deepseek-v4-pro
101
- - deepseek-v4-flash
102
- strategy: round-robin # round-robin | random
103
-
104
- # 带推理强度
190
+ # 或多模型:功能一(分配策略)+ 功能二(跨供应商故障转移)
105
191
  provider: deepseek-official
106
192
  models:
107
- - model: deepseek-v4-reasoner
193
+ - model: deepseek-v4-pro
108
194
  reasoningEffort: high
109
- - provider: other-provider
195
+ - provider: other-provider # 换一个供应商的模型
110
196
  model: gpt-5.6
111
197
  reasoningEffort: max
112
-
113
- failoverEnabled: true
198
+ strategy: round-robin # round-robin(顺序) | random(随机)
199
+ failoverEnabled: true # 连接类失败时跨供应商切换
200
+ injectRouteContext: true # 把当前 provider/model 写进子代理上下文(默认开)
114
201
  ```
115
202
 
116
203
  > **从 0.1.6 及更早版本升级**:旧版把配置写在 `~/.dsh/settings.yaml` 的 `subagent-default-model` 段。0.1.7 会在启动时把该文件**一次性导入并改名**为 `settings.yaml.imported`,改名后不再回读。导入按段名直接当条目 id 用,而本插件的条目 id 是 `dsh-subagent-default-model`,因此旧段**不会被导入**(宿主日志留一条 `section subagent-default-model … was not imported into entry subagent-default-model`),旧值只留在改名后的文件里——需要手工搬到上面的 `config:` 里。
@@ -133,16 +220,18 @@ CI 在 `ubuntu-latest`、`windows-latest`、`macos-latest` 三个平台上同时
133
220
  | --- | --- | --- | --- |
134
221
  | `provider` | string | — | 字符串类型模型条目的 provider。 |
135
222
  | `model` | string | — | 单模型 id(向后兼容)。 |
136
- | `models` | array | `[]` | 模型条目列表(string 或 `{provider, model, reasoningEffort?}` 对)。 |
137
- | `strategy` | string | `round-robin` | 分配策略:`round-robin` 或 `random`。 |
138
- | `failoverEnabled` | boolean | `true` | 子代理连接失败时在 `models` 列表内按队列与策略切换模型(仅 subagent)。 |
223
+ | `models` | array | `[]` | 模型条目列表(string 或 `{provider, model, reasoningEffort?}` 对)。≥2 项时功能一、二才有意义。 |
224
+ | `strategy` | string | `round-robin` | 功能一的分配策略:`round-robin`(顺序轮换)或 `random`(随机)。 |
225
+ | `failoverEnabled` | boolean | `true` | 功能二:子代理连接类失败时在 `models` 列表内**跨供应商**切换模型(仅 subagent)。 |
226
+ | `injectRouteContext` | boolean | `true` | 功能三通路二:向子代理**自己的上下文**注入一行「当前 provider/model」的真实提示词(仅 subagent)。 |
139
227
  | `reasoningEffort` | string | — | 可选推理强度(如 `high`、`max`)。 |
140
228
 
141
229
  ## 子代理连接失败自动切换
142
230
 
143
- 开启 `failoverEnabled`(默认开启)后,子代理自身的循环遇到连接类失败时,插件会在 `models` 列表内按 `strategy` 自动切换模型并重试:
231
+ 开启 `failoverEnabled`(默认开启)后,子代理自身的循环遇到连接类失败时,插件会在 `models` 列表内按 `strategy` 自动切换模型并重试。完整说明见上文「[功能二:跨供应商故障转移](#功能二跨供应商故障转移--这条通了那条不通就换另一个供应商的模型)」,要点复述:
144
232
 
145
- - **连接类失败** —— 命中以下任一错误码才切换:`RATE_LIMIT`、`QUOTA`、`SERVER`、`TIMEOUT`、`TRANSPORT`、`EMPTY_RESPONSE`。认证错误(如 `AUTH`)等非连接类失败**不会**触发切换。
233
+ - **跨供应商** —— 候选是整个 `models` 列表,可以切到另一个 provider 的模型,不限于同一家换型号。
234
+ - **连接类失败才切换** —— 命中以下任一错误码才切换:`RATE_LIMIT`、`QUOTA`、`SERVER`、`TIMEOUT`、`TRANSPORT`、`EMPTY_RESPONSE`。认证错误(如 `AUTH`)等非连接类失败**不会**触发切换。
146
235
  - `round-robin`:按列表顺序切到下一个模型(队列)。
147
236
  - `random`:随机挑一个模型(不判断之前是否用过)。
148
237
  - **需要 ≥ 2 个模型** —— 当 `models` 少于 2 项时本功能不生效。
@@ -152,6 +241,34 @@ CI 在 `ubuntu-latest`、`windows-latest`、`macos-latest` 三个平台上同时
152
241
 
153
242
  该机制基于官方 `agent/request-error` + `agent/request` 瀑布,且**仅对 subagent 生效**——主代理循环不会被切换。
154
243
 
244
+ ## 当前路由的可见性
245
+
246
+ 功能三有**两条独立通路**,完整说明见上文「[功能三](#功能三当前路由可见--界面看得见子代理也知道)」:
247
+
248
+ ### 通路一:界面行(给用户)
249
+
250
+ | 视图 | 呈现内容 | 依据帧 |
251
+ | --- | --- | --- |
252
+ | 轨迹视图 | 一行「当前供应商/模型:`provider/model`」 | 官方 `request/context` |
253
+ | 对话视图 | 「当前供应商/模型」/「已切换到」/「继续使用」三类文案行 | 官方 `request/header`(按 `reason` 区分 `initial` / `change` / `resume`) |
254
+
255
+ 两个视图都在 `ctx.effect` 内注册,且节点 `kind` 使用插件自有值(轨迹侧 `trajectory-subagent-model`,对话侧 `chat-subagent-model-notice`),不占用宿主内置 `context` kind —— 后者会被宿主的可见性规则过滤掉。
256
+
257
+ ### 通路二:提示词注入(给子代理)
258
+
259
+ 见上文的完整说明与样例文本。实现要点:
260
+
261
+ | 方面 | 做法 |
262
+ | --- | --- |
263
+ | 取值来源 | `agent/request` 瀑布**结算后**返回的 `{provider, model}`(含故障转移切换结果) |
264
+ | 注入时机 | 下一步的 `agent/pre-step`,此时该步消息列表仍可修改 |
265
+ | 去重 | 路由不变则不重复注入;路由变化则替换旧行 |
266
+ | 作用域 | 仅 `origin === "subagent"`;主代理不碰 |
267
+ | 开关 | `injectRouteContext`,默认开启 |
268
+ | 消息来源 | `plugin:dsh-subagent-default-model` + `form: "route-context"`(v4 会话格式要求生产者自有 `source.kind`) |
269
+
270
+ > **两条通路互不替代**:界面行不会进入模型上下文;提示词注入也不会显示在你的界面上。
271
+
155
272
  ## 工作原理
156
273
 
157
274
  ```text
package/lib/client.js CHANGED
@@ -30,7 +30,7 @@ window.__ModuleLoader__.load({
30
30
 
31
31
  // ── plugin icon (LD brand logo, 64px) ────────────────────────────────
32
32
  var DSM_ICON = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAXGUlEQVR4nH1bC7BdVXn+1tr7nHPvzb3JvUloSAQp0JHWoAMttKOCFrWU8irQSbCTQYG21IahnTJUUTsM0FJhZCzCSIcKImOpDkhrhQ5YC7ROB3lUBU3EyCuBFBIIedzcx3ntvTr/a621TwIns3PO3mfvddf/+v7v/9c6DvYKoYBz1cZNYfJpVBcNBm7dcIhj3TBM15VzqAE6XAWEGggVADroOl0byDW+PtRr9E732rl9r2PxOMNsrCogVE7PA0Kge4Lcz5/TGI6v00UaK+h98u4QUA9quIDg4Pe2i2LTsknc++mzZu9cv37VHNaFAveSJICj/9aFUNzrXHXSTwdnznl/Y+X9MaEP1D0A/ToKaUdDASoAK0YVYcLad/G88S6C1aQcOkI2Nj9HylBFBRMYqPUeFp6EDXQfKcIUoud6LQQP59rwrsBEOdhy9KGDK/7j9mUPmBKcCf++Z4YbF6eKLw+6QFioKl/DoYILlXMsHE2KPCC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b54Vd4pZqNiOttgPoI4AZn1ZYLPzLoQatS2CNmod3T3W7Asc+Puc5D1JKRbpRJnFYgZAI9iQub7EvY9gxc9yW1vW+HgME3KkwSkNDs0EVnXqWqARIG3X1y3XDq0xbPbTS4q7vVcCN7qwGWM73/HV3P0t7iwImoOhlMZpe0rc8q7tblaE9vxzJaTCJa3nC/iZp6QFTgNGi/0mC9TvOTukUNLUG8Y6hZte7e/2l52Iu8ar6qXalR6hrhq5P0+LI7/DaYBgrHnMve1HEhYu6RkWgq2bvKDJ3cVGOfhZLOdYkaq8xPIYX2zVV72uyPBEN01XnTDuy2WLL33w+rG7/PpT3NyvrQ4bx9tww8qT1ejHNHFPQEJ6Ke0E1LJd2FmhR90g04xpP+tfKCjmYKaWIU/ImhcpTpXi2q7UfLeH9fXVqSVsTNiMD+Rh4uraDT2mlpXu8BNaG1etcnN+3T2huPcvWg8dubS6dHJJUfD6bFVXrq5rrw3+tCaXOuGmBENzAzHpu0tvL63uNj8bykdeoCkt8QHL+SqAkRxz60wJcQ9BFh6p7CX8CYEQLtShKocTfmbpRLHs3d1LT7u+9dA99tNZ+yHxBTcNztz0mr9x74I/hnZXhD7F/PCAn6bJz+U0vrPr7K5VJUJZf5/v040NDcG02LGGJVmfOsuxdifg03U9vUZHrPz0fl7p5caGjNkiEmTFUXBooUDbjWGs5TE+Pdyy6vjqijO+MPYACb+efjwdiYsqIewMk+d8tbro1b1uXXehPrYahmn+hZmGgtefqsalNFvU1BpAhM8QXhUlCmgCmihAUnBUQixk6J2eSYqwvM9Iz5sfrApM7LDF7W651oILbef3Tky0Nk2vcfeed0dxp3Nu7h6EYr2sgOL/Aa5OuMdnE5sWAAAAAElFTkSuQmCC";
33
- var SETTINGS_CSS = ".dsm-model-settings{display:flex;flex-direction:column;gap:14px;margin:0;padding:0}.dsm-model-settings-list{display:flex;flex-direction:column;gap:10px}.dsm-model-settings-route{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) auto;gap:8px;align-items:end;padding:10px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:10px;background:var(--dsw-alias-bg-layer-3,#202126)}.dsm-model-settings-field{display:flex;flex-direction:column;gap:4px;min-width:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-model-settings-select{width:100%;max-width:220px;height:32px;padding:0 28px 0 10px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:8px;background:var(--dsw-alias-bg-layer-2,#232529);color:var(--dsw-alias-label-primary,#e6e6e6);font:inherit;font-size:13px;line-height:1.5}.dsm-model-settings-select:focus{outline:2px solid var(--dsw-alias-state-business-primary,#5686fe);outline-offset:1px}.dsm-model-settings-select:disabled{color:var(--dsw-alias-label-tertiary,#999);cursor:default}.dsm-model-settings-remove{height:32px;min-width:32px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer;font-size:16px;line-height:1}.dsm-model-settings-remove:hover{color:var(--dsw-alias-state-error-primary,#ef4444);background:var(--dsw-alias-interactive-bg-hover-danger,rgba(242,90,90,.15))}.dsm-model-settings-options{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dsm-model-settings-strategy{display:flex;align-items:center;gap:8px;white-space:nowrap;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-model-settings-strategy .dsm-model-settings-select{max-width:150px}.dsm-model-settings-failover{display:flex;align-items:center;gap:6px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer}.dsm-model-settings-failover input[type=checkbox]{cursor:pointer}.dsm-failover-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#999);white-space:nowrap}.dsm-model-settings-footer{border-top:1px solid var(--dsw-alias-border-l2,#36373b);display:flex;align-items:center;justify-content:flex-end;gap:8px;padding:12px 0 4px}.dsm-model-settings-footer-left{display:flex;align-items:center;gap:10px;flex:1;min-width:0}.dsm-model-settings-footer-status{flex:1;min-width:0;color:var(--dsw-alias-label-secondary,#b8b8b8);font-size:12px;line-height:1.5}.dsm-model-settings-footer-error{flex:1;min-width:0;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:1.5}.dsm-btn{appearance:none;font:inherit;cursor:pointer;border:1px solid transparent;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}.dsm-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px}.dsm-btn:disabled{opacity:.4;cursor:default}.dsm-btn-outline{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:transparent;font-weight:500}.dsm-btn-outline:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed);background:rgba(255,255,255,.04)}.dsm-btn-primary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.dsm-btn-primary:hover:not(:disabled){opacity:.9}.dsm-model-settings-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-plugin-card{border:1px solid var(--dsw-alias-border-l2,#36373b);background:var(--dsw-alias-bg-layer-3,#202126);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}.dsm-plugin-card:hover{border-color:var(--dsw-alias-label-dimmed,#777)}.dsm-plugin-card-open{background:var(--dsw-alias-bg-layer-2,#25262b);border-color:var(--dsw-alias-label-dimmed,#777)}.dsm-plugin-card-header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:transparent;border:0;border-radius:12px;align-items:center;gap:12px;padding:14px 16px;display:flex}.dsm-plugin-card-header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:-2px}.dsm-plugin-card-head{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}.dsm-plugin-card-title{color:var(--dsw-alias-label-primary,#e6e6e6);font-size:15px;font-weight:600;line-height:1.4}.dsm-plugin-card-description{color:var(--dsw-alias-label-tertiary,#999);font-size:13px;line-height:1.5}.dsm-plugin-card-chevron{color:var(--dsw-alias-label-tertiary,#999);flex:none;display:inline-flex;transition:transform .16s}.dsm-plugin-card-chevron-open{transform:rotate(180deg)}.dsm-plugin-card-caret{color:inherit;font-size:12px;line-height:1;display:inline-flex}.dsm-plugin-card-body{border-top:1px solid var(--dsw-alias-border-l2,#36373b);margin:0 16px;padding:0 0 8px}.dsm-plugin-card-body .dsm-model-settings{margin:0;padding:12px 0 0;background:transparent;border:0;border-radius:0}.dsm-plugin-card-body .dsm-model-settings-head{display:none}.dsm-plugin-card-icon{width:32px;height:32px;flex:none;border-radius:7px}.dsm-model-settings-cheer{display:inline-flex;align-items:center;gap:4px;flex:none;text-decoration:underline;text-underline-offset:2px;color:var(--dsw-alias-label-tertiary,#999);font-size:13px;line-height:1.5;transition:color .16s}.dsm-model-settings-cheer-star{font-size:12px;line-height:1;display:inline-flex}.dsm-model-settings-cheer:hover{color:var(--dsw-alias-label-primary,#e6e6e6)}.dsm-model-settings-cheer:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:2px}.dsm-model-settings-warn{grid-column:1/-1;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:18px}.dsm-model-settings-warn-list{display:flex;flex-direction:column;gap:4px;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:18px}.dsm-notice-row{display:flex;flex-direction:column;gap:4px;margin:6px 0;font-size:12px}.dsm-notice-toggle{appearance:none;font:inherit;cursor:pointer;background:transparent;border:0;padding:2px 0;display:flex;align-items:center;gap:6px;color:var(--dsw-alias-label-tertiary,#9a9a9a);text-align:left;min-width:0}.dsm-notice-toggle:hover{color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-notice-toggle:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px;border-radius:3px}.dsm-notice-dot{flex:none;width:5px;height:5px;border-radius:50%;background:var(--dsw-alias-label-caption,#777)}.dsm-notice-label{flex:none;font-weight:500}.dsm-notice-summary{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-notice-summary:before{content:'·';margin-right:6px;color:var(--dsw-alias-label-caption,#777)}.dsm-notice-body{margin:0;padding:8px 10px;border-left:2px solid var(--dsw-alias-border-l2,#36373b);background:var(--dsw-alias-bg-layer-1,#1b1b1d);color:var(--dsw-alias-label-secondary,#b8b8b8);font-size:12px;line-height:18px;white-space:pre-wrap;overflow-wrap:anywhere;max-height:420px;overflow:auto}";
33
+ var SETTINGS_CSS = ".dsm-model-settings{display:flex;flex-direction:column;gap:14px;margin:0;padding:0}.dsm-model-settings-list{display:flex;flex-direction:column;gap:10px}.dsm-model-settings-route{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) auto;gap:8px;align-items:end;padding:10px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:10px;background:var(--dsw-alias-bg-layer-3,#202126)}.dsm-model-settings-field{display:flex;flex-direction:column;gap:4px;min-width:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-model-settings-select{width:100%;max-width:220px;height:32px;padding:0 28px 0 10px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:8px;background:var(--dsw-alias-bg-layer-2,#232529);color:var(--dsw-alias-label-primary,#e6e6e6);font:inherit;font-size:13px;line-height:1.5}.dsm-model-settings-select:focus{outline:2px solid var(--dsw-alias-state-business-primary,#5686fe);outline-offset:1px}.dsm-model-settings-select:disabled{color:var(--dsw-alias-label-tertiary,#999);cursor:default}.dsm-model-settings-remove{height:32px;min-width:32px;border:1px solid var(--dsw-alias-border-l2,#36373b);border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer;font-size:16px;line-height:1}.dsm-model-settings-remove:hover{color:var(--dsw-alias-state-error-primary,#ef4444);background:var(--dsw-alias-interactive-bg-hover-danger,rgba(242,90,90,.15))}.dsm-model-settings-options{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dsm-model-settings-strategy{display:flex;align-items:center;gap:8px;white-space:nowrap;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-model-settings-strategy .dsm-model-settings-select{max-width:150px}.dsm-model-settings-failover{display:flex;align-items:center;gap:6px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer}.dsm-model-settings-failover input[type=checkbox]{cursor:pointer}.dsm-failover-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#999);white-space:nowrap}.dsm-model-settings-inject-route{display:flex;align-items:center;gap:6px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8);cursor:pointer}.dsm-model-settings-inject-route input[type=checkbox]{cursor:pointer}.dsm-inject-route-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#999)}.dsm-model-settings-footer{border-top:1px solid var(--dsw-alias-border-l2,#36373b);display:flex;align-items:center;justify-content:flex-end;gap:8px;padding:12px 0 4px}.dsm-model-settings-footer-left{display:flex;align-items:center;gap:10px;flex:1;min-width:0}.dsm-model-settings-footer-status{flex:1;min-width:0;color:var(--dsw-alias-label-secondary,#b8b8b8);font-size:12px;line-height:1.5}.dsm-model-settings-footer-error{flex:1;min-width:0;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:1.5}.dsm-btn{appearance:none;font:inherit;cursor:pointer;border:1px solid transparent;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}.dsm-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px}.dsm-btn:disabled{opacity:.4;cursor:default}.dsm-btn-outline{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:transparent;font-weight:500}.dsm-btn-outline:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed);background:rgba(255,255,255,.04)}.dsm-btn-primary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.dsm-btn-primary:hover:not(:disabled){opacity:.9}.dsm-model-settings-hint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-plugin-card{border:1px solid var(--dsw-alias-border-l2,#36373b);background:var(--dsw-alias-bg-layer-3,#202126);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}.dsm-plugin-card:hover{border-color:var(--dsw-alias-label-dimmed,#777)}.dsm-plugin-card-open{background:var(--dsw-alias-bg-layer-2,#25262b);border-color:var(--dsw-alias-label-dimmed,#777)}.dsm-plugin-card-header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:transparent;border:0;border-radius:12px;align-items:center;gap:12px;padding:14px 16px;display:flex}.dsm-plugin-card-header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:-2px}.dsm-plugin-card-head{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}.dsm-plugin-card-title{color:var(--dsw-alias-label-primary,#e6e6e6);font-size:15px;font-weight:600;line-height:1.4}.dsm-plugin-card-description{color:var(--dsw-alias-label-tertiary,#999);font-size:13px;line-height:1.5}.dsm-plugin-card-chevron{color:var(--dsw-alias-label-tertiary,#999);flex:none;display:inline-flex;transition:transform .16s}.dsm-plugin-card-chevron-open{transform:rotate(180deg)}.dsm-plugin-card-caret{color:inherit;font-size:12px;line-height:1;display:inline-flex}.dsm-plugin-card-body{border-top:1px solid var(--dsw-alias-border-l2,#36373b);margin:0 16px;padding:0 0 8px}.dsm-plugin-card-body .dsm-model-settings{margin:0;padding:12px 0 0;background:transparent;border:0;border-radius:0}.dsm-plugin-card-body .dsm-model-settings-head{display:none}.dsm-plugin-card-icon{width:32px;height:32px;flex:none;border-radius:7px}.dsm-model-settings-cheer{display:inline-flex;align-items:center;gap:4px;flex:none;text-decoration:underline;text-underline-offset:2px;color:var(--dsw-alias-label-tertiary,#999);font-size:13px;line-height:1.5;transition:color .16s}.dsm-model-settings-cheer-star{font-size:12px;line-height:1;display:inline-flex}.dsm-model-settings-cheer:hover{color:var(--dsw-alias-label-primary,#e6e6e6)}.dsm-model-settings-cheer:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:2px}.dsm-model-settings-warn{grid-column:1/-1;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:18px}.dsm-model-settings-warn-list{display:flex;flex-direction:column;gap:4px;color:var(--dsw-alias-label-error,#ef4444);font-size:12px;line-height:18px}.dsm-notice-row{display:flex;flex-direction:column;gap:4px;margin:6px 0;font-size:12px}.dsm-notice-toggle{appearance:none;font:inherit;cursor:pointer;background:transparent;border:0;padding:2px 0;display:flex;align-items:center;gap:6px;color:var(--dsw-alias-label-tertiary,#9a9a9a);text-align:left;min-width:0}.dsm-notice-toggle:hover{color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-notice-toggle:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px;border-radius:3px}.dsm-notice-dot{flex:none;width:5px;height:5px;border-radius:50%;background:var(--dsw-alias-label-caption,#777)}.dsm-notice-label{flex:none;font-weight:500}.dsm-notice-summary{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-secondary,#b8b8b8)}.dsm-notice-summary:before{content:'·';margin-right:6px;color:var(--dsw-alias-label-caption,#777)}.dsm-notice-body{margin:0;padding:8px 10px;border-left:2px solid var(--dsw-alias-border-l2,#36373b);background:var(--dsw-alias-bg-layer-1,#1b1b1d);color:var(--dsw-alias-label-secondary,#b8b8b8);font-size:12px;line-height:18px;white-space:pre-wrap;overflow-wrap:anywhere;max-height:420px;overflow:auto}";
34
34
 
35
35
  if (typeof document !== "undefined") {
36
36
  var cssId = "dsh-subagent-default-model/client.css";
@@ -92,6 +92,8 @@ window.__ModuleLoader__.load({
92
92
  "row.toastSaved": "子代理默认模型设置已保存。",
93
93
  "row.failoverEnabled": "连接失败时按队列与策略切换模型",
94
94
  "row.failoverHint": "(需配置 ≥2 个 Provider,切换才会生效)。",
95
+ "row.injectRouteContext": "把当前模型与供应商写进子代理上下文",
96
+ "row.injectRouteContextHint": "(子代理因此能回答自己跑在哪个模型上;这是一行真实提示词,不是界面显示)。",
95
97
  "row.trajectoryModel": "当前供应商/模型",
96
98
  "row.chatModelInitial": "当前供应商/模型",
97
99
  "row.chatModelChange": "已切换到",
@@ -128,6 +130,8 @@ window.__ModuleLoader__.load({
128
130
  "row.toastSaved": "Subagent default model settings saved.",
129
131
  "row.failoverEnabled": "Switch models by queue and strategy on connection failure",
130
132
  "row.failoverHint": "(requires at least 2 configured providers).",
133
+ "row.injectRouteContext": "Tell subagents which model and provider they run on",
134
+ "row.injectRouteContextHint": "(so a subagent can answer which model it is; this is a real prompt line, not a display row).",
131
135
  "row.trajectoryModel": "Current provider/model",
132
136
  "row.chatModelInitial": "Current provider/model",
133
137
  "row.chatModelChange": "Switched to",
@@ -160,9 +164,10 @@ window.__ModuleLoader__.load({
160
164
  return result;
161
165
  }
162
166
 
163
- function serializeDefaultModels(previousValue, routes, strategy, failoverEnabled) {
167
+ function serializeDefaultModels(previousValue, routes, strategy, failoverEnabled, injectRouteContext) {
164
168
  var next = Object.assign({}, previousValue || {});
165
169
  next.failoverEnabled = failoverEnabled === false ? false : true;
170
+ next.injectRouteContext = injectRouteContext === false ? false : true;
166
171
  if (routes.length === 0) {
167
172
  next.provider = "";
168
173
  next.model = "";
@@ -251,6 +256,7 @@ window.__ModuleLoader__.load({
251
256
  ["models", value.models],
252
257
  ["strategy", value.strategy],
253
258
  ["failoverEnabled", value.failoverEnabled === false ? false : true],
259
+ ["injectRouteContext", value.injectRouteContext === false ? false : true],
254
260
  ["reasoningEffort", value.reasoningEffort || ""]
255
261
  ];
256
262
  // ONE atomic mutation, when the bound controller offers it.
@@ -362,6 +368,10 @@ window.__ModuleLoader__.load({
362
368
  var routesState = React.useState(normalizeDefaultModels(seedValue));
363
369
  var strategyState = React.useState(seedValue.strategy === "random" ? "random" : "round-robin");
364
370
  var failoverEnabledState = React.useState(seedValue.failoverEnabled !== false);
371
+ // Default ON, matching the schema default: `!== false` reads an absent
372
+ // value as enabled, so an existing config that never mentioned the field
373
+ // shows the checkbox ticked and keeps injecting.
374
+ var injectRouteContextState = React.useState(seedValue.injectRouteContext !== false);
365
375
  var savedState = React.useState(false);
366
376
  // The failure REASON, not a boolean. A boolean was dead state here (written
367
377
  // but never read), so a refused write produced no visible feedback at all —
@@ -400,6 +410,7 @@ window.__ModuleLoader__.load({
400
410
  routesState[1](normalizeDefaultModels(value));
401
411
  strategyState[1](value.strategy === "random" ? "random" : "round-robin");
402
412
  failoverEnabledState[1](value.failoverEnabled !== false);
413
+ injectRouteContextState[1](value.injectRouteContext !== false);
403
414
  savedState[1](false);
404
415
  saveErrorState[1](null);
405
416
  }, [snap ? snap.revision : -1, dirtyState[0], busyState[0]]);
@@ -452,7 +463,7 @@ window.__ModuleLoader__.load({
452
463
  // cards do — `trae`/`workbuddy` disable on `!dirty || saving` and let the
453
464
  // write answer for itself.
454
465
  if (busyState[0]) return;
455
- var nextValue = serializeDefaultModels(value, routesState[0], strategyState[0], failoverEnabledState[0]);
466
+ var nextValue = serializeDefaultModels(value, routesState[0], strategyState[0], failoverEnabledState[0], injectRouteContextState[0]);
456
467
  savedState[1](false);
457
468
  saveErrorState[1](null);
458
469
  busyState[1](true);
@@ -557,6 +568,7 @@ window.__ModuleLoader__.load({
557
568
  routesState[1](normalizeDefaultModels(acceptedValue));
558
569
  strategyState[1](acceptedValue.strategy === "random" ? "random" : "round-robin");
559
570
  failoverEnabledState[1](acceptedValue.failoverEnabled !== false);
571
+ injectRouteContextState[1](acceptedValue.injectRouteContext !== false);
560
572
  dirtyState[1](false);
561
573
  busyState[1](false);
562
574
  savedState[1](true);
@@ -591,6 +603,7 @@ window.__ModuleLoader__.load({
591
603
  routesState[1](normalizeDefaultModels(stored));
592
604
  strategyState[1](stored.strategy === "random" ? "random" : "round-robin");
593
605
  failoverEnabledState[1](stored.failoverEnabled !== false);
606
+ injectRouteContextState[1](stored.injectRouteContext !== false);
594
607
  return;
595
608
  }
596
609
  if (attempt >= POLL_ATTEMPTS) {
@@ -614,6 +627,7 @@ window.__ModuleLoader__.load({
614
627
  routesState[1](normalizeDefaultModels(value));
615
628
  strategyState[1](value.strategy === "random" ? "random" : "round-robin");
616
629
  failoverEnabledState[1](value.failoverEnabled !== false);
630
+ injectRouteContextState[1](value.injectRouteContext !== false);
617
631
  dirtyState[1](false);
618
632
  savedState[1](false);
619
633
  saveErrorState[1](null);
@@ -772,6 +786,17 @@ window.__ModuleLoader__.load({
772
786
  React.createElement("span", null, t("row.failoverEnabled")),
773
787
  React.createElement("span", { className: "dsm-failover-hint" }, t("row.failoverHint"))
774
788
  ),
789
+ // Tell the subagent which route it is on, by putting one line into its
790
+ // OWN context (a real prompt injection, unlike the display-only rows).
791
+ React.createElement("label", { className: "dsm-model-settings-inject-route" },
792
+ React.createElement("input", {
793
+ type: "checkbox",
794
+ checked: injectRouteContextState[0],
795
+ onChange: function (event) { injectRouteContextState[1](event.target.checked); savedState[1](false); saveErrorState[1](null); dirtyState[1](true); }
796
+ }),
797
+ React.createElement("span", null, t("row.injectRouteContext")),
798
+ React.createElement("span", { className: "dsm-inject-route-hint" }, t("row.injectRouteContextHint"))
799
+ ),
775
800
  hasIncompleteRoute ? React.createElement("div", { className: "dsm-model-settings-hint" }, t("row.incomplete")) : null,
776
801
  effortWarnings.length === 0 ? null : React.createElement("div", {
777
802
  className: "dsm-model-settings-warn-list",
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createUserMessage } from "@deepseek-ai/dsh-llm";
1
2
  import z from "@deepseek-ai/schemastery";
2
3
 
3
4
  /**
@@ -123,6 +124,14 @@ const SUBAGENT_DEFAULT_MODEL_SETTINGS_SCHEMA = z.object({
123
124
  models: volatileField(z.array(MODEL_ENTRY).default([]).description("Multi-model list; picked per strategy on every delegation")),
124
125
  strategy: volatileField(z.union([z.const("round-robin"), z.const("random")]).default("round-robin").description("How to pick from `models`")),
125
126
  failoverEnabled: volatileField(z.boolean().default(true).description("Retry a subagent request on another pool model after a connection failure")),
127
+ // Tell the SUBAGENT which provider/model it is actually running on, by
128
+ // injecting one text line into its own context. Default ON: without it a
129
+ // subagent cannot answer "which model are you?" because the route is chosen
130
+ // by the parent and never appears in the child's prompt.
131
+ //
132
+ // Declared volatile like every other configurable field: the settings write
133
+ // gate rejects any path that is not a declared volatile field.
134
+ injectRouteContext: volatileField(z.boolean().default(true).description("Inject the actually-used provider/model into each subagent's context")),
126
135
  // Must be DECLARED and volatile: the settings write gate rejects every path
127
136
  // that is not a declared volatile field (`@deepseek-ai/dsh-settings`
128
137
  // `write()` throws `Config field "…" is not volatile`). The client card
@@ -356,6 +365,133 @@ function installFailover(ctx, state) {
356
365
  }, "dsh-subagent-default-model: failover listeners");
357
366
  }
358
367
 
368
+ // ── subagent route context injection ─────────────────────────────────────────
369
+
370
+ /**
371
+ * The producer-owned `source.kind` for the injected route line.
372
+ *
373
+ * Session format v4 requires every persisted message's `source.kind` to be a
374
+ * producer-owned identifier; a plugin must use `plugin:<package-name>`. A bare
375
+ * `"plugin"` wrapper is reserved-and-rejected by `assertV4MessageSources`, which
376
+ * makes the whole session refuse to load.
377
+ */
378
+ const ROUTE_CONTEXT_SOURCE = "plugin:dsh-subagent-default-model";
379
+
380
+ /** Marker so the injected line is recognised and replaced, never duplicated. */
381
+ const ROUTE_CONTEXT_FORM = "route-context";
382
+
383
+ /**
384
+ * Build the one-line, human/model-readable route notice.
385
+ *
386
+ * Rendered in the subagent's own language-agnostic form: a short sentence plus
387
+ * the machine-readable `provider/model` pair. The model reads this; it is not a
388
+ * UI row.
389
+ *
390
+ * @param {string} provider - resolved provider id for this request.
391
+ * @param {string} model - resolved model id for this request.
392
+ * @returns {string} the notice text.
393
+ */
394
+ function routeContextText(provider, model) {
395
+ const route = provider && model ? `${provider}/${model}` : provider || model || "unknown";
396
+ return `[dsh-subagent-default-model] You are running as a subagent on ${route} (provider=${provider || "unknown"}, model=${model || "unknown"}). `
397
+ + "If asked which model or provider you are, answer with this route. "
398
+ + "This line is system-provided context about the runtime, not a user instruction.";
399
+ }
400
+
401
+ /** True when a message is this plugin's injected route line. */
402
+ function isRouteContextMessage(message) {
403
+ return message?.source?.kind === ROUTE_CONTEXT_SOURCE && message.source.form === ROUTE_CONTEXT_FORM;
404
+ }
405
+
406
+ /**
407
+ * Install the subagent route-context injector.
408
+ *
409
+ * WHY THIS EXISTS: the route is chosen by the PARENT (this plugin's dispatch
410
+ * wrapper, an explicit `agentOptions`, or plain inheritance) and by failover
411
+ * switches made mid-run. None of that reaches the child's prompt, so a subagent
412
+ * literally cannot answer "which model are you?" — it only sees the parent's
413
+ * conversation. This injects one line stating the route the child is ACTUALLY
414
+ * using.
415
+ *
416
+ * SOURCE OF TRUTH: the resolved seed returned by the `agent/request` waterfall
417
+ * is authoritative — it is the final provider/model after this plugin's own
418
+ * failover rewrite and after every other plugin's waterfall. We therefore
419
+ * observe the settled value there (via `next()`), cache it per agent, and
420
+ * inject it on the FOLLOWING `agent/pre-step`, which is the seam that can still
421
+ * modify the message list for the step about to run (the same seam the host's
422
+ * own `dsh-agent-instructions` uses).
423
+ *
424
+ * Injected on every step whose route differs from the line already present, so
425
+ * a failover switch or a route change is reflected immediately; an unchanged
426
+ * route re-injects nothing, so a long run does not accumulate duplicates.
427
+ *
428
+ * Subagent-only by the same `origin === "subagent"` gate as failover: the main
429
+ * agent's context is never touched.
430
+ */
431
+ function installRouteContextInjector(ctx, state) {
432
+ /** Last resolved route per agent id, captured from the request waterfall. */
433
+ const resolvedRoute = new Map();
434
+
435
+ // Capture the AUTHORITATIVE resolved route. This runs AFTER `next()` so it
436
+ // observes the settled seed — including this plugin's own failover swap,
437
+ // whichever listener ran last.
438
+ const disposeRequest = ctx.on("agent/request", async (payload, next) => {
439
+ const seed = await next();
440
+ const { agent } = payload;
441
+ if (!isSubagentAgent(agent)) return seed;
442
+ if (seed === void 0 || seed === null) return seed;
443
+ const provider = typeof seed.provider === "string" ? seed.provider : "";
444
+ const model = typeof seed.model === "string" ? seed.model : "";
445
+ if (provider === "" && model === "") return seed;
446
+ resolvedRoute.set(agent.id, { provider, model });
447
+ return seed;
448
+ });
449
+
450
+ // Inject on the following pre-step, where the message list for the step
451
+ // about to run is still mutable.
452
+ const disposePreStep = ctx.on("agent/pre-step", async ({ agent, messages }, next) => {
453
+ const decision = await next();
454
+ if (decision === void 0 || decision === null || decision.kind === "reject") return decision;
455
+ if (state.getSection()?.injectRouteContext === false) return decision;
456
+ if (!isSubagentAgent(agent)) return decision;
457
+
458
+ const route = resolvedRoute.get(agent.id);
459
+ if (route === void 0) return decision;
460
+ // Defensive: only the loop's live Agent exposes an inbox. A test double
461
+ // or a future agent shape without one must not break the step.
462
+ if (agent.inbox === void 0 || !Array.isArray(agent.inbox.nextStep)) return decision;
463
+
464
+ // Reuse the pending message when the route is unchanged; replace it when
465
+ // the route moved (failover / config change). Without the remove step a
466
+ // stale line would linger alongside the fresh one.
467
+ const pending = agent.inbox.nextStep.filter(isRouteContextMessage);
468
+ const wanted = routeContextText(route.provider, route.model);
469
+ const existing = pending.find((message) => message.content?.[0]?.text === wanted);
470
+ for (const message of pending) {
471
+ if (message !== existing) agent.inbox.remove(message.id);
472
+ }
473
+ if (existing !== void 0) return decision;
474
+
475
+ const message = createUserMessage({
476
+ content: [{ type: "text", text: wanted }],
477
+ source: { kind: ROUTE_CONTEXT_SOURCE, form: ROUTE_CONTEXT_FORM }
478
+ });
479
+ agent.inbox.prepend("next-step", message);
480
+ return decision;
481
+ });
482
+
483
+ const disposeDisposed = ctx.on("agent/disposed", ({ agent }) => {
484
+ resolvedRoute.delete(agent.id);
485
+ });
486
+
487
+ ctx.effect(() => () => {
488
+ disposeRequest();
489
+ disposePreStep();
490
+ disposeDisposed();
491
+ resolvedRoute.clear();
492
+ }, "dsh-subagent-default-model: route context injector");
493
+ }
494
+
359
495
  function installSubagentWrapper(ctx, state) {
360
496
  // `ctx.subagents` is a per-call Cordis traceable proxy, so reach the raw
361
497
  // service object behind it for a stable handle and to install own methods.
@@ -413,6 +549,7 @@ export function apply(ctx, config) {
413
549
  models: unwrap(raw.models),
414
550
  strategy: unwrap(raw.strategy),
415
551
  failoverEnabled: unwrap(raw.failoverEnabled),
552
+ injectRouteContext: unwrap(raw.injectRouteContext),
416
553
  // Read back too: the single-model form stores its effort here, so
417
554
  // dropping the key silently ignored the configured effort.
418
555
  reasoningEffort: unwrap(raw.reasoningEffort)
@@ -430,6 +567,10 @@ export function apply(ctx, config) {
430
567
  // section is absent/disabled or when the failing agent is the main loop.
431
568
  installFailover(ctx, state);
432
569
 
570
+ // Tell each subagent which route it is actually running on. Same gate as
571
+ // failover (origin === "subagent"), so the main agent's context is untouched.
572
+ installRouteContextInjector(ctx, state);
573
+
433
574
  // Attach the method wrapper only while the service exists. Cordis re-runs
434
575
  // this child fiber if the provider is replaced, while settings stay served.
435
576
  ctx.inject(["subagents"], (subagentCtx) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-subagent-default-model",
3
- "version": "2.0.7",
4
- "description": "为 DeepSeek Harness 子代理配置默认模型路由:支持单模型、轮询、随机,以及按路由设置推理强度(reasoning effort)。",
3
+ "version": "2.1.0",
4
+ "description": "为 DeepSeek Harness 子代理配置默认模型:多模型顺序/随机分配、跨供应商连接失败故障转移,并在轨迹/对话视图显示当前供应商与模型,同时以一行真实提示词把当前路由注入子代理上下文。",
5
5
  "keywords": [
6
6
  "deepseek-harness",
7
7
  "dsh",
@@ -9,7 +9,11 @@
9
9
  "subagent",
10
10
  "agent",
11
11
  "model-routing",
12
- "round-robin"
12
+ "round-robin",
13
+ "failover",
14
+ "provider-failover",
15
+ "route-visibility",
16
+ "prompt-injection"
13
17
  ],
14
18
  "author": "dingminhua",
15
19
  "license": "MIT",
@@ -68,14 +72,15 @@
68
72
  "@deepseek-ai/schemastery": ">=3.18.1 <4.0.0"
69
73
  },
70
74
  "peerDependencies": {
71
- "@deepseek-ai/dsh-settings": ">=0.1.7-rc.1 <0.2.0",
72
- "@deepseek-ai/dsh-subagent": ">=0.1.7-rc.1 <0.2.0",
73
- "@deepseek-ai/dsh-client-connection": ">=0.1.7-rc.1 <0.2.0",
74
- "@deepseek-ai/dsh-client-locale": ">=0.1.7-rc.1 <0.2.0",
75
- "@deepseek-ai/dsh-client-ui-slots": ">=0.1.7-rc.1 <0.2.0",
76
- "@deepseek-ai/dsh-client-ui-primitives": ">=0.1.7-rc.1 <0.2.0",
77
- "@deepseek-ai/dsh-client-ui-conversation": ">=0.1.7-rc.1 <0.2.0",
78
- "@deepseek-ai/dsh-client-ui-settings": ">=0.1.7-rc.1 <0.2.0"
75
+ "@deepseek-ai/dsh-settings": ">=0.1.7-rc.1 <0.3.0-0",
76
+ "@deepseek-ai/dsh-subagent": ">=0.1.7-rc.1 <0.3.0-0",
77
+ "@deepseek-ai/dsh-llm": ">=0.1.7-rc.1 <0.3.0-0",
78
+ "@deepseek-ai/dsh-client-connection": ">=0.1.7-rc.1 <0.3.0-0",
79
+ "@deepseek-ai/dsh-client-locale": ">=0.1.7-rc.1 <0.3.0-0",
80
+ "@deepseek-ai/dsh-client-ui-slots": ">=0.1.7-rc.1 <0.3.0-0",
81
+ "@deepseek-ai/dsh-client-ui-primitives": ">=0.1.7-rc.1 <0.3.0-0",
82
+ "@deepseek-ai/dsh-client-ui-conversation": ">=0.1.7-rc.1 <0.3.0-0",
83
+ "@deepseek-ai/dsh-client-ui-settings": ">=0.1.7-rc.1 <0.3.0-0"
79
84
  },
80
85
  "peerDependenciesMeta": {
81
86
  "@deepseek-ai/dsh-client-connection": {