dsh-subagent-default-model 2.1.4 → 2.1.6

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,81 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.6 (2026-10-17)
4
+
5
+ ### 兼容性核查:DSH Desktop 0.2.1-rc.2
6
+
7
+ 当前宿主由 `0.2.1-rc.1` 升到 **`0.2.1-rc.2`**。逐项对照宿主源码(从 `app.asar` 解出 `dsh-agent-loop` / `dsh-session` / `dsh-subagent` / `dsh-app-boot`)核查,**插件行为无需改动**,但核查暴露了两个**与本插件逻辑无关、却会让护栏形同虚设**的问题,已一并修复。
8
+
9
+ | 检查项 | 结论 |
10
+ | --- | --- |
11
+ | 插件加载与注入 | ✅ 派发子代理实测注入正常 |
12
+ | 4 个事件钩子 | ✅ `agent/pre-step`、`agent/request`、`agent/request-error`、`agent/disposed` 全部仍在 |
13
+ | `preStep()` → `buildRequest()` 时序 | ✅ 未变(定义在 `:902` / `:1214`;`request/context` 仍在 `buildRequest` 内 `:1271` 才 append) |
14
+ | `inbox.claim()` 先抽干 | ✅ 未变(`preStep` 首行 `:906`) |
15
+ | `session.requestContext()` 语义 | ⚠️ 折叠逻辑未变,但 **`isSeeded` 的含义被放宽** —— 见下 |
16
+ | `agent/pre-step` 决策契约 | ✅ 未变:默认分支仍返回 `{kind:"enter", messages}`,`kind:"reject"` 仍短路 |
17
+ | 子代理提示词提交方式 | ✅ 仍以 `{kind:"user"}` 入队,`republish` 视为 `firstAttempt` 重新提交,注入行不会被跳过 |
18
+ | peer 区间覆盖 | ✅ 宿主 `unmetRequirements()` 对 `0.2.1-rc.2` 返回「无未满足要求」 |
19
+
20
+ 宿主的 `{{provider}}` / `{{model}}` 系统提示词变量依旧读 `agent.options`(派发时值),不含实时路由 —— 本插件注入行的价值不受影响。
21
+
22
+ ### Fixed
23
+
24
+ - **「直连宿主评估器」用例其实从未真正执行过(第二次)**。2.1.5 修掉了它的「静默 `return` 被记为 pass」,但漏了另一半:它用 `require.resolve("asar")` 读 `app.asar`,而本仓**根本没有 `asar` 依赖**,`MODULE_NOT_FOUND` 被 `catch` 吞掉 → **每台机器都走 `t.skip`**。结果是一个被报告为「已覆盖」、实际上从未断言过任何东西的用例。修法:改为**零依赖手写解析 asar**(16 字节前言 + JSON 目录树 + 载荷偏移),现在该用例在 `macOS` 上真实读取宿主源码并执行宿主的 `unmetRequirements`,测试统计为 `skip 0`。
25
+
26
+ > 手写解析时踩到一次真实陷阱:目录树 JSON 的长度是**第 4 个** uint32(未补零),第 3 个含尾部补零,直接喂给 `JSON.parse` 会抛 `Unexpected non-whitespace character after JSON`。
27
+
28
+ - **「应当通过」的宿主版本清单再次滞后**:清单停在 `0.2.1-rc.1`,而真实运行的宿主已是 `0.2.1-rc.2`。已补入清单(`semver` 护栏 + 宿主评估器护栏两处)。这正是 2.1.5 记录过的同一类回归,说明「宿主升级时必须补一行」需要按流程执行,而不是当次偶然发现。
29
+
30
+ ### Tests
31
+
32
+ - **新增回归用例**:`isSeeded` 含义放宽后,恢复会话在**本轮尚未结算请求**时必须保持沉默,结算后只报告**本轮**路由、绝不出现上一轮的 provider。变异验证:去掉 `isStaleFold()` 判定 → 2 项失败(新用例 + 原恢复会话用例)。
33
+ - **`peer-range.test.mjs` 现在真的会跑**:`tests 149 / pass 149 / fail 0 / skip 0`。变异验证:把 `dsh-llm` 单独改成 `>=0.1.7-rc.1 <0.2.1-0` → 2 项失败(区间护栏 + 宿主评估器护栏)。
34
+
35
+ ### Docs
36
+
37
+ `DEVELOPMENT.md`:
38
+
39
+ 1. 记录 `isSeeded` 在 0.2.1-rc.2 中**语义放宽**(`fromRestore` 现在要求显式 seed),并说明 `isStaleFold()` 为何在该含义下依然正确。
40
+ 2. 新增「这个『直连用例』曾经又空转了一次」一节:**「跳过」不是「通过」,也不是「验证过」**;并记录 asar 头部的字段顺序陷阱。
41
+ 3. 流程时序图的行号更新到 0.2.1-rc.2,并明确标注**行号是快照、不是契约**,每次升级重新 `grep`。
42
+
43
+ ## 2.1.5 (2026-10-17)
44
+
45
+ ### 兼容性核查:DSH Desktop 0.2.1-rc.1
46
+
47
+ 当前宿主为 `0.2.1-rc.1`(此前为 `0.2.0-rc.2`)。逐项核查的结论是**插件仍可正常运行**,但独立评审在复核中发现两个**与版本升级无关的既有缺陷**(恢复会话误报、半知路径渲染),已一并修复,见下节。
48
+
49
+ | 检查项 | 结论 |
50
+ | --- | --- |
51
+ | 插件加载与注入 | ✅ 派发子代理实测,注入行内容与实际路由一致(会话 `be5bae6b` / `b7df5721`) |
52
+ | 4 个事件钩子 | ✅ `agent/pre-step`、`agent/request`、`agent/request-error`、`agent/disposed` 全部仍在 |
53
+ | `preStep()` → `buildRequest()` 时序 | ✅ 未变(0.2.1-rc.1 中 `:956` → `:1075`) |
54
+ | `inbox.claim()` 先抽干 | ✅ 未变 |
55
+ | `session.requestContext()` 语义 | ⚠️ 未变 —— 但复核发现它在**恢复会话**下返回上一轮的路由,已修 |
56
+ | peer 区间覆盖 | ✅ 宿主 `evaluatePluginCompatibility()` 返回「无未满足要求」 |
57
+
58
+ 宿主的 `{{provider}}` / `{{model}}` 系统提示词变量仍读 `agent.options`(派发时值,`dsh-agent-loop` 注册处即 `context.agent?.options.provider`),不含 provider 的实时性 —— 这正是本插件注入行仍有价值的原因。
59
+
60
+ ### Fixed(独立评审发现)
61
+
62
+ - **恢复(resume)的子代理会被标上「上一轮」的路由**。`Session.fromRestore` 用上一轮的日志做种子,而 `requestContext()` 折叠的是**整段日志** —— 于是新一轮第 1 步、还没发出任何请求时,折叠结果就已经是旧路由。此时注入等于把一个**比派发种子更旧**的值当成现状。修法:仅当会话被恢复(`header.isSeeded`)**且**本轮尚未结算过请求时,不采信折叠值,保持沉默;本轮请求结算后折叠重新可信。
63
+ - **半知的路径被渲染成 `model=unknown`**。原先判定是「provider 或 model 有一个非空即采用」,于是 `{provider:"workbuddy", model:""}` 会输出 `model=unknown`,而模型可能把它当事实复述。改为**两半都已知才报告**,与服务端(`agent/request` 侧)的判定口径一致。
64
+ - **上一轮补的「直连宿主评估器」用例其实从未执行**。它 `import` 了 `app.asar` 内的路径 —— 普通 Node ESM 无法导入 asar(`ERR_MODULE_NOT_FOUND`,asar 是单个归档文件不是目录),于是走 `return` 分支**被计为 pass**,且是静默的。修法:改为**读取宿主源码文本**,在 `vm` 沙箱里用真实 `semver` 运行宿主的 `unmetRequirements`;找不到宿主时用 `t.skip` **显式跳过**,不再伪装成通过。同时该用例现在会断言「一个只拒绝 `0.2.1-rc.1` 的区间必须被宿主判为不满足」,即它要防的那个回归。
65
+
66
+ ### Tests
67
+
68
+ - **补上 `0.2.1-rc.1` 到「应当通过」的版本清单**。原先该清单从 `0.2.0-rc.2` 直接跳到稳定的 `0.2.1`,**真实在运行的 `0.2.1-rc.1` 从未被断言过**;一个只拒绝 `0.2.1-rc.1` 的区间回归会让护栏保持全绿。
69
+ - **新增直连宿主 `evaluatePluginCompatibility()` 的用例**:不再靠本地模型复述宿主规则,而是直接 `import` 宿主那个函数来断言 `0.2.1-rc.1` / `0.2.0-rc.2` / `0.2.1` / `0.1.7-rc.1` 均被接受。环境无 DSH 时自动跳过,不构成硬依赖。
70
+ - 变异验证:把上界改回 `<0.2.0-0` → 2 项失败;只让 `dsh-llm` 单独偏离区间 → 「every declared peer」用例失败。
71
+
72
+ ### Docs
73
+
74
+ `DEVELOPMENT.md` 补充两条实测结论:
75
+
76
+ 1. **`peerDependenciesMeta` 不参与宿主校验** —— `unmetRequirements()` 只遍历 `peerDependencies`。标了 `optional: true` 的 peer 区间不匹配时**照样挡住整个插件**。
77
+ 2. **校验必须用宿主的调用方式** —— 用 `semver.satisfies` 时漏掉 `{ includePrerelease: true }`,会把 `0.2.1-rc.1` 误判为不满足,从而得出「peer 区间坏了」的错误结论(本次排查即发生过)。
78
+
3
79
  ## 2.1.4 (2026-10-02)
4
80
 
5
81
  ### Fixed
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
 
@@ -158,7 +158,7 @@ Notes:
158
158
 
159
159
  ## Host version requirement
160
160
 
161
- 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.
161
+ All nine `@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.
162
162
 
163
163
  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:
164
164
 
@@ -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,14 +277,26 @@ 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
302
  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`.
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
 
@@ -158,7 +158,7 @@ npm install dsh-subagent-default-model
158
158
 
159
159
  ## 宿主版本要求
160
160
 
161
- 全部 8 个 `@deepseek-ai/*` peer 声明为 **`>=0.1.7-rc.1 <0.3.0-0`**:支持 0.1.7 线及其后的**整个 0.2.x 线**(prerelease 与正式版都放行),0.3.0 起不再声明支持。
161
+ 全部 9 个 `@deepseek-ai/*` peer 声明为 **`>=0.1.7-rc.1 <0.3.0-0`**:支持 0.1.7 线及其后的**整个 0.2.x 线**(prerelease 与正式版都放行),0.3.0 起不再声明支持。
162
162
 
163
163
  要理解这个区间为什么长这样,得先知道 DSH **怎么校验**它。`@deepseek-ai/dsh-app-boot` 对每个 `@deepseek-ai/dsh` / `dsh-*` peer 执行:
