rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:HelloQingTao/dsh-model-fallback-queue
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
English | 中文
当前模型限额、限流或不可用时,自动切到队列里的下一个模型,把会话接着跑完。开关、队列、P1 恢复策略都在设置页里点,不需要命令行。
openedAt 一起刷新,60s 冷却永远滑不到头(现象就是「刚探测还有 2 个可用,发一句话全红了」)。其余路由照常倒计时,到点自动回半个开。上一轮:P3 · 成功 · 12s前 / 上一轮:P3 · 失败 · QUOTA);还没发过消息就写「还没发过消息」,刚切换就写「已切到 P3,下一条消息会用它」。没有探测伪造的「验证通过」,也没有自相矛盾的「P1 验证失败」。maxTokens 可调(默认 8,在「高级」折叠区;1 会被一部分网关按 400 拒绝,于是「能正常对话的模型」长期显示探测失败)。插件内部仍保留「发一条和真实对话同形的请求」的验证能力,但设置页队列行已不再放「验证」按钮,界面更简洁。P1 失败、队列切到另一个 provider/model 时,宿主的请求里有两类内容不能原样带过去:
适配器物化的控制字段。 宿主的 prepareCall 会把 P1 适配器的默认输出上限物化进请求
(DeepSeek 适配器默认 maxTokens: 256000)。旧实现只剥 reasoningEffort,把 maxTokens
原样带给目标;z.ai/GLM 的上限是 131072,于是直接
400 code 1210 "The max_tokens parameter is illegal.:限制数值范围[1,131072]"。
现在换路由时一并剥掉 maxTokens——目标模型经宿主的 prepareCall 解析自己的默认值。
跨适配器不可重放的 thinking。 历史 assistant 消息的 thinking 只在同一适配器 + 同一模型
下可重放;跨 provider/model 切换时宿主会丢掉 reasoning,而 DeepSeek 的 Anthropic 兼容
端点要求「text + tool_use」的 assistant 消息必须带 thinking 块,否则
400 "Thecontent[].thinkingin the thinking mode must be passed back to the API."。
现在对 strictThinkingProviders(默认 deepseek-official)下发的请求,把这类消息的 text 块
摘掉(tool_use、参数、工具结果不动)——这是该 API 接受的形状,也是跨适配器降级时最小的损失。
原生可重放与否由 nativeReplayKinds(provider=replayKind,默认
deepseek-official=deepseek-messages)判断。
新增配置:strictThinkingProviders(string[])、nativeReplayKinds(string[],provider=kind)。
测试:node scripts/test-route-adaptation.mjs,以及 scripts/verify-execution.mjs 场景 H/H-2。
设置页(开关 / 队列 / P1 恢复策略):

输入框右侧的芯片与展开面板:

dsh plugin --profile web add dsh-model-fallback-queue
装完重启 dsh(或刷新 Web GUI),bundle 会随包里的 cordis.patch.yml 自动注册。
发生切换时,会话里会出现核心自带的「模型已切换」通知,芯片同步切到新路由。
芯片状态
| 显示 | 含义 |
|---|---|
P1 + 绿点 |
正常走 P1 |
P2(黄点) |
已切到 P2;黄点表示半开探测中 |
P! + 红点 |
队列全部熔断,已降级放行原配置 |
P(灰点) |
插件未启用 |
恢复策略三档
| 档位 | 行为 |
|---|---|
| 粘滞(默认) | 切到 P2 后只要 P2 可用就一直用,P1 恢复也不切回;P2 也挂时按邻近可用往后找,绕回 P1 是最后手段。 |
| 探测回切 | P1 冷却到期后,由下一个真实请求探测回 P1;成功留下,失败回 P2(防抖 5 分钟,不发额外探测流量)。 |
| 手动回切 | 切走后不自动回 P1,用芯片面板里的「切回 P1」恢复。 |
三档都按会话隔离:每个会话各自记「锚点」(上一轮真正作答成功的那条路由),新消息的换路链从锚点起跑,不再每条消息都从 P1 重撞一遍。探测回切/手动回切只决定「锚点是否自动回到 P1」,不影响锚点本身的按会话隔离。
| 字段 | 默认值 | 说明 | 设置页可改 |
|---|---|---|---|
enabled |
false |
总开关 | ✅ |
queue |
[] |
后备队列,数组顺序即优先级(存在 ~/.dsh/fallback-queue-state.json,不在 settings 里,见下方说明) |
✅ |
failbackMode |
sticky |
sticky / probe / manual |
✅ |
p1Follow |
true |
P1 跟随当前会话模型 | — |
immediateCodes |
QUOTA、ACCOUNT_QUOTA、RATE_LIMIT、AUTH、INVALID_CREDENTIAL、NO_ADAPTER |
命中即熔断的错误码 | — |
failureThreshold |
2 |
非即时码的连续失败阈值 | — |
cooldownMs |
60000 |
熔断冷却毫秒 | — |
failbackDelayMs |
300000 |
探测回切防抖毫秒 | — |
日常用的开关、队列、恢复策略都在设置页;标「—」的高级旋钮默认值适用于绝大多数场景,需要时写进 ~/.dsh/profiles/<profile>/cordis.patch.yml 里本插件那一行的 config。
为什么队列不放在 settings 里:DSH 的 ui-theme 只要你写一次 settings 文档,就会重推一次主题快照,前端随之把整页 design token 逐个移除再写回,深色模式下会闪一帧白。队列排序是高频操作(反复点上下箭头调优先级),放在 settings 里每点一次闪一次;改存独立的 JSON 文件就完全不碰 settings revision,白闪消失。
队列文件是插件私有数据,不在设置页的配置导出/备份范围内,换机器需要重新排序。首次升级时如果文件不存在,会自动把 settings 里的旧队列迁移过来,所以已有配置不会丢。
0.2.0-rc.2、0.2.1-rc.2(宿主 + Web GUI)。package.json 的 engines.dsh 为准(当前 >=0.2.0-rc.2 <0.3.0)。dsh-client-auto-continue 天然兼容:自动续发走同一条请求瀑布,一样享受队列切换。dsh-llm-retry 分层:它管同路由退避重试,本插件管跨路由切换。① 厂商勾选批量添加(F1):点「+ 添加模型」打开选择器,顶部按厂商分组(来自 DSH 内置模型目录 group.id),每组是复选框列表,可跨厂商一次勾选多个;点底部「添加 N 个到队列」批量入队,顺序=先厂商、后组内展示序。已入队的行整行置灰防重复,勾了也不会再添。
② 拖动排序(F5):队列行支持按住拖动调整顺序(行首有 ⠿ 手柄提示,整行可拖)。队列采用纯物理顺序:你在界面上看到的从上到下,就是故障转移的尝试顺序,所见即所得,没有「大保底」这类隐藏排序规则。P1 槽(当前会话模型)始终最先。
③ 免费/付费标记(F3):每个行有一个小胶囊标签(像输入框里的 chip),旁边的「标记」按钮在「未标注 → 免费 → 付费 → 未标注」间轮转。标签为中性色(颜色通道专供健康状态,价格不抢色,避免把"付费"误读成"有问题")。芯片面板同步显示。该标注只做展示辅助,不参与排序、不做自动判定(没有可靠的免费/付费数据源,不猜)。
④ 快速探测 ping(F4):队列标题右侧的「探测全部」一键限并发探测队列里所有模型可用性(默认并发 4,可配 probeConcurrency;墙钟时间≈最慢一条而非全部之和),结束后提示「可用 N / 不可用 M」;芯片面板也有同款按钮。周期健康探测收在设置页「高级:周期健康探测(默认关闭)」折叠区里,展开后可配:周期探测间隔(毫秒,0=关闭,默认 0=不开启;填 60000 即每 60 秒一轮)+ 周期探测跳过付费模型(默认开,省配额)+ 探测请求 maxTokens(默认 8,可改 1–512)。⚠ 周期探测会向模型发真实请求,可能消耗配额/费用,所以默认不自动开启——升级后你的存量设置保持原样。
When your current model hits its quota, gets rate-limited or becomes unavailable, requests automatically fail over to the next model in your queue and the session keeps going. The switch, the queue and the P1 recovery mode are all configured from the Settings UI — no CLI needed.
maxTokens is adjustable (default 8; a value of 1 gets rejected with 400 by some gateways, which made perfectly chatty models look permanently broken). Every queue row also has a Verify button that sends one request shaped exactly like a real conversation and reports success/failure, error code, latency and token usage — a probe is always a trimmed-down request, only a real-shaped request counts as evidence.Settings page (switch / queue / P1 recovery mode):

The chip next to the input box and its expanded panel:

dsh plugin --profile web add dsh-model-fallback-queue
Restart dsh (or reload the Web GUI); the bundle registers itself through the cordis.patch.yml shipped in the package.
On every switch the core “model switched” notice appears in the session and the chip follows.
Chip states
| Chip | Meaning |
|---|---|
P1 green dot |
Running on P1 |
P2 amber dot |
Switched to P2; amber means a half-open probe is in flight |
P! red dot |
Every route tripped — original config passed through |
P grey dot |
Plugin disabled |
Recovery modes
| Mode | Behaviour |
|---|---|
| Sticky (default) | Once on P2 it stays there while P2 works, even after P1 recovers; if P2 also fails it walks forward and only wraps back to P1 as a last resort. |
| Probe back | After P1's cooldown expires the next real request probes P1; success keeps it, failure returns to P2 (5-minute debounce, no extra probe traffic). |
| Manual | Never returns to P1 automatically — use “Back to P1” in the chip panel. |
| Field | Default | Description | In Settings UI |
|---|---|---|---|
enabled |
false |
Master switch | ✅ |
queue |
[] |
Backups; array order = priority (stored in ~/.dsh/fallback-queue-state.json, not in settings — see below) |
✅ |
failbackMode |
sticky |
sticky / probe / manual |
✅ |
p1Follow |
true |
P1 follows the current session model | — |
immediateCodes |
QUOTA, ACCOUNT_QUOTA, RATE_LIMIT, AUTH, INVALID_CREDENTIAL, NO_ADAPTER |
Codes that trip a route immediately | — |
failureThreshold |
2 |
Consecutive failures for a soft trip | — |
cooldownMs |
60000 |
Circuit cooldown in ms | — |
failbackDelayMs |
300000 |
Probe-back debounce in ms | — |
The everyday switch, queue and recovery mode live in the Settings UI; the advanced knobs marked “—” keep sensible defaults and can be set in the plugin row's config inside ~/.dsh/profiles/<profile>/cordis.patch.yml.
Why the queue is not in settings: any write to a DSH settings document makes ui-theme republish the theme snapshot, and the client then removes and rewrites every design token for the whole page — in dark mode that shows up as a one-frame white flash. Reordering the queue is frequent (you keep clicking the up/down arrows), so keeping it in settings meant a flash per click. Storing it in a standalone JSON file never touches the settings revision, and the flash is gone.
That file is plugin-private data and is outside the Settings UI's config export/backup, so ordering must be redone on another machine. On the first upgrade, if the file is missing, the old queue in settings is migrated automatically — existing configuration is not lost.
0.2.0-rc.2 and 0.2.1-rc.2 (host + Web GUI).engines.dsh in package.json (currently >=0.2.0-rc.2 <0.3.0).dsh-client-auto-continue: auto-continue rides the same request waterfall, so it benefits from failover too.dsh-llm-retry: it handles same-route backoff, this plugin handles cross-route failover.① Batch add by vendor (F1). Click “+ Add model”; the picker lists vendors (from the built-in DSH model catalog group.id) with a checkbox list per vendor. Tick across vendors, then “Add N to queue” appends them all in vendor → in-group order. Rows already in the queue are disabled and deduped.
② Drag to reorder (F5). Queue rows are drag-and-drop reorderable (a ⠿ handle hints it; the whole row is draggable). The queue uses a pure physical order: what you see top-to-bottom is exactly the failover try order — WYSIWYG, with no hidden "safety-net" rule. The P1 slot (current session model) always goes first.
③ Free/paid marks (F3). Each row shows a small pill badge (like an input chip) plus a "Mark" button that cycles unmarked → free → paid → unmarked. Badges stay neutral (colour is reserved for health, so "paid" isn't misread as "trouble"). The chip panel mirrors it. Purely a display aid — never used for ordering or auto-detected.
④ Fast ping probe (F4). The “Probe all” button (in the settings page next to the queue, and in the chip panel) pings every queue model serially and reports “N ok / M unavailable”. Below the queue, periodic health probing is configured via probe interval (ms, 0 = off, default 0 = disabled; enter 60000 for once a minute), skip paid models in periodic probes (default on, saves quota; turn it off to probe paid models too) and probe request maxTokens (default 8, editable 1–512; too small a value gets rejected with 400 by some gateways). ⚠ Periodic probing sends real requests to models and can consume quota/cost, so it stays off until you enable it — existing settings are left untouched on upgrade.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: llm、deepseek-harness。