dsh-opencode-routing: OpenCode Account Pool & Usage Dashboard Plugin for DeepSeek Harness

Introduction

When building agents with DeepSeek Harness (DSH), you often need to manage multiple OpenCode accounts simultaneously, monitor their usage, and automatically switch to the official subscription when quotas are exhausted or upstream rate limiting kicks in. Previously, these capabilities required two separate plugins, with settings split across two pages. dsh-opencode-routing unifies “OpenCode account pool + quota routing” and “usage dashboard” into a single package, with just one settings page: “OpenCode Accounts & Usage.”

Plugin Overview

dsh-opencode-routing is a DeepSeek Harness plugin developed by maintainer doushabao2026, categorized under “Model Inference.” It addresses: multi-account quota management, automatic routing failover, usage visualization, upstream status monitoring, and recovery strategies.

Core Features

The plugin provides a unified “OpenCode Accounts & Usage” settings page with the following capabilities:

  • Account Pool & Automatic Rotation
  • Supports adding, removing, and editing accounts; drag to reorder.
  • Accounts are used in sequence; there is only one “current account.”
  • Keys are automatically mirrored to the credential references read by the provider, so switching accounts requires no provider configuration changes.
  • When an account returns a QUOTA / ACCOUNT_QUOTA / 429 or authentication-related error (AUTH, INVALID_CREDENTIAL, MISSING_CREDENTIAL, ACCOUNT_SIGN_IN_REQUIRED, CLIENT_UPGRADE_REQUIRED), the current account is marked as unavailable and routing automatically switches to the next enabled account, retrying within the same step.
  • Per-model isolation: when a specific model’s quota is exhausted, only that model is isolated (default 30 minutes); other models continue using the plan.
  • The entire pool falls back to the fallback (default DeepSeek account) only when all accounts are exhausted, with a zero-token probe every 30 minutes to check for recovery.
  • Capacity/Overload Fallback
  • When router.fallbackOnCapacity: true is enabled, if upstream returns a capacity/overload-type 429 (overloaded / at capacity / prefill_cap_refused / ttft_admission_refused), traffic falls back to the official subscription.
  • Probing begins 60 seconds after fallback; the probe interval is controlled by router.capacityFallbackDelayMs.
  • The settings page provides “Switch to Official Subscription Now / Switch Back to OpenCode” buttons, and this can also be triggered via POST /opencode-quota-router.json {"action":"fallback"} / {"action":"primary"}.
  • Recovery Strategy
  • During fallback, a probe is issued every router.recoveryProbeIntervalMs (default 60 seconds).
  • Traffic is only handed back to the plan after router.recoverStableMs (default 10 minutes) of consecutive successful probes.
  • Any single failed probe in between resets the window to zero, preventing “flapping back and forth when upstream jitters.”
  • Recovery also requires that the official status no longer marks the model as degraded (recovery.blocked = "published").
  • Official Status Monitoring
  • The plugin reads the JSON status from https://status.opencode.ai/api/status and displays it alongside local probes.
  • Official status is broken down by service and model, including reasons, real-time speed, and ongoing/historical events.
  • The settings page shows an “Upstream Status” card with local probe results and official judgments side by side; it auto-expands when either side reports an issue.
  • The card displays labels such as Normal / Degraded / Outage / Maintenance, along with per-model local and official judgments.
  • A “Refresh Status” button (POST {"action":"status"}) and an “Open Status Page” link are provided.
  • Usage Dashboard
  • Displays metrics by model including monthly, 5-hour, weekly, and request count figures; supports 10 languages (follows browser language).
  • Model cards support collapsing capability tags into small icons with hover tooltips.
  • The top of the page shows the current route, peak/off-peak status, and a countdown to the next probe.
  • A banner displays the current route and the reason for switching.
  • Main UI Notifications
  • When automatically switching to the official subscription or switching back to the account pool, a notification appears in the top-left corner of the main UI.
  • Notifications include a timestamp, can be dismissed by clicking ✕, and up to 3 are shown simultaneously.
  • The notification body is a human-readable reason (e.g., “Upstream capacity insufficient/overloaded, temporarily routing via official direct connection”).
  • Input Box Model Label
  • Replaces the framework’s conversation.input.model.label slot and does not display the OpenCode badge.
  • During fallback, an “Official Fallback” tag appears after the model name; it disappears automatically after switching back to OpenCode.
  • Hovering over the model name reveals the actual provider currently in use.
  • Framework Banner Override
  • Takes over the DSH framework’s “Upstream Unavailable” banner, repositions it away from the logo, restyles it, and adds a close button.
  • Adds local network self-diagnosis text (e.g., “Both domains unreachable: this is a problem with your local connection to the external network”).
  • Version 2.11.1 adds re-assertion against framework-overridden styles and cleanup of empty banners.
  • Configuration & API
  • The host exposes two endpoints: GET /opencode-usage.json (usage, ?refresh=1 to force refresh) and GET|POST /opencode-quota-router.json (account pool and routing).
  • Configuration is declared via cordis.patch.yml insert statements, including top-level keys such as usageUrl, apiKeyRef, probeIntervalMs, as well as usage and router sub-objects.
  • Routing configuration example:
    - insert:
        - id: opencode-router
          name: 'dsh-opencode-routing'
          config:
            usageUrl: https://opencode.ai/inference/go/v1/usage
            apiKeyRef: OPENCODE_API_KEY
            usage:
              path: /opencode-usage
              plan: go
            router:
              path: /opencode-quota-router
              routes:
                - primary: { provider: opencode-go, model: deepseek-v4.1-flash }
                  fallback: { provider: deepseek-account, model: deepseek-flash }
  • Top-level keys apply to both the dashboard and the router; sub-objects only override their respective sections.

