dsh-subagent-default-model 2.2.4 → 2.2.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 +169 -0
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/lib/index.js +56 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,174 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.6 (2026-11-19)
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
**故障转移的触发码集补上两个真实会发生的失败:`STREAM_CLOSED` 与 `ACCOUNT_QUOTA`。**
|
|
8
|
+
|
|
9
|
+
这张清单是 2026-08 写 failover v1.0.0 时照着**当时**宿主会抛的码定的,之后宿主陆续加码,而**没有任何测试比对过两张表**。到 0.2.2-rc.5 为止,缺的两个恰好都是本功能存在的理由:
|
|
10
|
+
|
|
11
|
+
| 码 | 宿主在哪里抛 | 为什么该切换 |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| `STREAM_CLOSED` | `dsh-llm-deepseek:2096`「stream ended before message_stop」、`dsh-llm-pi-ai:1688`「event stream ended without done/error」 | 流在响应中途断掉,是「这家坏了、换一家就好」的典型场景。此前插件把它原样放行,子代理直接以错误结束 |
|
|
14
|
+
| `ACCOUNT_QUOTA` | `dsh-llm-deepseek-account:87` —— 把账号余额耗尽的 `QUOTA` **改写**成这个码 | 与 `QUOTA`(清单里一直有)是同一件事,只是把「账号额度」与「单 key 额度」分开表达。结果唯一一个明说「这个账号没钱了」的码,恰恰是唯一不触发切换的码 |
|
|
15
|
+
|
|
16
|
+
判据:**码集要对「宿主真的会抛什么」负责,不是对「当年常量表里写了什么」负责。**
|
|
17
|
+
|
|
18
|
+
仍然**故意不切换**的码(理由已逐条写进测试文件):`CONTENT_REFUSED`(内容被拒,换一家也一样被拒)、`CONTEXT_WINDOW_EXCEEDED` / `IMAGE_OFFLOAD_REQUIRED` / `INVALID_REQUEST`(请求本身有问题)、`UNKNOWN_MODEL` / `MODEL_UNSUPPORTED`(切换会掩盖配置里的笔误)、`MALFORMED_RESPONSE`(可能是供应商坏了,也可能是适配器的恒定 bug,插件分不出来,赌错会烧光整池)。
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
**护栏:码集与宿主词表的自动对齐(此前完全裸奔)。**
|
|
23
|
+
|
|
24
|
+
新增 `plugin/test/failover-codes.test.mjs`,两层:
|
|
25
|
+
|
|
26
|
+
1. **词表层(静态)** —— 从运行中的 `app.asar` 里解析宿主自己的 `LLM_FAILURE_CODES` 表,要求每个码要么在切换集里、要么在 `DELIBERATELY_ABSENT` 里写明理由。宿主下次加码时,**这条用例会红**,而不是等到几个月后有人手工发现。
|
|
27
|
+
2. **行为层(动态)** —— 对每个码真实驱动插件自己的 `agent/request-error` 监听器,断言到底切不切。观察点是 `agent.model.select()` 是否被调用:在 0.2.2 上切换走这条路,瀑布的返回值**两种情况都是 `undefined`**,只看返回值等于什么都没断言。
|
|
28
|
+
|
|
29
|
+
另有两条针对性回归:`STREAM_CLOSED` / `ACCOUNT_QUOTA` 必须切换;且必须走**连接类**路径而不是认证类(否则每次都要打一条误导性的「凭据被拒」warn)。
|
|
30
|
+
|
|
31
|
+
`FAILOVER_ELIGIBLE_CODES` 与 `FAILOVER_TRIGGER_CODE_SET` 改为导出常量(与 `volatileField` / `Config` 同类的测试接缝):测试直接读模块,**不再手抄一份清单**——抄一份的话,清单改了它照样绿,护栏就成了装饰。
|
|
32
|
+
|
|
33
|
+
### Tests
|
|
34
|
+
|
|
35
|
+
`198 → 206`,`skip 0`。新增 8 条:
|
|
36
|
+
|
|
37
|
+
- 宿主词表可读(并校验解析结果的规模,防止解析退化成两三条让后续断言全部空转);
|
|
38
|
+
- 每个宿主码要么切换、要么有文档;
|
|
39
|
+
- 「故意不切」与「切换集」互斥;
|
|
40
|
+
- 「故意不切」里的码必须仍存在于宿主词表(防止过期决策变成噪音);
|
|
41
|
+
- 行为:切换集里的每个码真的会切;
|
|
42
|
+
- 行为:文档记为不切的每个码真的不切;
|
|
43
|
+
- 回归:`STREAM_CLOSED` / `ACCOUNT_QUOTA` 会切;
|
|
44
|
+
- 回归:两者走连接类路径,不打凭据 warn。
|
|
45
|
+
|
|
46
|
+
**变异验证 3/3 命中**:删 `STREAM_CLOSED` → 2 条红;删 `ACCOUNT_QUOTA` → 2 条红;把 `CONTENT_REFUSED` 误加进切换集 → 2 条红(互斥检查 + 行为检查)。
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- 双语文档(根 `README` 与 `plugin/README` 各两份)的连接类触发码清单同步补上这两个码。
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## 2.2.5 (2026-11-19)
|
|
54
|
+
|
|
55
|
+
### 兼容性核查:DSH Desktop 0.2.2-rc.3 → rc.4 → rc.5
|
|
56
|
+
|
|
57
|
+
宿主由 `0.2.2-rc.2` 一路升到 **`0.2.2-rc.5`**(2026-11-18 安装)。**插件运行逻辑零改动**(`plugin/lib/index.js` / `plugin/lib/client.js` 未动一行)——本版只做核查与清单维护。
|
|
58
|
+
|
|
59
|
+
两个区间分开记:rc.2 → rc.3 见下节(2.2.5 起草时核查过),rc.3 → rc.5 见本节。
|
|
60
|
+
|
|
61
|
+
#### rc.3 → rc.5:只有 10 个包有真实代码改动,全部在插件未触碰的面
|
|
62
|
+
|
|
63
|
+
| 包 | 改动 | 与本插件的关系 |
|
|
64
|
+
| --- | --- | --- |
|
|
65
|
+
| `dsh-web` / `dsh-tool-web` | 搜索提供方改为**按模型路由自动选择**:DeepSeek 模型走旧版 Messages 搜索(不按次收费),其余路由走 DeepSeek Search API;`WebSearchRequest` 新增 `llmProvider` | 与本插件无关(不碰 `ctx.web`) |
|
|
66
|
+
| `dsh-web-search-deepseek` / `dsh-web-deepseek-api` | 跟随上述改造 | 与本插件无关 |
|
|
67
|
+
| `dsh-client-ui-settings-web-search` | 「网页搜索提供方」菜单新增**自动选择** | 与本插件无关 |
|
|
68
|
+
| `dsh-bundle-base` | 组合不再固定 `web.searchProvider` | 与本插件无关 |
|
|
69
|
+
| `dsh-llm` | **新增失败码 `CONTENT_REFUSED`**(内容安全拒答,取代原来的 `MALFORMED_RESPONSE`) | 见下方「需要决定的一项」 |
|
|
70
|
+
| `dsh-llm-deepseek` | 拒答时先 `yield usage` 再抛错(已消耗的 token 照常计费);`stop_reason: "refusal"` 映射到 `CONTENT_REFUSED` | 同上 |
|
|
71
|
+
| `dsh-experimental-liveshare` | 隧道 worker 的 owner 凭据时限 | 与本插件无关 |
|
|
72
|
+
| `dsh-tool-cordis` | 内嵌的 `SERVICE_API` 目录:`ctx.web` 的搜索选择规则补上按路由分支,`WebSearchRequest` 增加 `llmProvider` | 纯文档字符串 |
|
|
73
|
+
|
|
74
|
+
**插件依赖的 8 个包在 rc.3 → rc.5 全程零改动**:`dsh-agent-loop`、`dsh-agent`、`dsh-session`、`dsh-subagent`、`dsh-tool-subagent`、`dsh-settings`、`dsh-app-boot`、`cordis`(逐文件比对,只有 `package.json` 版本号)。
|
|
75
|
+
|
|
76
|
+
#### 契约复核(`0.2.2-rc.5` 实测,与 rc.3 逐位相同)
|
|
77
|
+
|
|
78
|
+
| 检查项 | 结论 |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| 插件加载与注入 | ✅ 已挂载(`include:dsh-subagent-default-model`),`Config` 投影出全部 10 个 volatile 字段(`provider` / `model` / `models` / `strategy` / `failoverEnabled` / `injectRouteContext` / `reasoningEffort` / `applyToForkChildren` / `continueAfterFailover` / `maxAutoContinues`) |
|
|
81
|
+
| `preStep()` → `buildRequest()` 时序 | ✅ `:679` / `:1031`;`request/context` 仍在 `:1088` append |
|
|
82
|
+
| `inbox.claim()` 先抽干 | ✅ `:683`,仍在 `:698` 的 `agent/pre-step` 之前 |
|
|
83
|
+
| `agent/pre-step` / `agent/request-error` / `agent/request` | ✅ `:698` / `:942` / `:1007`,`agent/request` 仍未移除、仍派发 |
|
|
84
|
+
| `agent/request` 的硬校验 | ✅ 仍在 `:1013`——改了 `provider` / `model` / `reasoningEffort` 就抛错 |
|
|
85
|
+
| `agent/disposed` | ✅ `:1448` |
|
|
86
|
+
| `session.requestContext()` / `deriveMessages()` | ✅ `dsh-session` `:1708` / `:1753` |
|
|
87
|
+
| `agent.model.select()` | ✅ `dsh-agent` `model-selection.js:88`(2.2.3 的故障转移落点) |
|
|
88
|
+
| `agent.followup()` | ✅ `dsh-agent-loop` `:579`(2.2.3 的自动续跑) |
|
|
89
|
+
| 派发入口 | ✅ `startActivation(spec)`(`dsh-subagent` `:3018`),**spec 仍是扁平形状**,2.2.2 的形状自适应(探测键 `prompt`)继续正确 |
|
|
90
|
+
| `provider.capabilities.agentOptions` | ✅ spawn / fork 两个 in-process provider 都仍声明 `agentOptions: true` |
|
|
91
|
+
| `request/header` 的 `reason` | ✅ `initial` / `resume` / `change` / `series` 四种未变(`:1045` / `:1051` / `:1056`) |
|
|
92
|
+
| `Symbol.for("cordis.original")` | ✅ `cordis` `:39` |
|
|
93
|
+
| 客户端槽位 | ✅ `settings.section` 与 `settings.section.icon` 都有本插件 occupant 且 `active: true` |
|
|
94
|
+
| peer 区间覆盖 | ✅ `>=0.1.7-rc.1 <0.3.0-0` 放行 rc.3 / rc.4 / rc.5(`semver.satisfies` 实测 true),仍挡住 `0.3.0-rc.1` |
|
|
95
|
+
|
|
96
|
+
#### 升级指南这次终于跟上了
|
|
97
|
+
|
|
98
|
+
`docs/upgrade-guide/` 新增两个目录(此前最新是 `v0.2.2-rc.1`):
|
|
99
|
+
|
|
100
|
+
- `v0.2.2-rc.3/deepseek-refusal-code` —— 拒答错误码从 `MALFORMED_RESPONSE` 改为 `CONTENT_REFUSED`;
|
|
101
|
+
- `v0.2.2-rc.4/web-search-deepseek-model-default` —— DeepSeek 模型上的搜索默认改用旧版 Messages 搜索。
|
|
102
|
+
|
|
103
|
+
两条**都落在插件未触碰的面上**,无需迁移。`0.2.2-rc.2`(扁平化 `SubagentActivationSpec`)依旧没有指南,那条只能靠逐包比对发现。
|
|
104
|
+
|
|
105
|
+
#### rc.2 → rc.3:11 个包有真实代码改动
|
|
106
|
+
|
|
107
|
+
| 包 | 改动 | 与本插件的关系 |
|
|
108
|
+
| --- | --- | --- |
|
|
109
|
+
| `dsh-client-ui-sidebar` | 新增 `sidebar.session.action` HOC 槽 | 插件只注册 `settings.section` / `settings.section.icon`,不碰侧栏会话行 |
|
|
110
|
+
| `dsh-client-ui-workspace` | Workspace picker 重整为 `WorkspacePickerFactory` | 与本插件无关 |
|
|
111
|
+
| `dsh-client-ui-directory-picker-browse` / `-native` | 跟随上述 picker 改造 | 与本插件无关 |
|
|
112
|
+
| `dsh-client-ui-primitives` | 新增 `IconUploadOutline{Regular,Medium}` | 纯新增;插件只用到 `Toast` 与 `IconChevronDown*`,全部仍在 |
|
|
113
|
+
| `dsh-deepseek-chat-import` | **新包**:DeepSeek 聊天记录导入为 Session | 与本插件无关;rc.3 唯一新增的 bundle |
|
|
114
|
+
| `dsh-session-log-export` | 归档导出容错:单个附件读不出来时记入 `missing` 继续导出 | 与本插件无关 |
|
|
115
|
+
| `dsh-cordis-client-runner` | 内嵌 `CLIENT_SLOT_API` 行号引用 | 纯文档字符串 |
|
|
116
|
+
| `dsh-tool-cordis` | 内嵌 `SERVICE_API` 新增 `deepseekChatImport.limits` | 纯文档字符串 |
|
|
117
|
+
| `dsh-agent-preset` | `dsh-doc` skill 的 `references/packages.md` 增一行 | 纯文档 |
|
|
118
|
+
| `dsh-official-bundles` | 把 `@deepseek-ai/dsh-deepseek-chat-import` 列入三个 bundle 清单 | 与本插件无关 |
|
|
119
|
+
|
|
120
|
+
#### rc.2 → rc.3 的契约复核(行号与 rc.2 逐位相同)
|
|
121
|
+
|
|
122
|
+
`core` / `subagent` / `llm` / `settings` / `session` / `boot` 六组共 57 个文件**全部只是 `package.json` 版本号**。当时逐项复核的结论与上面的 rc.5 表一致,唯一的差别是失败码词表当时还只有 `RATE_LIMIT` / `QUOTA` / `EMPTY_RESPONSE` / `CONTEXT_WINDOW_EXCEEDED` 等;`CONTENT_REFUSED` 是 rc.4 才加进来的。
|
|
123
|
+
|
|
124
|
+
### Fixed
|
|
125
|
+
|
|
126
|
+
- **「应当通过」的宿主版本清单第六次滞后**:清单停在 `0.2.2-rc.3`。2.1.8 加的自检用例照例直接失败:
|
|
127
|
+
|
|
128
|
+
```text
|
|
129
|
+
✖ the running host 0.2.2-rc.5 must be listed in ADMITTED_HOST_VERSIONS
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
补 `0.2.2-rc.4` **与** `0.2.2-rc.5`:跨版本升级必须把跳过的版本一并列上,否则一台仍停在 rc.4 的机器上跑同一份已评审清单会失败。
|
|
133
|
+
|
|
134
|
+
变异验证(**注意只有一半测得出来**):删掉 `0.2.2-rc.5` → `fail 1`;删掉 `0.2.2-rc.4` → **仍然 `fail 0`**,因为这台机器装的是 rc.5,而该用例只断言本机那一个版本。这是「清单记录的是已评审集合,不是本机版本」那条判据的实证——**rc.4 那一行没有任何测试替你守着**,只能靠人记得补。
|
|
135
|
+
|
|
136
|
+
> 这道自检只覆盖**版本号漏列**,不覆盖**契约变化**。rc.2 那次扁平化 spec 的破坏性变更正是它看不见的——那次是靠逐包 diff 发布物找到的。
|
|
137
|
+
|
|
138
|
+
### Docs
|
|
139
|
+
|
|
140
|
+
`DEVELOPMENT.md`:
|
|
141
|
+
|
|
142
|
+
1. 「宿主升级流程」第 1 步换成可直接粘贴的一行命令(asar 内不能 `ls`/`cat`,但能 `node` 读),新增第 4 步「逐包比对发布物」,并把 `skipped` 必须为 0 写进判据。
|
|
143
|
+
2. 契约行号表:表头 `rc.3` / `rc.5` 改为全称 `0.2.1-rc.3` / `0.2.1-rc.5`(与 `0.2.2-rc.3` 撞名,核对时极易看错列),新增 `0.2.2-rc.3` 与 `0.2.2-rc.5` 两列(两者行号完全相同)。
|
|
144
|
+
3. 新增一张「2.2.3 / 2.2.4 之后额外依赖的契约」表:`agent.model.select()`、`agent.followup()`、`session.deriveMessages()`、`agent.disposed`、失败码词表、`cordis.original`。
|
|
145
|
+
4. 「逐包比对」一节补 rc.2 → rc.3 与 rc.3 → rc.5 的实操结论,并新增判据:**关键词零命中不等于契约没了**(失败码在 `dsh-llm`、`cordis.original` 定义在 `cordis`,搜错包会得出反结论)。
|
|
146
|
+
|
|
147
|
+
> 升级指南从 rc.3 起补上了(见上),但 `0.2.2-rc.2` 仍然缺席。发布物比对依旧是发现契约变化的唯一可靠手段。
|
|
148
|
+
|
|
149
|
+
### Tests
|
|
150
|
+
|
|
151
|
+
全量:`tests 198 / pass 198 / fail 0 / skipped 0`(用例数与 2.2.4 相同,本版未新增用例)。
|
|
152
|
+
|
|
153
|
+
### 需要决定的一项(尚未改动,等你定)
|
|
154
|
+
|
|
155
|
+
核对失败码时发现插件**当前切换的码集与实际会发生的失败对不上**。这不是本次升级引入的,是 8 月底 failover v1.0.0 写定码集后、宿主陆续加码造成的。下表是**实测**——用插件真实的 `agent/request-error` 监听器跑出来的,不是读常量:
|
|
156
|
+
|
|
157
|
+
| 失败码 | 宿主会不会抛 | 插件是否切换 |
|
|
158
|
+
| --- | --- | --- |
|
|
159
|
+
| `RATE_LIMIT` / `QUOTA` / `SERVER` / `TIMEOUT` / `TRANSPORT` / `EMPTY_RESPONSE` | 会 | ✅ 切换 |
|
|
160
|
+
| `AUTH` / `INVALID_CREDENTIAL` | 会 | ✅ 切换 |
|
|
161
|
+
| `STREAM_CLOSED` | **会**(`dsh-llm-deepseek:2096`、`dsh-llm-pi-ai:1688`:流在 `message_stop` 前断掉) | ❌ **不切换** |
|
|
162
|
+
| `ACCOUNT_QUOTA` | **会**(`dsh-llm-deepseek-account:87`,账号额度耗尽时把 `QUOTA` 改写成它) | ❌ **不切换** |
|
|
163
|
+
| `MALFORMED_RESPONSE` | 会(SSE 坏帧) | ❌ 不切换(宿主自己标了 `retryChoice`,但换一家未必还会坏) |
|
|
164
|
+
| `CONTENT_REFUSED` | 会(内容拒答) | ❌ 不切换(**正确**:换一家也会被拒) |
|
|
165
|
+
|
|
166
|
+
前两条是实质缺口:**流被中断**和**账号额度耗尽**恰好都是换一家供应商很可能成功的场景,却直接放行错误、结束子代理。`docs/per-model-retry-design.md` 的原始需求是「连接类失败就换」,`STREAM_CLOSED` 正属于连接类。
|
|
167
|
+
|
|
168
|
+
另有一处文档不一致:2.1.10 的核查表把 `ACCOUNT_QUOTA` 列为「已核对」的失败码,但插件源码里从来没有它。
|
|
169
|
+
|
|
170
|
+
**没有动它**,因为这是行为变更(会让上面两种失败从此触发切换),不属于「升级跟进」的范围。要修的话单独起一版。
|
|
171
|
+
|
|
3
172
|
## 2.2.4 (2026-11-13)
|
|
4
173
|
|
|
5
174
|
### Changed
|
package/README.en.md
CHANGED
|
@@ -27,7 +27,7 @@ With `failoverEnabled` (on by default), when a subagent hits a **connection-clas
|
|
|
27
27
|
|
|
28
28
|
- **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.
|
|
29
29
|
- **Two classes of trigger code** —
|
|
30
|
-
- **Connection-class**: `RATE_LIMIT`, `QUOTA`, `SERVER`, `TIMEOUT`, `TRANSPORT`, `EMPTY_RESPONSE`.
|
|
30
|
+
- **Connection-class**: `RATE_LIMIT`, `QUOTA`, `ACCOUNT_QUOTA`, `SERVER`, `TIMEOUT`, `TRANSPORT`, `EMPTY_RESPONSE`, `STREAM_CLOSED`.
|
|
31
31
|
- **Auth-class**: `AUTH`, `INVALID_CREDENTIAL` (HTTP 401/403 — an invalid, expired, or unauthorised key).
|
|
32
32
|
- Auth-class failures **do** switch: when each provider holds its own credentials, one bad key must not kill the whole delegation while healthy providers sit unused.
|
|
33
33
|
- **But an auth switch always emits a warning** naming the provider whose key was refused. That is deliberate: switching buys resilience, and the **log line** is what keeps the misconfiguration from being silently hidden.
|
|
@@ -252,7 +252,7 @@ CI runs the same suite on `ubuntu-latest`, `windows-latest`, and `macos-latest`,
|
|
|
252
252
|
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:
|
|
253
253
|
|
|
254
254
|
- **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.
|
|
255
|
-
- **Trigger codes** — connection-class: `RATE_LIMIT`, `QUOTA`, `SERVER`, `TIMEOUT`, `TRANSPORT`, `EMPTY_RESPONSE`; auth-class: `AUTH`, `INVALID_CREDENTIAL` (invalid/expired key — switches, with a warning). Other codes do not switch.
|
|
255
|
+
- **Trigger codes** — connection-class: `RATE_LIMIT`, `QUOTA`, `ACCOUNT_QUOTA`, `SERVER`, `TIMEOUT`, `TRANSPORT`, `EMPTY_RESPONSE`, `STREAM_CLOSED`; auth-class: `AUTH`, `INVALID_CREDENTIAL` (invalid/expired key — switches, with a warning). Other codes do not switch.
|
|
256
256
|
- `round-robin`: advance to the next model in the list (the queue).
|
|
257
257
|
- `random`: pick any model (without checking whether it was used before).
|
|
258
258
|
- **Needs ≥ 2 models** — with fewer than 2 entries in `models`, the feature is inactive.
|
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
- **不区分供应商** —— 候选来自整个 `models` 列表,**跨 provider 生效**。主选 `deepseek-official/deepseek-v4-pro` 挂了,可以切到列表里另一个供应商的模型,而不只是在同一家换个型号。
|
|
29
29
|
- **触发码分两类** ——
|
|
30
|
-
- **连接类**:`RATE_LIMIT`、`QUOTA`、`SERVER`、`TIMEOUT`、`TRANSPORT`、`EMPTY_RESPONSE`。
|
|
30
|
+
- **连接类**:`RATE_LIMIT`、`QUOTA`、`ACCOUNT_QUOTA`、`SERVER`、`TIMEOUT`、`TRANSPORT`、`EMPTY_RESPONSE`、`STREAM_CLOSED`。
|
|
31
31
|
- **认证类**:`AUTH`、`INVALID_CREDENTIAL`(HTTP 401/403,密钥无效/过期/无权限)。
|
|
32
32
|
- 认证类**也会切换**:当各家供应商密钥各自独立时,其中一家密钥失效不应该让整个任务死掉、而健康的供应商却在闲置。
|
|
33
33
|
- **但切换时一定会打 warn 日志**,明确指出「该供应商的密钥可能无效」——这是刻意设计:允许切换是为了可用性,而**日志**保证这个配置问题不会被静默掩盖。
|
|
@@ -252,7 +252,7 @@ CI 在 `ubuntu-latest`、`windows-latest`、`macos-latest` 三个平台上同时
|
|
|
252
252
|
开启 `failoverEnabled`(默认开启)后,子代理自身的循环遇到连接类失败时,插件会在 `models` 列表内按 `strategy` 自动切换模型并重试。完整说明见上文「[功能二:跨供应商故障转移](#功能二跨供应商故障转移--这条通了那条不通就换另一个供应商的模型)」,要点复述:
|
|
253
253
|
|
|
254
254
|
- **跨供应商** —— 候选是整个 `models` 列表,可以切到另一个 provider 的模型,不限于同一家换型号。
|
|
255
|
-
- **触发码** —— 连接类:`RATE_LIMIT`、`QUOTA`、`SERVER`、`TIMEOUT`、`TRANSPORT`、`EMPTY_RESPONSE`;认证类:`AUTH`、`INVALID_CREDENTIAL`(密钥无效/过期,会切换并打 warn 日志)。其余码不切换。
|
|
255
|
+
- **触发码** —— 连接类:`RATE_LIMIT`、`QUOTA`、`ACCOUNT_QUOTA`、`SERVER`、`TIMEOUT`、`TRANSPORT`、`EMPTY_RESPONSE`、`STREAM_CLOSED`;认证类:`AUTH`、`INVALID_CREDENTIAL`(密钥无效/过期,会切换并打 warn 日志)。其余码不切换。
|
|
256
256
|
- `round-robin`:按列表顺序切到下一个模型(队列)。
|
|
257
257
|
- `random`:随机挑一个模型(不判断之前是否用过)。
|
|
258
258
|
- **需要 ≥ 2 个模型** —— 当 `models` 少于 2 项时本功能不生效。
|
package/lib/index.js
CHANGED
|
@@ -195,8 +195,50 @@ const WRAPPED = Symbol.for("dsh-subagent-default-model.wrapped");
|
|
|
195
195
|
* Failure codes that count as "connection failed" (rate limit, quota, server /
|
|
196
196
|
* transport errors, empty responses). Switching on these is safe because a
|
|
197
197
|
* different model/provider may well succeed where the primary just failed.
|
|
198
|
+
*
|
|
199
|
+
* The list was written in 2026-08 against the failure codes the host raised
|
|
200
|
+
* THEN, and the host has added codes since. Two of them were missing until
|
|
201
|
+
* 2.2.6, and both are exactly the kind this feature exists for:
|
|
202
|
+
*
|
|
203
|
+
* - `STREAM_CLOSED` — the provider's stream ended before its terminal event
|
|
204
|
+
* (`dsh-llm-deepseek`: "DeepSeek Messages stream ended before message_stop";
|
|
205
|
+
* `dsh-llm-pi-ai`: "pi-ai event stream ended without done/error"). A dropped
|
|
206
|
+
* connection mid-stream is the textbook case for trying another provider,
|
|
207
|
+
* yet the plugin used to pass the error straight through and end the
|
|
208
|
+
* subagent.
|
|
209
|
+
* - `ACCOUNT_QUOTA` — `dsh-llm-deepseek-account` REWRITES a plain `QUOTA` into
|
|
210
|
+
* this code when the *account's* balance is exhausted. It is the same
|
|
211
|
+
* situation as `QUOTA` (which this list always had), just told apart from a
|
|
212
|
+
* per-key quota; skipping it meant the one code that says "this account is
|
|
213
|
+
* out of credit" was the one code that never triggered a switch.
|
|
214
|
+
*
|
|
215
|
+
* Deliberately still absent:
|
|
216
|
+
*
|
|
217
|
+
* - `CONTENT_REFUSED` — the provider's safety review rejected the content.
|
|
218
|
+
* Another provider would refuse the same request, so switching only burns
|
|
219
|
+
* the pool.
|
|
220
|
+
* - `CONTEXT_WINDOW_EXCEEDED`, `IMAGE_OFFLOAD_REQUIRED`, `INVALID_REQUEST` —
|
|
221
|
+
* the request itself is wrong; retrying it elsewhere fails identically.
|
|
222
|
+
* - `MALFORMED_RESPONSE` — kept out on purpose even though the host marks it
|
|
223
|
+
* `retryChoice`. A malformed stream is a real candidate for "this provider is
|
|
224
|
+
* broken", but it is also what a permanent adapter bug looks like, and the
|
|
225
|
+
* plugin has no way to tell them apart. Adding a code here is cheap; adding
|
|
226
|
+
* one that turns a deterministic parse failure into a pool-wide burn is not.
|
|
227
|
+
*
|
|
228
|
+
* `test/failover-codes.test.mjs` pins this list against the host's own failure
|
|
229
|
+
* code vocabulary, so a future host release that adds a code fails a test
|
|
230
|
+
* instead of silently going unswitched.
|
|
198
231
|
*/
|
|
199
|
-
const FAILOVER_TRIGGER_CODES = [
|
|
232
|
+
const FAILOVER_TRIGGER_CODES = [
|
|
233
|
+
"RATE_LIMIT",
|
|
234
|
+
"QUOTA",
|
|
235
|
+
"ACCOUNT_QUOTA",
|
|
236
|
+
"SERVER",
|
|
237
|
+
"TIMEOUT",
|
|
238
|
+
"TRANSPORT",
|
|
239
|
+
"EMPTY_RESPONSE",
|
|
240
|
+
"STREAM_CLOSED"
|
|
241
|
+
];
|
|
200
242
|
|
|
201
243
|
/**
|
|
202
244
|
* Auth failures, handled SEPARATELY from the connection codes above.
|
|
@@ -219,8 +261,19 @@ const FAILOVER_TRIGGER_CODES = ["RATE_LIMIT", "QUOTA", "SERVER", "TIMEOUT", "TRA
|
|
|
219
261
|
*/
|
|
220
262
|
const AUTH_FAILURE_CODES = ["AUTH", "INVALID_CREDENTIAL"];
|
|
221
263
|
|
|
222
|
-
/**
|
|
223
|
-
|
|
264
|
+
/**
|
|
265
|
+
* Every failure code that may trigger a switch.
|
|
266
|
+
*
|
|
267
|
+
* Exported as a read-only test seam, the same convention `volatileField` and
|
|
268
|
+
* `Config` follow: `test/failover-codes.test.mjs` compares it against the
|
|
269
|
+
* host's own failure-code vocabulary, and a hand-copied duplicate inside the
|
|
270
|
+
* test would defeat the point (it would keep passing after this list changed).
|
|
271
|
+
* The module loader only reads `apply` / `inject`.
|
|
272
|
+
*/
|
|
273
|
+
export const FAILOVER_ELIGIBLE_CODES = Object.freeze([...FAILOVER_TRIGGER_CODES, ...AUTH_FAILURE_CODES]);
|
|
274
|
+
|
|
275
|
+
/** The connection-class subset, exported alongside for the same reason. */
|
|
276
|
+
export const FAILOVER_TRIGGER_CODE_SET = Object.freeze([...FAILOVER_TRIGGER_CODES]);
|
|
224
277
|
|
|
225
278
|
/**
|
|
226
279
|
* Whether this host fixes the step's route and only sanctions changing it
|