dsh-subagent-default-model 1.2.2 → 1.2.3
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 +13 -0
- package/lib/index.js +41 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.3 (2026-09-16)
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- **故障转移切换到目标模型时,补上目标条目自己声明的 `reasoningEffort`**:`agent/request` 缝合处原本把继承来的 `reasoningEffort` 丢弃后**不再补值**,于是切换过去的请求仍带着上一条路由的 thinking 模式。对于「thinking 档位必须与 effort 一致」的 provider(pi-ai / anthropic-messages 一类),这会直接返回 `400 invalid thinking type, only be disabled when reasoning effort is none and enabled when reasoning effort is not none`。实测中该错误码为 `INVALID_REQUEST`、**不在**触发列表内,因此**不可重试**:故障转移把池子里所有候选逐个消耗在这个永远不可能成功的请求上,子代理最终失败——**尽管池中配置了健康模型**。现在目标条目声明了 effort 就用它;未声明时保持 `undefined`,由 adapter 解析该模型自身的 `defaultEffort`(或整个省略 reasoning 选项),不再继承目标可能不支持的上游档位。
|
|
8
|
+
- **故障转移不再重复选中本次运行已经切换过的池条目**:原 `nextFailoverIndex` 仅按 `count` 计数前进,不记录已尝试项;当无法从 `agent.session.requestContext()` 定位当前路由时(`found < 0`)直接回到 index 0,可能切回刚失败的模型或重复选同一个坏候选,白白消耗配额。现在按 `agent.id` 记录本次运行已切换到的索引集合并跳过它们;仅当全部条目都已尝试(或每次切换都失败)时才回落到普通轮询前进。
|
|
9
|
+
|
|
10
|
+
### Testing
|
|
11
|
+
|
|
12
|
+
- `plugin/test/failover.test.mjs` 新增两个回归用例:`applies the target entry's own reasoning effort when switching models`(断言切换产物为 `{ provider: "zzztoken", model: "deepseek-v4-pro", reasoningEffort: "max" }`)与 `does not re-select a pool entry this run already switched to`(三条目池,断言第二次切换落到未尝试过的条目)。前者已用回退验证确认可捕获原缺陷(回退实现即失败),不可静默回退。
|
|
13
|
+
- 为已有用例 `drops inherited reasoning effort when switching models` 补充注释,说明其断言仅适用于目标条目**未声明** effort 的情形,避免与新增用例的语义混淆。
|
|
14
|
+
- 全部 48 项测试通过(原 46 项 + 新增 2 项)。
|
|
15
|
+
|
|
3
16
|
## 1.2.2 (2026-09-10)
|
|
4
17
|
|
|
5
18
|
### Fixes
|
package/lib/index.js
CHANGED
|
@@ -186,7 +186,8 @@ function isSubagentAgent(agent) {
|
|
|
186
186
|
* Pick the next pool index for one failed subagent request.
|
|
187
187
|
*
|
|
188
188
|
* - round-robin: the next entry after the currently-served model, wrapping
|
|
189
|
-
* around the list (the "queue")
|
|
189
|
+
* around the list (the "queue"), skipping entries this run already tried so a
|
|
190
|
+
* single bad candidate is not re-selected while an untried one remains.
|
|
190
191
|
* - random: any entry, without checking whether it was used before — a random
|
|
191
192
|
* pick may repeat the failing model, which is fine by design (simplest).
|
|
192
193
|
*/
|
|
@@ -195,13 +196,27 @@ function nextFailoverIndex(view, agent, current) {
|
|
|
195
196
|
if (strategy === "random") {
|
|
196
197
|
return Math.floor(Math.random() * entries.length);
|
|
197
198
|
}
|
|
198
|
-
|
|
199
|
+
const tried = current?.tried;
|
|
200
|
+
if (current !== void 0) {
|
|
201
|
+
// Advance from the last pick, taking the first entry this run has not used.
|
|
202
|
+
for (let step = 1; step <= entries.length; step += 1) {
|
|
203
|
+
const candidate = (current.index + step) % entries.length;
|
|
204
|
+
if (tried === void 0 || !tried.has(candidate)) return candidate;
|
|
205
|
+
}
|
|
206
|
+
return (current.index + 1) % entries.length;
|
|
207
|
+
}
|
|
199
208
|
// First failure: locate the served route in the pool and move to the next.
|
|
200
209
|
const served = agent.session?.requestContext?.();
|
|
201
210
|
const found = served === void 0 ? -1 : entries.findIndex((entry) =>
|
|
202
211
|
entry.provider === served.provider && entry.model === served.model
|
|
203
212
|
);
|
|
204
|
-
|
|
213
|
+
if (found < 0) return 0;
|
|
214
|
+
// Start after the served entry, preferring one this run has not used.
|
|
215
|
+
for (let step = 1; step <= entries.length; step += 1) {
|
|
216
|
+
const candidate = (found + step) % entries.length;
|
|
217
|
+
if (tried === void 0 || !tried.has(candidate)) return candidate;
|
|
218
|
+
}
|
|
219
|
+
return (found + 1) % entries.length;
|
|
205
220
|
}
|
|
206
221
|
|
|
207
222
|
/**
|
|
@@ -231,8 +246,13 @@ function installFailover(ctx, state) {
|
|
|
231
246
|
// `entries.length - 1` switches, then let the real error surface.
|
|
232
247
|
if (current !== void 0 && current.count >= view.entries.length - 1) return next(); // pool exhausted
|
|
233
248
|
const index = nextFailoverIndex(view, agent, current);
|
|
249
|
+
// Remember every pool entry this run has already been switched to, so a
|
|
250
|
+
// candidate that fails again is not selected a second time.
|
|
251
|
+
const tried = new Set(current?.tried ?? []);
|
|
252
|
+
tried.add(index);
|
|
234
253
|
pending.set(agent.id, {
|
|
235
254
|
index,
|
|
255
|
+
tried,
|
|
236
256
|
count: (current?.count ?? 0) + 1
|
|
237
257
|
});
|
|
238
258
|
ctx.logger.warn(
|
|
@@ -251,8 +271,21 @@ function installFailover(ctx, state) {
|
|
|
251
271
|
});
|
|
252
272
|
|
|
253
273
|
// On the rebuilt request for that subagent: swap the seed route for the
|
|
254
|
-
// pending pool entry
|
|
255
|
-
//
|
|
274
|
+
// pending pool entry, carrying the target's OWN request controls.
|
|
275
|
+
//
|
|
276
|
+
// The inherited `reasoningEffort` is dropped because it belongs to the route
|
|
277
|
+
// that just failed. The failure this fixes: without re-applying the target's
|
|
278
|
+
// declared effort, the fallback is dispatched with the previous route's
|
|
279
|
+
// thinking mode, and a provider whose thinking level must agree with the
|
|
280
|
+
// effort rejects it with e.g. "invalid thinking type, only be disabled when
|
|
281
|
+
// reasoning effort is none ...". That error is NOT retryable, so the
|
|
282
|
+
// failover burns every remaining candidate on a request that can never
|
|
283
|
+
// succeed — the subagent dies even though a healthy model was available.
|
|
284
|
+
//
|
|
285
|
+
// When the target declares no effort, sending the key as `undefined` is the
|
|
286
|
+
// correct dispatch: the adapter then resolves the model's own
|
|
287
|
+
// `defaultEffort` (or omits the reasoning option entirely), instead of
|
|
288
|
+
// inheriting a level the target may not support.
|
|
256
289
|
const disposeRequest = ctx.on("agent/request", async (payload, next) => {
|
|
257
290
|
const view = failoverView(state);
|
|
258
291
|
if (view === void 0) return next();
|
|
@@ -265,7 +298,9 @@ function installFailover(ctx, state) {
|
|
|
265
298
|
const seed = await next();
|
|
266
299
|
if (seed === void 0 || seed === null) return seed;
|
|
267
300
|
const { reasoningEffort: _inherited, ...rest } = seed;
|
|
268
|
-
|
|
301
|
+
const switched = { ...rest, provider: target.provider, model: target.model };
|
|
302
|
+
if (target.reasoningEffort !== void 0) switched.reasoningEffort = target.reasoningEffort;
|
|
303
|
+
return switched;
|
|
269
304
|
});
|
|
270
305
|
|
|
271
306
|
// Drop per-agent state once the subagent is disposed.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-subagent-default-model",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Configure default model routes for DeepSeek Harness subagents, with single-model, round-robin, random, and per-route reasoning-effort options.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|