Installation & Activation

In a DeepSeek Harness environment, install via npm:

npm i dsh-opencode-routing

After installation, the plugin automatically applies the patch from cordis.patch.yml, registering the opencode-router provider and routing configuration. Ensure your DSH version meets dsh >= 0.2.0-rc.1 (all streaming calls are routed via the llm/stream waterfall); older versions will automatically skip alignment with no extra configuration needed.

Typical Usage

Navigate to “OpenCode Accounts & Usage” in the DSH settings page. Add multiple OpenCode account keys and drag to reorder their usage sequence. In the routing configuration, specify the primary model (e.g., deepseek-v4.1-flash) and the fallback model. Enable router.fallbackOnCapacity: true, and when upstream returns an overload-type 429, traffic will automatically switch to the official subscription. Monitor the “Upstream Status” card to view local probe results and official judgments, and click “Refresh Status” to manually update. The usage dashboard displays request volumes and consumption per model across various time windows. The main UI will automatically show switch notifications, and the input box model label will reflect the current route and fallback status.

Use Cases & Notes

  • Ideal for scenarios where multiple OpenCode accounts are used simultaneously and unified usage monitoring and routing failover are needed.
  • Ideal for scenarios requiring automatic fallback to the official subscription with smooth recovery strategies.
  • The plugin runs with the current DSH process permissions; it is recommended to review the source code and license (MIT) before installation.
  • The plugin depends on the official status endpoint status.opencode.ai; if that endpoint is unavailable or returns anomalies, it may affect the official status display and recovery decisions.

Conclusion

dsh-opencode-routing ties together OpenCode multi-account management and DeepSeek Harness streaming calls through an account pool, automatic routing failover, a usage dashboard, and official status monitoring—enabling agent developers to configure and monitor everything from a single settings page. For more details, see the plugin directory page and the GitHub repository.

References

  • Plugin directory page: https://www.skillhub.cn/plugins/doushabao2026/dsh-opencode-routing
  • GitHub repository: https://github.com/doushabao2026/dsh-opencode-routing
  • DeepSeek Harness: https://github.com/deepseek-ai/deepseek-harness
羽毛球分组比赛记分
小程序二维码

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

Xiaoye