Introduction

DSH supports plugin extensions, but free-tier API quotas are often exhausted during use. Manually switching is cumbersome. dsh-poor-router pools these resources, tracks usage, monitors health, and automatically switches between them.

Plugin Overview

dsh-poor-router is a budget LLM pool router for DeepSeek Harness. It is maintained by yishengdaxiaonengjihui. The core problem the plugin solves is that free models are scattered and short-lived, requiring seamless switching when a request fails. It provides automatic ledger tracking, health tracking, and Thompson-sampling-based adaptive routing.

Core Capabilities

  1. Automatic Ledger
    The plugin records the call count for each entry, success/failure/aborted status, time-to-first-token latency (EMA), and token inflow/outflow. A model discovered for the first time is automatically registered in pool.json.

  2. Thompson-sampling Adaptive Routing
    Routing decisions are based on each entry’s Beta posterior distribution and Gaussian approximation sampling. The decision considers a time-to-first-token latency penalty (3000ms/ttft) and the weight of the current hourly bucket. With a 34% probability, a new unused model from the same tier is injected.

  3. Hourly Bucket v2
    Congestion detection is based only on the current day’s hourly bucket (YYYY-MM-DD:HH local time), combined with 7-day rolling pruning. This avoids “ghost” congestion caused by historical data.

  4. Same-Quality Tiers
    Models are classified by tier: S/A/B/C labels. Routing prefers models in the same tier, then degrades from A→B→C, and escalates only when necessary. Tiers can be edited in real time in the Web panel.

  5. Executor Pool
    Cheap, high-quota models marked role: executor are added to the executor pool. Trivial or auxiliary requests are routed to the model with the greatest remaining quota. One in every six such requests performs epsilon exploration.

  6. Paid Guardrail
    Models marked paid: true have daily caps. They are not included in the candidate list and are used only as an escape hatch. When all free candidates fail, the plugin switches to the cheapest paid model and triggers an SMS alert.

  7. Provider Circuit Breaker
    Cooldowns are set for authentication failures (AUTH), insufficient quota (QUOTA), and 429 errors (10 minutes, 90 minutes); cooldown state is persisted.

  8. Forensics and Logging
    The plugin maintains a 50-entry switch log (ring buffer) and TS sample records; all forensic data is persisted to disk.

  9. Web Panel and Redirect Badge
    It provides a settings-page dashboard that displays availability rankings, a grouped ledger, and recent switch records. A ⚡ redirect badge is shown to the left of the input box, showing the source and reason for the most recent request.

Installation and Activation

Run the following command in the DSH environment to install the plugin:

dsh plugin --profile web add github:yishengdaxiaonengjihui/dsh-poor-router

Or manually edit package.json, add the dependency, and run pnpm install.

Configuration

Configuration files are mainly located in pool.json (the same level as the model configuration) and the plugin’s default path <cwd>/poor-router/. Plugin-level paths can be overridden in cordis.patch.yml.

cordis.patch.yml Example

- id: poor-router
  name: dsh-poor-router
  config:
    dataDir: 'D:/my-data/poor-router'   # 基础目录
    layerRules:
      - { match: 'deepseek-official/', layer: 'backbone' }
      - { match: 'tokenrouter/', layer: 'matchstick' }

pool.json Field Description

Field Description
id provider/model; must match the ID provided by the Harness
expiresAt ISO date used for sorting and the panel countdown
grantRemaining / grantUnit Executor pool budget configuration
tier Quality tier S/A/B/C
role "executor" adds it to the executor pool
layer backbone (never burned) / burn / matchstick
paid + priceInYuanPerM + dailyCapYuan Paid guardrail configuration
escapeHatch Allows using a paid model as a last resort

Agent Tools

The plugin registers two session tools, which can be called via the CLI:

  • pool_status: Get a full snapshot, including a summary and per-entry statistics.
  • pool_control: Used to override configuration, such as setTier (set quality), setRouting (set routing mode), setBadge (show badge), setExpiry (set expiration), clearProviderCooldown (clear cooldown), etc.

Notes

  1. Stateless Routing: Routing decisions are stateless per request and do not permanently modify configuration.
  2. Escape Hatch: When all free models fail, the plugin switches to the cheapest paid model and sends an SMS notification via text_me.
  3. Headless Operation: The plugin can run without the Web GUI; CLI tools remain available.

References