164
164
 
@@ -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,14 +277,26 @@ 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
302
  插件包装宿主 `ctx.subagents` 服务(`start` / `startContinuable`),覆盖所有派发路径 —— 内置的 `subagent` / `subagent_fork` 工具,以及任何调用该服务但未提供 `agentOptions` 的自定义工具。
package/lib/index.js CHANGED
@@ -444,6 +444,32 @@ function isRouteContextMessage(message) {
444
444
  return message?.source?.kind === ROUTE_CONTEXT_SOURCE && message.source.form === ROUTE_CONTEXT_FORM;
445
445
  }
446
446
 
447
+ /**
448
+ * Has this agent built a request yet in the CURRENT run?
449
+ *
450
+ * `session.requestContext()` folds over the session's whole event log, and a
451
+ * RESTORED session (`Session.fromRestore`) starts with the PREVIOUS run's log as
452
+ * its seed. So on step 1 of a resumed subagent the fold already returns the old
453
+ * run's route — before this run has chosen anything. Trusting it would label the
454
+ * new run with the previous run's provider/model: the same "authoritative but
455
+ * wrong" failure as the dispatch-seed bug, only older.
456
+ *
457
+ * The plugin's own `agent/request` listener records a route only once a request
458
+ * settles, so a per-agent "has requested" flag separates "this run has chosen"
459
+ * from "history says something".
460
+ *
461
+ * @param {object} agent - the loop agent.
462
+ * @param {Map} settled - per-agent settled-seed cache (its key presence is the flag).
463
+ * @returns {boolean} true when the fold can only be describing an earlier run.
464
+ */
465
+ function isStaleFold(agent, settled) {
466
+ // Only a actually-restored session can carry another run's log. A fresh
467
+ // session's fold is always produced by this run, so never second-guess it.
468
+ const seeded = agent?.session?.header?.isSeeded;
469
+ if (seeded !== true) return false;
470
+ return settled.has(agent?.id) === false;
471
+ }
472
+
447
473
  /**
448
474
  * Resolve the route the agent is ACTUALLY using, or `undefined` when that is
449
475
  * not yet knowable.
@@ -470,12 +496,18 @@ function isRouteContextMessage(message) {
470
496
  */
471
497
  function routeForInjection(agent, settled) {
472
498
  // The session's fold of the latest `request/context` — authoritative and
473
- // current, and what the host itself treats as "the latest resolved route".
499
+ // current FOR THE RUN THAT PRODUCED IT, and what the host itself treats as
500
+ // "the latest resolved route".
501
+ //
502
+ // BOTH halves must be known: a half-filled fold (`{provider:"workbuddy",
503
+ // model:""}`) used to render as `model=unknown`, which is exactly the
504
+ // "report a guess" failure this function exists to avoid. The request side
505
+ // rejects the same shape, so both ends agree on what a route is.
474
506
  const live = agent?.session?.requestContext?.();
475
507
  if (live !== void 0 && live !== null) {
476
508
  const provider = typeof live.provider === "string" ? live.provider : "";
477
509
  const model = typeof live.model === "string" ? live.model : "";
478
- if (provider !== "" || model !== "") return { provider, model };
510
+ if (provider !== "" && model !== "" && !isStaleFold(agent, settled)) return { provider, model };
479
511
  }
480
512
  // A request already built by this plugin's own waterfall: still authoritative
481
513
  // for that request, and normally identical to the fold above.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-subagent-default-model",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
4
4
  "description": "为 DeepSeek Harness 子代理配置默认模型:多模型顺序/随机分配、跨供应商连接失败故障转移,并在轨迹/对话视图显示当前供应商与模型,同时以一行真实提示词把当前路由注入子代理上下文。",
5
5
  "keywords": [
6
6
  "deepseek-harness",