dsh-llm-quota-retry: Long-Term Retry and Routing Pool Switchover After Account Quota Exhaustion

Preface

When running agents in DeepSeek Harness (DSH), model requests may fail due to exhausted account allowances or balances. The host’s default @deepseek-ai/dsh-llm-retry handles rapid retries within a limited count. Once this budget is exhausted, the turn often concludes, leaving unfinished steps in the conversation suspended.

If you have configured multiple interchangeable provider/model routes, or wish to wait for quota restoration on the same route at fixed intervals, you need a strategy layer that engages after “rapid retries are exhausted.” The community plugin dsh-llm-quota-retry (maintainer: windwhiterain, Category: Model Inference) targets this gap. It takes over after earlier recovery strategies abandon quota-related failures, either switching to a route in the pool that still has quota, or retrying the same request repeatedly within the same turn at configured intervals until success or user cancellation.

What is this

dsh-llm-quota-retry is a DSH host plugin (Cordis bundle, including Web composer capabilities). The current package version is 0.2.0, licensed under MIT.

It solves a core problem: when a model request fails due to exhausted account allowance, keep the current agent step alive after the basic retry strategy has given up. If the session is bound to a route pool (an ordered list of interchangeable providers/models) and a route still has quota, it switches immediately based on the remaining quota ratio of each route. If no routes in the pool have quota, it retries the same request at configured intervals (default one hour) without a limit on the number of attempts, provided the turn remains open, until success or the turn is cancelled.

The plugin is enabled for all sessions by default. It can be disabled per session via a composer chip or /quota-retry, or disabled globally at the deployment level by setting defaultEnabled: false.

Core Features

Scope of Quota Failure Identification

Beyond the standard QUOTA, the plugin handles cases where some providers express “usage limit exhausted” using AUTH or RATE_LIMIT. Examples include 403s metered by rolling windows, or 429s triggered by Token Plan limits (including Chinese messages like “已达到 Token Plan 用量上限:…”). Recognizing only QUOTA would miss these metered scenarios, so extended identification is part of the plugin’s rationale.

Route Pool and Balance Sources

Sessions can manually join a pool via the second composer chip or /quota-pool. If the current model is already in a pool, the session will automatically follow that pool. The pool’s minimumRemaining determines which routes the session starts on, selected by the remaining quota ratio of each route. During the session, migration is triggered only when the provider itself reports that the allowance is exhausted.

The determination of which routes “have quota” comes from balance scripts and the exhaustion information reported by providers.

Division of Labor with dsh-llm-retry

When composing, the llm-quota-retry line must be placed after @deepseek-ai/dsh-llm-retry. This is a contract: dsh-llm-retry executes earlier in the agent/request-error waterfall, consuming its retry budget first. When a quota failure reaches this plugin, all preceding recovery strategies have already declined—meaning the long-term strategy engages “after basic rapid retries.” The bundle’s included cordis.patch.yml appends the line to the composition root, so it is usually in the correct position after installing the bundle.

Note: Line order does not equal listener registration order; Cordis runs listeners in registration order. If this plugin activates before other strategies, it might “voice” quota failures first, causing failures that should go through native strategies to skip native retries. For providers listed in nativeRetryFirstProviders, the behavior is consistent under both orders.

nativeRetryFirstProviders (Native Quick Retries First for Named Providers)

Some providers report ordinary rate limiting as “quota exhausted” (e.g., qwen returns insufficient_quota on 429). Waiting for an hour directly would be detrimental. When nativeRetryFirstProviders is configured, the plugin first runs the same finite exponential backoff as @deepseek-ai/dsh-llm-retry for that provider (derived from the retryPolicy on the failed request: initialDelayMs, maxDelayMs, jitterRatio, maxRetries, providerRetryAfterMs, etc.). Only after the budget is exhausted does it mark the provider’s quota as exhausted and proceed to failover or hourly waiting.

Quick retries occur before exhaustion marking and failover; the rate-limited provider retains its allowance. Example log:

llm-quota-retry: provider "qwen" returned QUOTA; native quick retry 2 in 4000ms

Configuration example from the README:

- id: llm-quota-retry
  name: 'dsh-llm-quota-retry'
  config:
    nativeRetryFirstProviders: [qwen]

Externally Visible Status

Entry into, exit from, and the current status of long-term retries are published via mechanisms like ctx.llmQuotaRetry for other plugins to perceive (also noted in the package.json description).

Boundaries

For failures that are not quota exhaustion, the plugin strictly makes additions without altering original behavior. The README section “What this plugin does not touch” explains the handling of other failure types (the text was truncated in the source, so please verify on the GitHub README before installation).

Installation and Activation

The plugin is a Cordis bundle. You must execute the official installation command in the directory one level above the checked-out repository (i.e., the directory containing the dsh-llm-quota-retry folder):

dsh plugin --profile web add ./dsh-llm-quota-retry

Installation links the package into the profile and writes to dsh.profile.bundles; the bundle layer loads on every subsequent startup. Host lines take effect without a restart: profile patches hot-reload, lines activate, and the bundle reports enabled and starts fibers.

The Composer chip requires a host restart the first time. The dsh.client manifest is scanned and read by the client-module and is cached for life per package. If dsh.client was not declared during the first scan, it remains cached as a “non-client package.” After installation or adding dsh.client to an installed package, please restart dsh web once for the chip to appear.

Ensure that @deepseek-ai/dsh-llm-retry is installed in the composition and that this plugin’s line is placed after it (bundle installation usually appends this automatically).

Typical Usage

  1. Install the bundle and restart dsh web (to display the composer chip for the first time).
  2. In the Cordis configuration, set nativeRetryFirstProviders, route pools, and balance scripts for llm-quota-retry as needed (see the route pools section in the README for details).
  3. Session level: Use the composer chip or /quota-retry to toggle long-term retries; use the second chip or /quota-pool to specify a route pool.
  4. Deployment level: Set defaultEnabled: false if you do not want it enabled by default.

Use Cases and Notes

Who it is for: DSH agent deployments with multiple provider/model routes, or a single route where you are willing to wait a long time within the same turn for quota refresh (e.g., hourly quotas). Often paired with @deepseek-ai/dsh-llm-retry.

Security and Permissions: The plugin runs with the current dsh process privileges and can access the network and credentials configured by the host. Please read the GitHub Source Code and the MIT license before installation to assess whether to include it in your environment.

Ecosystem Note: DSH advocates “everything is a plugin.” The SkillHub directory page is a community site and has no official affiliation with DeepSeek / High-Flyer.

Conclusion

dsh-llm-quota-retry retains the step within the same turn after rapid retry budgets are exhausted, using route pool failover and unlimited interval retries. It also covers various ways providers express “quota exhausted.” For more information and issues:

  • Directory Page: https://www.skillhub.cn/plugins/windwhiterain/dsh-llm-quota-retry
  • GitHub: https://github.com/windwhiterain/dsh-llm-quota-retry
羽毛球分组比赛记分
小程序二维码

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

Xiaoye