dsh-deepaicode-auto: DeepAI Code Model Routing and Fault-Tolerance Plugin

Introduction

In the DeepSeek Harness (DSH) environment, many developers use multiple paid models alongside free tiers simultaneously. When an upstream model returns a refusal or the quota is exhausted, common approaches either fail outright or require manual model switching, which interrupts the conversation. This plugin registers the DeepAI Code model catalog within DSH and builds a capability-ranked “Frontier → Free” ladder, providing automatic routing and per-turn fault tolerance for the Auto (DeepAiCode) virtual model.

What Is This

dsh-deepaicode-auto is a DeepSeek Harness bundle that registers the DeepAI Code model catalog as an LLM provider and adds a virtual model Auto (DeepAiCode). This virtual model attempts “Frontier models” and “Unmetered models” in order of capability and price, based on configuration and the live catalog, and automatically switches on failure until the request succeeds or no further options remain.

  • Provider route: deepaicode
  • Virtual model ID: auto (displayed as Auto (DeepAiCode))
  • Settings entry: The “Settings → DeepAI Code” page in DSH, for connecting an account and checking status
  • Tool name: deepaicode_free_models, for reporting and re-validating the free tier
  • Runtime: Pure ESM JavaScript, no build step, no runtime dependency on @deepseek-ai/* packages
  • License: MIT

Core Features

Model Catalog & Routing Ladder

The plugin divides the model catalog into two tiers:

  • Frontier: Ordered by configuration (capability priority) and catalog-discovered pricing; each request consumes Theos credits.
  • Unmetered: Ordered by configuration; no Theos credit consumption.

The live catalog takes precedence over configuration in terms of pricing: if the catalog returns a theosPerRequest value that differs from the configured value, the catalog value is used. Newly added models in the catalog are appended to the ladder and can be routed to immediately without a plugin release.

Per-Turn Fault Tolerance

When Auto (DeepAiCode) encounters an error during a request, the plugin re-plans the attempt order based on the error category, rather than iterating through the list in a fixed sequence. Error categories include:

  • context: Context exceeds the current model’s window; attempts a wider model. If no wider model exists, returns CONTEXT_WINDOW_EXCEEDED, and the Harness performs a compression retry.
  • auth: Authentication issue; aborts the chain without cooling down any model.
  • quota: Insufficient Theos quota; the entire paid tier is retired, falling back to the free tier.
  • busy: Session is busy; cools down for 15 seconds before attempting the next model.
  • rejected: Model refused the request; cools down for 10 minutes before attempting the next model.
  • transient: Network or transport-layer error; cools down for 60 seconds before attempting the next model.
  • lane: Lane version unsupported; retries the same model once after a limited cooldown.

Each failure also triggers a background catalog refresh to promptly capture upstream changes.

SSE Timeout Monitoring

Streaming responses can silently stall due to upstream hangs or network issues. The plugin uses src/sse.js to race the read body against streamIdleTimeoutMs (default 90 seconds). If the timeout is reached, the stream is terminated and treated as a failure, entering the fault-tolerance flow.

Context Window Handling

Auto (DeepAiCode) can route to any model in the ladder, so it only exposes the narrowest context window in the ladder (minimum 32k). This way, when the conversation exceeds the currently available model’s window, the Harness begins compression early, avoiding a hard limit breach. If the upstream still reports an overflow, CONTEXT_WINDOW_EXCEEDED is returned, triggering the Harness’s compression retry path.

Dual Wire-Family Adaptation

DeepAI Code models are distributed across two endpoints:

  • openai-completions (26 models): Uses POST /deepai_code/chat/completions, returning choices[].delta.
  • openai-responses (e.g., gpt-6-astra): Uses POST /deepai_code/responses, returning structured events (response.output_item.added, response.output_text.delta, etc.).

The plugin unifies both into the Harness StreamChunk vocabulary in src/stream.js, making routing, fault tolerance, and SSE monitoring wire-family-agnostic. Additionally, the plugin rejects the max_output_tokens parameter (returning 400) and ensures the openai-responses endpoint requires the input field.

Typical Usage

Once enabled in DSH, the virtual model can be used directly in conversations or orchestration:

  • Select model: Auto (DeepAiCode)
  • Provider route: deepaicode
  • Settings page: Settings → DeepAI Code

The plugin automatically attempts requests in Frontier → Unmetered order based on configuration and the live catalog, and switches or retries by category on failure.

Use Cases & Notes

  • Suitable for scenarios requiring simultaneous use of multiple DeepAI Code models, automatic per-turn fault tolerance, and maintaining conversation continuity.
  • The plugin communicates directly with DeepAI Code’s OpenAI-compatible API within the DSH process — no desktop app, local gateway, or proxy process is involved.
  • It is recommended to review the source code and license (MIT) before installation.
  • Catalog page & source repository: https://www.skillhub.cn/plugins/luciomerlo/dsh-deepaicode-auto / https://github.com/luciomerlo/dsh-deepaicode-auto
羽毛球分组比赛记分
小程序二维码

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

Xiaoye