返回目录
模型与 MCP 插件

dsh-model-fallback

zznobzz/dsh-model-fallback

Model failover for DeepSeek Harness: repeat a failed primary model request on a fallback route, with selectable trigger mode, failure-code selection, and a switch-over threshold.

Stars
0
Forks
0
Issues
0
更新
9 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:zznobzz/dsh-model-fallback

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

@zznobzz/dsh-model-fallback

Model failover for DeepSeek Harness.

Install — Plugins → Add plugin → github:zznobzz/dsh-model-fallback, or from a terminal:

dsh plugin --profile <your-profile> add github:zznobzz/dsh-model-fallback

The bundle installs its own row with placeholder route names, so it does nothing until you point it at your own models — see Choosing your routes below.

DeepSeek Harness ships one default model route (@deepseek-ai/dsh-agent-default-model) and one recovery executor (@deepseek-ai/dsh-llm-retry) that re-runs the same request. There is no fallback-model setting. This bundle adds it at the llm/stream seam — the extension point whose contract says a listener "may short-circuit the call or route a mutable one-shot request before lookup" — so a provider failure on the guarded route ends in one dispatch of that request on the fallback route.

Where the policy lives

Plugins → Installed plugins → Model failover → Configure. That row page is where a bundle's own configuration lives; Settings keeps only the read-only built-in inventory. The card edits every field below: the trigger mode, the multi-select of failure codes, the failure count that switches the route over, the failover window, and both routes. Each field is declared .volatile(), so a save writes the profile patch through the harness configuration editor and the next request already runs under the new policy — no restart. Reset drops the profile override and returns to the values in this bundle's patch.

The same form also appears at the bottom of Settings → Models, beside the provider rows, because the policy is about models.

Shipped defaults

- insert:
    - id: model-fallback
      name: '@zznobzz/dsh-model-fallback'
      config:
        enabled: true
        mode: any
        failureThreshold: 1
        probeIntervalMs: 60000
        requireNoOutput: true
        keepReasoningEffort: true
        primary:
          provider: main-provider        # the guarded (main) route
        fallback:
          provider: fallback-provider    # the route that takes over
          model: fallback-model

Those route names are placeholders on purpose: an installed bundle carries no one's providers. Until fallback names a route your Host actually registers, no request matches the guard and the plugin stays inert.

Choosing your routes

Set the routes on the plugin's own configuration page — Plugins → Model failover → Configure, or the card at the bottom of Settings → Models — and save. That writes a model-fallback row into your profile patch, one layer above this bundle's defaults, and it survives reinstalls and updates:

- id: model-fallback
  name: '@zznobzz/dsh-model-fallback'
  config:
    enabled: true
    mode: any
    codes: [EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT]
    failureThreshold: 1
    probeIntervalMs: 60000
    requireNoOutput: true
    keepReasoningEffort: true
    primary:
      provider: <provider route of your main model>
    fallback:
      provider: <registered fallback provider>
      model: <model that provider serves>

A route id is what the Models page shows and what a request's provider field uses. Nothing here is a credential: keys stay in the harness credential store, and this plugin only asks the LLM service to dispatch the same request on another route the Host already serves.

Fields

Field Default Meaning
enabled true Take over at all. Off leaves every request on the route its Session selected.
mode transient any — any provider failure may switch over. transient — only the codes listed in codes.
codes EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT Failure codes allowed to switch over in transient mode. The schema publishes the eight codes the harness offers as retry choices and admits any other provider code (for example HTTP_503).
failureThreshold 1 Consecutive qualifying failures on the guarded route before its requests move to the fallback route.
probeIntervalMs 60000 How long the fallback keeps serving after a switch-over; the first request after that window is attempted on the guarded route again.
requireNoOutput true Switch over only while the failed attempt streamed no content. With false the plugin can also take over mid-response.
keepReasoningEffort true Send the request's reasoning effort to the fallback model when that model offers the same level; otherwise omit it and let that adapter choose.
fallback.provider / fallback.model required Route that takes over.
primary.provider / primary.model unset Guarded route. model narrows the guard to one model id; omitting primary guards every route except fallback.

Each switch-over is one extra provider request. Switch-overs, switch-backs, and failures counted toward the threshold are written to the Host log at info; an unusable fallback route is written at warn.

Behavior and limits

  • The saved Session and deployment model selections never change; the switch is request routing at the LLM seam, so the guarded route returns on its own.
  • A switch-over counts per guarded route (provider/model) and lives in Host memory only, so a restart starts from the guarded route.
  • The Session log still attributes a step to the guarded route, because the agent loop writes the request header before dispatch; the provider tokens in usage are the fallback route's.
  • The fallback request is the same assembled messages and tools sent to another adapter: replay state does not cross adapters, and an exact reasoning-effort or output-cap value that route rejects surfaces as that route's own failure.
  • Turn cancellation (finish { kind: 'aborted' }) is never re-routed.
  • If the fallback route is not registered, misconfigured, or lacks its credential, the original failure is preserved and a warning is logged.
  • While the failover window is open the guarded route is not attempted at all, so a provider that recovers instantly is still probed only when the window ends.

Layout

File Role
index.js Host plugin: the llm/stream listener, the live policy read, and the per-route circuit.
client.js Browser half: the configuration form, contributed to the Plugins bundle page (plugins.bundle.config), the row's Configure page (plugins.row.config), and the Settings → Models footer (settings.models.footer).
cordis.patch.yml Row and defaults; editing it changes the bundle layer, not the user's saved overrides.
locale/en.json, locale/ru.json Bundle display metadata. Card copy lives in the client.js dictionaries.
package.json Declares the @deepseek-ai/schemastery dependency and the dsh.client module.
../model-fallback-verify/run.mjs Offline check of the schema and the routing policy (48 assertions).
../model-fallback-verify/run-client.mjs Offline check of the card against a stub module table, React, settings form, and model catalog (28 assertions).

Both checks run under the packaged runtime without touching the profile:

$env:ELECTRON_RUN_AS_NODE = '1'
& "$env:DSH_NODE_EXECUTABLE" ..\model-fallback-verify\run.mjs
& "$env:DSH_NODE_EXECUTABLE" ..\model-fallback-verify\run-client.mjs

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类模型与 MCP
规则置信度高

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: model、deepseek。