Preface¶
When running agents in DeepSeek Harness (DSH), model requests go through fixed provider routing. If you have multiple OpenCode Go subscriptions (each with an API key), the common approach is to manually switch keys or split them into multiple routes, then switch in the client or scripts. The DSH agent loop deep-freezes the options for each request; waterfall listeners can only read provider, not modify routing; what can be re-resolved per request is the provider’s apiKeyEnv credential reference. The dsh-opencode-go-pool described below (maintainer TianYa-DAO, category: model inference) pools multiple subscription keys behind the same route: it selects the healthiest key before the request, cools down and fails over when the gateway rejects due to quota exhaustion, without requiring you to manually switch models or routes.
What Is This¶
dsh-opencode-go-pool is a DSH community plugin (package name dsh-opencode-go-pool, DSH display name “OpenCode Go Multi-Subscription Pool”, current version 0.1.0, MIT license). It solves the problem of how multiple OpenCode Go subscriptions can stably share one provider route, and automatically switch keys when usage windows (5-hour / week / month) are exhausted or gateway quota errors are received, rather than changing routes or modifying frozen options.
Why “Switch Credentials” Instead of “Switch Routes”¶
The options in model requests sent by the DSH agent loop cannot be modified; doing so throws an error. This plugin makes the target route’s apiKeyEnv point to an activeRef that is exclusively written by the plugin (e.g., OPENCODE_GO_ACTIVE_KEY); before each request, the plugin writes the currently healthiest subscription key into this reference, thereby switching the actual key used without changing the route name.
How It Works¶
- Each subscription key is stored in the DSH standard credential store (
$DSH_HOME/.credentials.yaml, manageable in the settings page), and the plugin reads them according tokeys[].refin the configuration. - The route’s
apiKeyEnvis changed toactiveRef, which the plugin writes the currently active key into before each request. - The plugin calls the official OpenCode Go usage API
GET https://opencode.ai/zen/go/v1/usage(only requires an API key, no org token needed), reading thepercentandstatusfor the 5-hour / week / month windows;status: "rate-limited"orpercent >= 100means that window is exhausted. - Before each request: if readings are missing, query once first; if readings are only stale, refresh in the background without blocking the request; if the current key is exhausted, immediately switch to the one with the most remaining quota.
- When the gateway returns
HTTP 429,{"error":{"type":"GoUsageLimitError"}}withRetry-After(Harness classifies this asQUOTA, which is not in the default retry codes, so the plugin resends): cool down that key according toRetry-Afterand the window reset time, switch to another one, and resend the request as-is once under the premise that the current request has not yet produced any token; if there is already output, report the error honestly without repeating generation.
Multiple decisions (activation warm-up and concurrent requests) execute serially to avoid state snapshot crossing.
Configuration and Activation¶
The plugin itself in cordis.patch.yml only has a one-line insert; specific pooling parameters are written in your profile patch layer. The README does not provide a unified dsh plugin add … installation command; the desktop profile example uses a file: dependency pointing to the plugin directory and inserts it via patch (plugin source path example: ~/.dsh/plugins/dsh-opencode-go-pool). Before enabling, please read the source code and LICENSE on GitHub; the plugin runs with the current DSH process permissions.
Register the plugin in the patch and fill in the pool configuration:
- insert:
- id: opencode-go-pool
name: 'dsh-opencode-go-pool'
- id: opencode-go-pool
config:
route: opencode-go # provider route name to take over
activeRef: OPENCODE_GO_ACTIVE_KEY # credential reference exclusively written by the plugin
keys:
- { ref: OPENCODE_GO_API_KEY, label: 订阅A }
- { ref: OPENCODE_GO_API_KEY_B, label: 订阅B }
Change the taken-over route’s apiKeyEnv to activeRef, for example:
- id: llm-pi-ai
config:
providers:
opencode-go:
apiKeyEnv: OPENCODE_GO_ACTIVE_KEY
api: openai-completions
baseURL: https://opencode.ai/zen/go/v1
Optional fields and default values (from the source material): usageUrl (default: the above usage API), usageTtlMs (60000), cooldownMs (60000, minimum cooldown when the gateway does not provide a window), maxFailovers (1, maximum switches per call). keys[].ref must not be the same as activeRef, otherwise the plugin will error on activation and point out the field name.
Credential example: each subscription’s ref (e.g., OPENCODE_GO_API_KEY, OPENCODE_GO_API_KEY_B) is filled in by you; OPENCODE_GO_ACTIVE_KEY is written by the plugin, do not manually overwrite it with a subscription key.
Typical Usage and Observable Behavior¶
After configuration is complete, model requests going through the provider route specified by route will automatically select keys and fail over when rejected due to quota. The host log prefix is opencode-go-pool:, for example:
- Successful loading:
pooling 订阅A, 订阅B behind route "opencode-go" through OPENCODE_GO_ACTIVE_KEY - First load or key switch:
installed 订阅B as the active key - Avoiding exhausted keys before request:
switched away from 订阅A (quota spent, resets …) to 订阅B - Switching and resending after 429:
failover 订阅A (quota spent, resets …) -> 订阅B (until …) — Go usage limit exceeded
You can run the plugin’s built-in self-check locally (does not depend on the real gateway):
node tests/selfcheck.mjs
The repository also provides e2e overlay configurations (tests/e2e-overlay.yml, tests/e2e-overlay-failover.yml) for regression scenarios of usage-driven switching and 429-driven switching.
Use Cases and Limitations¶
Suitable for: developers who hold multiple OpenCode Go subscriptions, want to maintain only one opencode-go (or similar) route in DSH, and automatically switch keys based on usage and 429 responses.
Notes:
- Health is only assessed before sending the request and after being rejected; it does not predict when quota will be exhausted.
- Only makes per-request decisions for the route specified by
config.route; if other routes share the sameactiveRef, they can only inherit the currently active key. - Switching is a transport-layer action and does not write session events; the evidence is in host logs, not in session records.
- If the profile uses
nodeLinker: hoistedand hard-links the plugin as afile:dependency, changes toindex.jsgenerally take effect immediately; if the editor replaces the file causing inode changes, you need to runpnpm installin the profile directory to rebuild links. After changes, you usually need to restart the DSH desktop client.
For issue reporting, go to GitHub Issues or email 2842425998@qq.com.
Conclusion¶
dsh-opencode-go-pool, in the DSH “everything is a plugin” ecosystem, uses credential pooling to consolidate multiple OpenCode Go subscriptions into one provider route, and integrates with the official usage API and 429 failover. Community directory page (no official affiliation with DeepSeek / High-Flyer): skillhub.cn plugin page; source code and full documentation: GitHub — TianYa-DAO/dsh-opencode-go-pool.