dsh-model-failover: DSH Model Failover

Preface

When running agents in DeepSeek Harness (DSH), model selection is often “select once, fail immediately.” The official dsh-llm-retry retries within the same provider; if the provider is globally rate-limited, out of quota, or unavailable, the turn will still fail after retries are exhausted. With multiple providers and models coexisting, a mechanism is needed to poll across providers by pool, switch upon failure, and not mask real errors. Below we introduce how the community plugin qgg4588/dsh-model-failover (Maintainer: QGG4588, Category: Model Inference) connects to DSH extension points to achieve these behaviors.

What is this

dsh-model-failover is a Host-only bundle plugin: when a model request fails due to configurable failure codes (such as RATE_LIMIT, QUOTA, TIMEOUT, etc.), it selects the next untried model from the “selected provider pool” to retry; it provides the runtime tool model_failover and a ⇄ Failover panel next to the Web input box. If the pool is exhausted, it returns the original error without masking the failure.

Repository: https://github.com/QGG4588/dsh-model-failover
Community Directory Page: https://www.skillhub.cn/plugins/QGG4588/dsh-model-failover (Independent site, not officially affiliated with DeepSeek / High-Flyer)

The current package.json version is 1.2.2, License MIT, requiring DSH engine >=0.2.1-rc.1 <0.3.0-0.

Core Features

Provider Pool and Switch-on-Failure

  • Pool = All models under selected providers: Select only one provider → Poll all models within that provider; Select multiple → Poll across provider pools in order.
  • Trigger Failover: Default routable failure codes include RATE_LIMIT, QUOTA, ACCOUNT_QUOTA, SERVER, TIMEOUT, TRANSPORT, EMPTY_RESPONSE, NO_ADAPTER (adjustable in config); each candidate model is tried only once.
  • Stickiness: When sticky: true, the session continues using the new model after failover; default is only for the duration of the current failure.

Alignment with Official Extension Points

  1. agent/request-error waterfall: After the upstream dsh-llm-retry exhausts retries within the same provider and returns undefined, this plugin catches the failure → selects the next untried model from the pool → returns { kind: "retry" }, and the agent-loop re-executes prepareRequest and resends.
  2. agent/request waterfall: Writes the pending target into the provider/model of the current request (same pattern as the member model switch in dsh-session-conductor).
  3. Failure classification only recognizes failure.code, without parsing error text.
  4. State is written to <DSH_HOME>/model-failover/state.json (runtime pool, sticky target, modelCatalog snapshot, recent events, circuit breaker state).

Circuit Breaker (Anti-Flicker)

Occasional failures on a single model do not immediately blacklist it permanently; consecutive failures within a window reaching the threshold will trigger a cooldown, and pool candidates will automatically skip it; provider-level thresholds can put the entire provider pool into cooldown together. preemptiveSwitch (enabled by default) can bypass tripped routes before requests. Cooldown automatically recovers upon expiration; successful terminal states in llm/stream clear the circuit breaker for that route. If all candidates are tripped, it still attempts in pool order.

Runtime Tools and Interface

action Function
status Switches, pool, trigger codes, last 8 failover events
set Set runtime pool (overrides config.providers)
clear Clear runtime pool and stickiness, fall back to config pool
enable / disable Runtime master switch

The Web panel is located at the bottom right of the input box, to the left of the official model selector; data goes through GET /api/model-failover/status, POST /api/model-failover/{set,clear,toggle}. After modifying Client code, restart DSH and refresh the page.

Installation and Activation

This repository has no third-party dependencies and requires no build. The directory structure is roughly:

dsh-model-failover/
├── index.js
├── cordis.patch.yml
├── package.json
├── locale/{en,zh}.json
└── icon.svg

Method 1: Use install_bundle in DSH Plugin Manager, passing the absolute path of this directory as target.

Method 2: Put the directory into the profile’s node_modules/, and append to cordis.patch.yml:

- insert:
    - id: dsh-model-failover
      name: dsh-model-failover
      config: {}

Restart DSH to take effect. The plugin runs with the current DSH process permissions; please review the source code and MIT license before installation.

Configuration Options

Set in the config of the corresponding line in cordis.patch.yml (all have default values):

Key Default Description
enabled true Master switch
providers [] Default provider pool; if empty, use model_failover set
retryableCodes See README list Failure codes triggering failover
sticky false Whether to stick the session after failover
maxFailoverAttempts 0 Max candidates to switch to in a single failure (0 = whole pool)

Circuit breaker related thresholds (failureThreshold, burstWindowMs, circuitCooldownMs, providerThreshold, etc.) refer to the “Circuit Breaker” section in the repository README.

Typical Usage

First, set the pool using the runtime tool (example from README):

model_failover set providers=["wb","agnes"]

Meaning: Pool = all models of wb + all models of agnes, in this order.

Check status:

model_failover status

You can also check providers and save in the Web panel, which shares the same state as the tool.

When working with dsh-llm-retry: First retry and backoff within the same provider, and after exhaustion, this plugin performs cross-provider failover. When coexisting with dsh-session-conductor at agent/request modifying models: This plugin takes effect when there is a pending failover or sticky setting; when there is no pending, it does not interfere with explicit member models.

Applicable Scenarios and Notes

Suitable for: Users who have configured multiple providers, wish to automatically switch models to continue the same turn of tasks when facing rate limits/quota/timeout/server errors, and need to change the pool at runtime without changing config and restarting.

Boundaries (explained in README):

  • Pool members come from modelCatalog; if the catalog is unavailable, the latest disk snapshot is used.
  • v1 does not check input modalities of candidate models; if the pool contains pure text models, image messages may be rejected.
  • Failover may increase latency within the same step (one full attempt + official backoff for each candidate).
  • No scheduled polling, failover only occurs upon failure.

Unit tests: node --test test/unit.mjs.

Conclusion

In the DSH “everything is a plugin” ecosystem, dsh-model-failover complements the official single-point model selection and same-provider retry with cross-provider pool failover capabilities, combined with circuit breakers and dual-channel control via Web/tools. For further understanding and installation, please refer to the SkillHub Directory Page and GitHub Repository.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye