dsh-model-fallback-queue: Automatic Failover Queue for Model Limits and Rate Limiting

Introduction

When running long sessions in DeepSeek Harness (DSH), common interruptions stem from the current model’s quota being exhausted, rate limiting, or temporary routing unavailability. Backoff retries on the same route can be handled by dsh-llm-retry, but if the primary model itself is unavailable, you still need to switch to a different route to continue the conversation. Manually switching in the model selector disrupts the workflow and makes it difficult to prioritize routes in advance.

dsh-model-fallback-queue targets this scenario: it maintains a P1 → P2 → … queue for the current session and automatically switches to the next model when a circuit breaker condition is triggered. Toggling, queue ordering, and P1 recovery strategies are managed via the Web settings page, requiring no command line interaction. Maintained by HelloQingTao and categorized under model inference; the npm package name is dsh-model-fallback-queue (current version 0.2.5, MIT license).

What is this

The plugin implements cross-route failover on the request path: P1 defaults to following the current model you selected in the session, while you add fallbacks (P2, P3, etc.) in the settings. When a switch occurs, the DSH core issues a “Model Switched” notification, and the chip next to the input box updates to display the currently active route.

It has a clear division of labor with dsh-llm-retry: non-fatal errors are passed through, and same-route backoff retries remain the responsibility of the retry plugin; this plugin only handles cases where a route change is necessary. It is compatible with dsh-client-auto-continue; auto-continue follows the same request chain and benefits from the queue switching.

Core Features

Request-level Circuit Breaking & Switching

  • Immediate Circuit Breaking: When encountering immediate circuit breaker error codes (such as QUOTA, ACCOUNT_QUOTA, RATE_LIMIT, AUTH, INVALID_CREDENTIAL, NO_ADAPTER), the current route is immediately tripped, and the next available item in the queue is attempted.
  • Failure Threshold: Other errors that fail consecutively 2 times (default threshold) will also trip the current route.
  • Cooldown: The circuit breaker cooldown defaults to 60 seconds (cooldownMs); the broken state is held in memory and resets to zero after a process restart.

Queue P1 → Pn

  • P1 follows session model (p1Follow defaults to true): Changing the model in the model selector changes P1 accordingly; the queue contains the configured fallback items.
  • Empty/Single Queue: No switching occurs if the queue is empty or contains only one item.
  • Persistence: Queue order determines priority. It is stored in a separate file ~/.dsh/fallback-queue-state.json, not in the settings document. This avoids frequent reordering triggering ui-theme re-pushes, which causes dark mode white flashes (as per the design notes in the README).

Three P1 Recovery Strategies

Mode Behavior
Sticky (sticky, default) Once switched to P2, it continues to be used as long as P2 is available. P1 is not automatically switched back to even if it recovers. If failures continue, it looks further down the queue; wrapping back to P1 is the last resort.
Probe (probe) After P1’s cooldown expires, the next real request probes P1. If successful, it stays on P1; if it fails, it returns to P2 (default debounce 5 minutes, no extra probe traffic sent).
Manual (manual) Does not automatically return to P1. Click “Switch back to P1” in the chip expansion panel.

Input Box Chip & Full-Breakdown Degradation

A status chip is displayed on the right side of the input box, expandable to view the queue and health status:

Display Meaning
P1 + Green Dot Normal operation on P1.
P2 (Yellow Dot) Switched to P2; yellow dot indicates a half-open probe is in progress.
P! + Red Dot All routes in the queue are broken; requests are passing through based on original configuration (degradation).
P (Gray Dot) Plugin not enabled.

When all routes are broken, the plugin passes requests through according to the original configuration without interception. UI text follows DSH language settings, automatically switching between Chinese and English.

Installation & Activation

Install under the corresponding profile via Web configuration (Official README Command):

dsh plugin --profile web add dsh-model-fallback-queue

After installation, restart dsh or refresh the Web GUI; the bundle is automatically registered via the cordis.patch.yml inside the package. Compatibility is based on engines.dsh in package.json: >=0.2.0-rc.2 <0.3.0; the README notes testing on dsh 0.2.0-rc.2 and 0.2.1-rc.2. Node.js >=20 is required.

The plugin runs with the current dsh process permissions. Before installation, it is recommended to review the source code and MIT license on the GitHub Repository to ensure compliance with your environment policies.

Typical Usage

  1. Open Settings → Failover and enable “Enable Failover”.
  2. Click + Add Model, select fallback routes (P2, P3…), use ↑ / ↓ to adjust order, and remove items you don’t need.
  3. Select P1 Recovery Strategy: Sticky, Probe, or Manual.
  4. Return to the session: The chip on the right side of the input box shows the route corresponding to the current P1; watch for model switch notifications within the session and chip changes when a switch occurs.

Common settings like enabled, queue, and failbackMode are modified in the settings page. Advanced items (such as immediateCodes, failureThreshold, cooldownMs, failbackDelayMs) are available by default; to customize, write them into the config of this plugin’s line in ~/.dsh/profiles/<profile>/cordis.patch.yml.

Note: The queue file is private plugin data and is not included in the settings page’s export/backup scope. You need to reconfigure the queue when switching machines; on the first upgrade, if the JSON does not exist, it will automatically migrate from the old queue in settings.

Use Cases & Notes

Who it is for

  • DSH users who have configured multiple model routes and want to automatically fall back to secondary models when the primary model encounters rate limits or quota issues.
  • Scenarios already using a Web GUI profile and willing to maintain queue order and recovery strategies in the settings page.

Compatibility & Layering

  • Account Pool Providers (e.g., workbuddy-xdpool): Single account rate limits are handled by swapping accounts internally within the pool. This plugin’s cross-model switching is only triggered when the entire pool is maxed out.
  • Do not enable this simultaneously with other failover-type plugins to avoid competing for the same error events.

Community & Directory

The DSH ecosystem emphasizes “Everything is a Plugin”; the plugin directory site SkillHub Entry and GitHub are maintained by the community and are not officially affiliated with DeepSeek / High-Flyer.

Conclusion

dsh-model-fallback-queue consolidates cross-route switching, circuit breaker strategies, and P1 failback into a single graphical configuration suite: when limits, rate limits, or unavailability occur, the session continues via the queue, and if a total breakdown occurs, original requests are still passed through as a degradation. For further implementation details and issues, see GitHub: HelloQingTao/dsh-model-fallback-queue; for browsing categories and briefs, see the SkillHub Plugin Page.

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

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

Xiaoye