dsh-subagent-default-model 2.1.5 → 2.1.7

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,67 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.7 (2026-10-18)
4
+
5
+ ### Fixed
6
+
7
+ - **DSH 0.2.x 上「多模型分配」整体空转**。宿主把派发入口从 `ctx.subagents.start(name, request)` / `startContinuable(spec)` 改成了 **`startActivation(spec)`**,而 `subagent` / `subagent_fork` 工具与 agent-team 的 `spawn_teammate` **都只调 `startActivation`**——旧的两个方法在服务上已无任何调用方。插件仍只包装旧方法,于是 `applyDefaultModel()` 从未执行,子代理静默继承父会话路由:配置 `workbuddy/space-bunny`,实际却跑在父会话的 `deepseek-flash` 上。
8
+
9
+ 这就是「设置看起来生效、行为却是父路由」的隐蔽失败:面板显示正确、日志无异常、子代理照常工作,只是没走配置的路由。
10
+
11
+ 修法:`installSubagentWrapper` 同时包装 `startActivation(spec)`,在 `spec.request` 上注入默认模型;`start` / `startContinuable` 继续包装以兼容旧宿主。未注入时**保持原 spec 引用**(不克隆),避免宿主侧的身份比较出现无意义差异。
12
+
13
+ > 现场取证方式:子代理会话首事件 `subagent/descriptor` 里固化了 `agentProvider` / `agentModel` / `agentReasoningEffort`,与插件配置对比即可判定注入是否发生——比读设置面板可靠。
14
+
15
+ ### Notes
16
+
17
+ - **预检错误不触发故障转移**。像 `MISSING_CREDENTIAL`(provider 的路由凭据缺失)这类错误发生在请求发出之前,不在切换名单内,插件会原样放行。名单仍然只包含运行期的连接类与认证类错误码。
18
+
19
+ ### Tests
20
+
21
+ - 新增 3 个用例:`legacy: false` 的主机(只有 `startActivation`)必须注入、显式 `agentOptions` 不被覆盖且 spec 引用不变、无配置时保持继承。
22
+ - 变异验证:把 `startActivation` 的包装赋值去掉 → 2 项失败(注入用例 + 卸载恢复用例)。
23
+ - 全量:`tests 152 / pass 152 / fail 0 / skip 0`。
24
+
25
+ ## 2.1.6 (2026-10-17)
26
+
27
+ ### 兼容性核查:DSH Desktop 0.2.1-rc.2
28
+
29
+ 当前宿主由 `0.2.1-rc.1` 升到 **`0.2.1-rc.2`**。逐项对照宿主源码(从 `app.asar` 解出 `dsh-agent-loop` / `dsh-session` / `dsh-subagent` / `dsh-app-boot`)核查,**插件行为无需改动**,但核查暴露了两个**与本插件逻辑无关、却会让护栏形同虚设**的问题,已一并修复。
30
+
31
+ | 检查项 | 结论 |
32
+ | --- | --- |
33
+ | 插件加载与注入 | ✅ 派发子代理实测注入正常 |
34
+ | 4 个事件钩子 | ✅ `agent/pre-step`、`agent/request`、`agent/request-error`、`agent/disposed` 全部仍在 |
35
+ | `preStep()` → `buildRequest()` 时序 | ✅ 未变(定义在 `:902` / `:1214`;`request/context` 仍在 `buildRequest` 内 `:1271` 才 append) |
36
+ | `inbox.claim()` 先抽干 | ✅ 未变(`preStep` 首行 `:906`) |
37
+ | `session.requestContext()` 语义 | ⚠️ 折叠逻辑未变,但 **`isSeeded` 的含义被放宽** —— 见下 |
38
+ | `agent/pre-step` 决策契约 | ✅ 未变:默认分支仍返回 `{kind:"enter", messages}`,`kind:"reject"` 仍短路 |
39
+ | 子代理提示词提交方式 | ✅ 仍以 `{kind:"user"}` 入队,`republish` 视为 `firstAttempt` 重新提交,注入行不会被跳过 |
40
+ | peer 区间覆盖 | ✅ 宿主 `unmetRequirements()` 对 `0.2.1-rc.2` 返回「无未满足要求」 |
41
+
42
+ 宿主的 `{{provider}}` / `{{model}}` 系统提示词变量依旧读 `agent.options`(派发时值),不含实时路由 —— 本插件注入行的价值不受影响。
43
+
44
+ ### Fixed
45
+
46
+ - **「直连宿主评估器」用例其实从未真正执行过(第二次)**。2.1.5 修掉了它的「静默 `return` 被记为 pass」,但漏了另一半:它用 `require.resolve("asar")` 读 `app.asar`,而本仓**根本没有 `asar` 依赖**,`MODULE_NOT_FOUND` 被 `catch` 吞掉 → **每台机器都走 `t.skip`**。结果是一个被报告为「已覆盖」、实际上从未断言过任何东西的用例。修法:改为**零依赖手写解析 asar**(16 字节前言 + JSON 目录树 + 载荷偏移),现在该用例在 `macOS` 上真实读取宿主源码并执行宿主的 `unmetRequirements`,测试统计为 `skip 0`。
47
+
48
+ > 手写解析时踩到一次真实陷阱:目录树 JSON 的长度是**第 4 个** uint32(未补零),第 3 个含尾部补零,直接喂给 `JSON.parse` 会抛 `Unexpected non-whitespace character after JSON`。
49
+
50
+ - **「应当通过」的宿主版本清单再次滞后**:清单停在 `0.2.1-rc.1`,而真实运行的宿主已是 `0.2.1-rc.2`。已补入清单(`semver` 护栏 + 宿主评估器护栏两处)。这正是 2.1.5 记录过的同一类回归,说明「宿主升级时必须补一行」需要按流程执行,而不是当次偶然发现。
51
+
52
+ ### Tests
53
+
54
+ - **新增回归用例**:`isSeeded` 含义放宽后,恢复会话在**本轮尚未结算请求**时必须保持沉默,结算后只报告**本轮**路由、绝不出现上一轮的 provider。变异验证:去掉 `isStaleFold()` 判定 → 2 项失败(新用例 + 原恢复会话用例)。
55
+ - **`peer-range.test.mjs` 现在真的会跑**:`tests 149 / pass 149 / fail 0 / skip 0`。变异验证:把 `dsh-llm` 单独改成 `>=0.1.7-rc.1 <0.2.1-0` → 2 项失败(区间护栏 + 宿主评估器护栏)。
56
+
57
+ ### Docs
58
+
59
+ `DEVELOPMENT.md`:
60
+
61
+ 1. 记录 `isSeeded` 在 0.2.1-rc.2 中**语义放宽**(`fromRestore` 现在要求显式 seed),并说明 `isStaleFold()` 为何在该含义下依然正确。
62
+ 2. 新增「这个『直连用例』曾经又空转了一次」一节:**「跳过」不是「通过」,也不是「验证过」**;并记录 asar 头部的字段顺序陷阱。
63
+ 3. 流程时序图的行号更新到 0.2.1-rc.2,并明确标注**行号是快照、不是契约**,每次升级重新 `grep`。
64
+
3
65
  ## 2.1.5 (2026-10-17)
4
66
 
5
67
  ### 兼容性核查:DSH Desktop 0.2.1-rc.1
package/README.en.md CHANGED
@@ -4,7 +4,7 @@ English | [中文](README.md)
4
4
 
5
5
  Pick the default model for subagent delegations in [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness), configured through the plugin's own settings card (its Cordis `Config`), stored in the profile's `cordis.patch.yml`.
6
6
 
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).
7
+ When a delegation request carries **no `agentOptions` at all**, this plugin supplies a default route from your settings before the host creates the subagent — 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 behaviour (children inherit the parent route).
8
8
 
9
9
  ## Three core capabilities
10
10
 
@@ -185,24 +185,29 @@ Use the Web settings card (**Settings → Plugins → dsh-subagent-default-model
185
185
  You can also edit the profile patch `~/.dsh/profiles/<profile>/cordis.patch.yml` directly: since DSH 0.1.7 that is where settings live, keyed by this plugin's Loader entry id `dsh-subagent-default-model`:
186
186
 
187
187
  ```yaml
188
+ # Multiple models (recommended): Capability 1 (distribution) + Capability 2 (cross-provider failover)
188
189
  - id: dsh-subagent-default-model
189
190
  name: dsh-subagent-default-model
190
191
  config:
191
- # Single model
192
- provider: deepseek-official
193
- model: deepseek-v4-pro
194
-
195
- # Or multiple models: Capability 1 (distribution) + Capability 2 (cross-provider failover)
196
- provider: deepseek-official
192
+ provider: deepseek-official # entries in models[] without a provider inherit this
197
193
  models:
198
194
  - model: deepseek-v4-pro
199
195
  reasoningEffort: high
200
196
  - provider: other-provider # a model from another vendor
201
197
  model: gpt-5.6
202
- reasoningEffort: max
203
- strategy: round-robin # round-robin (sequential) | random
204
- failoverEnabled: true # switch across providers on connection failures
205
- injectRouteContext: true # write the live provider/model into each subagent’s context (default)
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
201
+ ```
202
+
203
+ To pin a **single** model, use `model` instead of `models` (never both in the same `config:`):
204
+
205
+ ```yaml
206
+ - id: dsh-subagent-default-model
207
+ name: dsh-subagent-default-model
208
+ config:
209
+ provider: deepseek-official
210
+ model: deepseek-v4-pro
206
211
  ```
207
212
 
208
213
  > **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.
@@ -272,17 +277,29 @@ See the full description and sample text above. Implementation:
272
277
  | Setting | `injectRouteContext`, on by default |
273
278
  | Message source | `plugin:dsh-subagent-default-model` + `form: "route-context"` (the v4 session format requires a producer-owned `source.kind`) |
274
279
 
280
+ > **The line only appears once the route is known.**
281
+ >
282
+ > | Situation | Behaviour | Why |
283
+ > | --- | --- | --- |
284
+ > | Step 1 (no request settled yet) | **silent, nothing injected** | `preStep()` runs before `buildRequest()`, so no settled route exists yet. Guessing from the dispatch-time seed produced labels that did not match reality — saying nothing is better |
285
+ > | A **single-step** subagent | **may receive no line at all** | The direct consequence above. This is deliberate, not a fault |
286
+ > | Only half the route is known (provider but no model) | not rendered | Avoids emitting `model=unknown`, which a model may repeat back as fact |
287
+ > | A **resumed** session, before this run requests | does not reuse the previous run's route | At that moment the session fold describes the **previous** run — older than the dispatch seed |
288
+ >
289
+ > From step 2 onward (once the route settles) the line appears normally and updates when the route changes.
290
+
275
291
  > **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.
276
292
 
277
293
  ## How it works
278
294
 
279
295
  ```text
280
- Explicit agentOptions on the request
281
- → subagent-default-model settings
282
- → inherit parent session route
296
+ request already carries agentOptions → passed through untouched (this plugin never reads its settings)
297
+ else models[] has >=1 valid entry → pick one from models[] by strategy (round-robin / random)
298
+ else model (+ provider) is non-empty → use that single route
299
+ else → no injection; the host inherits the parent-session route
283
300
  ```
284
301
 
285
- The plugin wraps the host `ctx.subagents` service (`start` / `startContinuable`), so it covers every delegation path — built-in `subagent` / `subagent_fork` tools and any custom tool that calls the service without providing `agentOptions`.
302
+ The plugin wraps the host `ctx.subagents` service (`startActivation` on DSH 0.2.x, plus the legacy `start` / `startContinuable`), so it covers every delegation path — built-in `subagent` / `subagent_fork` tools, the agent-team `spawn_teammate` path, and any custom tool that calls the service without providing `agentOptions`.
286
303
 
287
304
  ## License
288
305
 
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  为 [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) 中的子代理(subagent)派发选择默认模型,可通过插件自己的设置卡片(其 Cordis `Config`)配置,存在 profile 的 `cordis.patch.yml`。
6
6
 
7
- 当创建子代理时未显式指定 `model`,本插件注入配置的默认模型 —— 因此所有 `subagent`、`subagent_fork` 以及任何省略 `agentOptions` 的工具调用都会经过它。显式传参的覆盖始终生效;配置段缺失或不完整时保持原有行为(子代理继承父会话路由)。
7
+ 当派发请求**完全没有 `agentOptions`** 时,本插件注入配置的默认路由 —— 因此所有 `subagent`、`subagent_fork` 以及任何省略 `agentOptions` 的工具调用都会经过它。显式传参的覆盖始终生效;配置段缺失或不完整时保持原有行为(子代理继承父会话路由)。
8
8
 
9
9
  ## 三个核心功能
10
10
 
@@ -185,24 +185,29 @@ semver.satisfies(runtimeVersion, range, { includePrerelease: true })
185
185
  也可以直接编辑 profile 的 patch 文件 `~/.dsh/profiles/<profile>/cordis.patch.yml`:DSH 0.1.7 起设置就存在这里,段名是本插件的 Loader 条目 id `dsh-subagent-default-model`:
186
186
 
187
187
  ```yaml
188
+ # 多模型(推荐):功能一(分配策略)+ 功能二(跨供应商故障转移)
188
189
  - id: dsh-subagent-default-model
189
190
  name: dsh-subagent-default-model
190
191
  config:
191
- # 单模型
192
- provider: deepseek-official
193
- model: deepseek-v4-pro
194
-
195
- # 或多模型:功能一(分配策略)+ 功能二(跨供应商故障转移)
196
- provider: deepseek-official
192
+ provider: deepseek-official # models 里未写 provider 的条目沿用这个
197
193
  models:
198
194
  - model: deepseek-v4-pro
199
195
  reasoningEffort: high
200
- - provider: other-provider # 换一个供应商的模型
196
+ - provider: other-provider # 换一个供应商的模型
201
197
  model: gpt-5.6
202
- reasoningEffort: max
203
- strategy: round-robin # round-robin(顺序) | random(随机)
204
- failoverEnabled: true # 连接类失败时跨供应商切换
205
- injectRouteContext: true # 把当前 provider/model 写进子代理上下文(默认开)
198
+ strategy: round-robin # round-robin(顺序) | random(随机)
199
+ failoverEnabled: true # 连接类失败时跨供应商切换
200
+ injectRouteContext: true # 把当前 provider/model 写进子代理上下文
201
+ ```
202
+
203
+ 若只想固定**一个**模型,改用 `model` 而不是 `models`(二者不要同时写在同一个 `config:` 里):
204
+
205
+ ```yaml
206
+ - id: dsh-subagent-default-model
207
+ name: dsh-subagent-default-model
208
+ config:
209
+ provider: deepseek-official
210
+ model: deepseek-v4-pro
206
211
  ```
207
212
 
208
213
  > **从 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:` 里。
@@ -272,17 +277,29 @@ CI 在 `ubuntu-latest`、`windows-latest`、`macos-latest` 三个平台上同时
272
277
  | 开关 | `injectRouteContext`,默认开启 |
273
278
  | 消息来源 | `plugin:dsh-subagent-default-model` + `form: "route-context"`(v4 会话格式要求生产者自有 `source.kind`) |
274
279
 
280
+ > **注入是有前提的:路由已知才会注入。**
281
+ >
282
+ > | 情形 | 行为 | 为什么 |
283
+ > | --- | --- | --- |
284
+ > | 第 1 步(本轮还没结算任何请求) | **静默,不注入** | `preStep()` 早于 `buildRequest()`,此时没有任何已结算的真实路由。拿派发时的旧种子去猜,会造成「标注与实际不符」——宁可不说 |
285
+ > | **单步子代理** | **可能完全收不到这一行** | 上面那条的直接后果。这是**刻意**的设计,不是故障 |
286
+ > | 路由只知一半(如只有 provider 没有 model) | 不渲染 | 避免输出 `model=unknown` 之类的占位符,被模型当事实复述 |
287
+ > | 恢复(resume)的会话,本轮尚未请求 | 不沿用上一轮的路由 | 会话折叠值此刻描述的是**上一轮**,比派发种子更旧 |
288
+ >
289
+ > 从第 2 步起(路由结算后),注入行会正常出现并在路由变化时更新。
290
+
275
291
  > **两条通路互不替代**:界面行不会进入模型上下文;提示词注入也不会显示在你的界面上。
276
292
 
277
293
  ## 工作原理
278
294
 
279
295
  ```text
280
- 请求携带显式 agentOptions
281
- → subagent-default-model 设置
282
- → 继承父会话路由
296
+ 派发请求已带 agentOptions → 原样放行,完全不碰(不读本插件设置)
297
+ 否则 models[] 有 ≥1 条有效条目 → 按 strategy 从 models[] 里取一条(round-robin / random)
298
+ 否则 model(+ provider)非空 → 就用这一条路由
299
+ 否则 → 不注入;由宿主自行继承父会话路由
283
300
  ```
284
301
 
285
- 插件包装宿主 `ctx.subagents` 服务(`start` / `startContinuable`),覆盖所有派发路径 —— 内置的 `subagent` / `subagent_fork` 工具,以及任何调用该服务但未提供 `agentOptions` 的自定义工具。
302
+ 插件包装宿主 `ctx.subagents` 服务(DSH 0.2.x 的 `startActivation`,以及旧版 `start` / `startContinuable`),覆盖所有派发路径 —— 内置的 `subagent` / `subagent_fork` 工具、agent-team 的 `spawn_teammate`,以及任何调用该服务但未提供 `agentOptions` 的自定义工具。
286
303
 
287
304
  ## 许可证
288
305
 
package/lib/index.js CHANGED
@@ -628,6 +628,12 @@ function installSubagentWrapper(ctx, state) {
628
628
 
629
629
  const originalStart = raw.start;
630
630
  const originalStartContinuable = raw.startContinuable;
631
+ // DSH 0.2.x unified every delegation entry point on `startActivation(spec)`:
632
+ // `subagent` / `subagent_fork` and the agent-team `spawn_teammate` path all
633
+ // call it directly, and the old `start` / `startContinuable` service methods
634
+ // no longer have any caller. Wrapping only those two therefore selected no
635
+ // route at all on 0.2.x (children silently inherited the parent route).
636
+ const originalStartActivation = raw.startActivation;
631
637
  const wrappedStart = typeof originalStart === "function"
632
638
  ? async (name, request) => originalStart.call(raw, name, applyDefaultModel(state, request))
633
639
  : void 0;
@@ -640,10 +646,23 @@ function installSubagentWrapper(ctx, state) {
640
646
  });
641
647
  }
642
648
  : void 0;
649
+ const wrappedStartActivation = typeof originalStartActivation === "function"
650
+ ? async (spec) => {
651
+ if (spec === void 0 || spec === null) return originalStartActivation.call(raw, spec);
652
+ const request = applyDefaultModel(state, spec.request);
653
+ // Keep the spec reference when nothing was injected: host code compares
654
+ // identity and a needless clone would be a silent behaviour change.
655
+ return originalStartActivation.call(raw, request === spec.request ? spec : {
656
+ ...spec,
657
+ request
658
+ });
659
+ }
660
+ : void 0;
643
661
 
644
- if (wrappedStart === void 0 && wrappedStartContinuable === void 0) return;
662
+ if (wrappedStart === void 0 && wrappedStartContinuable === void 0 && wrappedStartActivation === void 0) return;
645
663
  if (wrappedStart !== void 0) raw.start = wrappedStart;
646
664
  if (wrappedStartContinuable !== void 0) raw.startContinuable = wrappedStartContinuable;
665
+ if (wrappedStartActivation !== void 0) raw.startActivation = wrappedStartActivation;
647
666
  raw[WRAPPED] = state;
648
667
 
649
668
  // Service method replacement is not a Cordis-managed contribution by itself.
@@ -651,6 +670,7 @@ function installSubagentWrapper(ctx, state) {
651
670
  ctx.effect(() => () => {
652
671
  if (wrappedStart !== void 0 && raw.start === wrappedStart) raw.start = originalStart;
653
672
  if (wrappedStartContinuable !== void 0 && raw.startContinuable === wrappedStartContinuable) raw.startContinuable = originalStartContinuable;
673
+ if (wrappedStartActivation !== void 0 && raw.startActivation === wrappedStartActivation) raw.startActivation = originalStartActivation;
654
674
  if (raw[WRAPPED] === state) delete raw[WRAPPED];
655
675
  });
656
676
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-subagent-default-model",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "description": "为 DeepSeek Harness 子代理配置默认模型:多模型顺序/随机分配、跨供应商连接失败故障转移,并在轨迹/对话视图显示当前供应商与模型,同时以一行真实提示词把当前路由注入子代理上下文。",
5
5
  "keywords": [
6
6
  "deepseek-harness",