dsh-model-think-level 2.6.0 → 2.6.1
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/README.md +10 -6
- package/lib/history-compat.d.ts +12 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ DSH 自带的 Models 页只认得它自己目录里的模型。中转站、自
|
|
|
20
20
|
- **自定义请求头** — 每个路由可配任意请求头(含 `user-agent`),在 fetch 层按请求重新盖回去;同源冲突、与官方适配器或同类插件的争抢都会被检出。
|
|
21
21
|
- **请求伪装** — 每个路由可选 Codex / Claude 两种官方 CLI 身份:客户端请求头,以及 Claude 的 Messages 请求体身份段一并补齐;默认关闭,与自定义请求头同一区块。
|
|
22
22
|
- **生图** — 勾一下「生图」就能把任意模型变成生图模型,对话模型调用原生工具 `generate_image` 出图,支持参考图改图、多图并出、默认参数与超时。
|
|
23
|
-
- **旧话题恢复** — 换过 Azure
|
|
23
|
+
- **旧话题恢复** — 换过 Azure 资源/中转账号池的上游会拒收旧话题带来的历史项(`item`):要么说「created under a different … resource」,要么说某个 `function_call` 缺少与它配对的那条 `reasoning`。打开后同时识别 `400` 响应体与 `200` 流内 `response.failed` 的这些拒绝,在发送副本的消息上下文里逐级去掉旧资源签发的句柄(必要时连历史推理一起),再重放这次请求,不删本地历史。
|
|
24
24
|
- **自动继续** — 会话因为断线、超时、撞上输出上限停住时,替你补一条「继续」,可展开配置等待秒数和最多重试次数。
|
|
25
25
|
- **余额** — 每个供应商可选配一个只读余额接口,模型页直接显示余额,支持手动刷新。
|
|
26
26
|
|
|
@@ -199,18 +199,22 @@ dsh plugin add .
|
|
|
199
199
|
|
|
200
200
|
## 旧话题恢复
|
|
201
201
|
|
|
202
|
-
同一个供应商如果换过 Azure
|
|
202
|
+
同一个供应商如果换过 Azure 资源、换过中转账号池,旧话题的下一条消息可能直接被拒。会见到两种说法:
|
|
203
203
|
|
|
204
204
|
```
|
|
205
205
|
The requested item was created under a different Azure OpenAI resource. Use the same resource that created the item to access it.
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
|
|
208
|
+
```
|
|
209
|
+
Item 'fc_04e5…' of type 'function_call' was provided without its required 'reasoning' item: 'rs_04e5…'.
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
前者是历史项的标识属于上一个资源;后者是同一次拆分的结果——中转把工具调用的 `fc_` 句柄留下了,却没把与它配对生成的那条 `rs_` 推理项一起重放,服务端按配对关系找不到兄弟项。**两者是同一件事:重放的历史和服务它的后端对不上。** 旧话题的历史项带着上一个资源签发的标识和加密推理,新资源不认识它们。这不是密钥失效,也不是模型不存在——换密钥、切协议、把话题清空重来都不对症,而且本地那段历史还在,换个入口发出去照样被拒。
|
|
209
213
|
|
|
210
|
-
|
|
214
|
+
「高级配置」里的第三块**旧话题恢复**就是为这两种拒绝准备的,默认关闭,按路由打开:
|
|
211
215
|
|
|
212
|
-
-
|
|
213
|
-
- **在原消息上下文上降级,逐级放宽**:第一次原样发送;命中后先只去掉重放历史里绑定旧资源的句柄——推理项 `thinkingSignature` 里的 `id`、文本项 `textSignature` 里的 `id`、工具调用 `id` 里的 `itemId`
|
|
216
|
+
- **认措辞,不认状态码**:这两种拒绝都可能以 `400` 出现(正文是 JSON,或中转把 400 当 SSE 流发回来),也可能以 `200` 的流内 `response.failed` 出现——流式 Responses 更常见的正是后者。两种都会识别,因为恢复引擎读的是那句精确措辞,而不是 HTTP 门牌。别的错误一律原样透传。
|
|
217
|
+
- **在原消息上下文上降级,逐级放宽**:第一次原样发送;命中后先只去掉重放历史里绑定旧资源的句柄——推理项 `thinkingSignature` 里的 `id`、文本项 `textSignature` 里的 `id`、工具调用 `id` 里的 `itemId` 半段(去掉它,被拆开的 `fc_`/`rs_` 也就不再触发配对校验);仍被拒就再停止重放历史推理(本地可见的思考文本不动)。恢复只发生在流还没把任何内容交给调用方之前;已经开始输出的回合不会被重放。
|
|
214
218
|
- **不动你保存的历史**:只改这一次请求的副本。`call_id`、工具调用与结果的配对、正文、顺序、`previous_response_id` 全部保留;`item_reference`、compaction 这类带密文的项不碰。
|
|
215
219
|
- **不牵连密钥与协议**:恢复在同一个候选密钥、同一个地址、模型和协议内完成;历史类失败不会把密钥记进冷却、不算协议失败、不触发自动继续。修不好时不换密钥——每把密钥都到同一个中转池,换只是把同样的失败多试几遍。
|
|
216
220
|
- **代价很小**:只有匹配到那句拒绝时才多读一次错误体(上限 64 KiB / 2 秒),或按需多跑一至两次降级重放;正常请求一个字节都不多看。
|
package/lib/history-compat.d.ts
CHANGED
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
* every key reaches the same relay, and the relay's own pool decides which
|
|
13
13
|
* resource sees the request.
|
|
14
14
|
*
|
|
15
|
+
* The same fan-out produces a second wording when the pool keeps a tool call's
|
|
16
|
+
* `fc_` handle but not the `rs_` reasoning item minted with it: the server
|
|
17
|
+
* answers `Item 'fc_…' of type 'function_call' was provided without its
|
|
18
|
+
* required 'reasoning' item: 'rs_…'`. That is the same condition — the replayed
|
|
19
|
+
* history and the backend serving it disagree about the items — so it shares
|
|
20
|
+
* one recognition point and one degradation ladder with the resource refusal.
|
|
21
|
+
*
|
|
15
22
|
* Two facts make this module structural rather than a fetch-layer patch:
|
|
16
23
|
*
|
|
17
24
|
* 1. The refusal arrives in more than one shape. A relay may answer `400` with
|
|
@@ -36,6 +43,8 @@
|
|
|
36
43
|
* item as new instead of resolving a foreign handle. A text signature cannot
|
|
37
44
|
* keep its `phase` once the id is gone: pi-ai only reads `{v:1, id, phase?}`,
|
|
38
45
|
* and a signature without a string `id` is sent verbatim as the item id.
|
|
46
|
+
* This is also the repair for a split `fc_`/`rs_` pair: with no item handle
|
|
47
|
+
* on the function call, the server stops looking for its reasoning sibling.
|
|
39
48
|
* 2. `drop_reasoning` — additionally stop replaying historical reasoning items
|
|
40
49
|
* altogether (the `thinkingSignature` is removed; the visible thinking text
|
|
41
50
|
* stays in the local history untouched). Reasoning is the other thing bound
|
|
@@ -53,7 +62,9 @@ export declare const HISTORY_INSPECT_LIMIT = 65536;
|
|
|
53
62
|
/** How long an error body may take before inspection is abandoned. */
|
|
54
63
|
export declare const HISTORY_INSPECT_TIMEOUT_MS = 2000;
|
|
55
64
|
/**
|
|
56
|
-
* Whether a provider message is the
|
|
65
|
+
* Whether a provider message is one of the foreign-history refusals: an item
|
|
66
|
+
* minted under another backend resource, or a tool call whose paired reasoning
|
|
67
|
+
* item the relay no longer replays.
|
|
57
68
|
* @param text - the error body or stream error message, decoded.
|
|
58
69
|
* @returns whether the history (not the request shape) is what failed.
|
|
59
70
|
*/
|
package/lib/index.js
CHANGED
|
@@ -3421,8 +3421,11 @@ var RESOURCE_MISMATCH = [
|
|
|
3421
3421
|
/created under a different [a-z0-9 ._-]{0,48}?resource/i,
|
|
3422
3422
|
/same resource that created the item/i
|
|
3423
3423
|
];
|
|
3424
|
+
var ITEM_PAIRING_MISMATCH = [
|
|
3425
|
+
/provided without its required [^\n]{0,40}?reasoning/i
|
|
3426
|
+
];
|
|
3424
3427
|
function isHistoryStateMismatch(text) {
|
|
3425
|
-
return RESOURCE_MISMATCH.some((pattern) => pattern.test(text));
|
|
3428
|
+
return RESOURCE_MISMATCH.some((pattern) => pattern.test(text)) || ITEM_PAIRING_MISMATCH.some((pattern) => pattern.test(text));
|
|
3426
3429
|
}
|
|
3427
3430
|
var HISTORY_STAGES = ["portable_ids", "drop_reasoning"];
|
|
3428
3431
|
function degradeForHistory(context, stage) {
|