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¶
-
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 inpool.json. -
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. -
Hourly Bucket v2
Congestion detection is based only on the current day’s hourly bucket (YYYY-MM-DD:HHlocal time), combined with 7-day rolling pruning. This avoids “ghost” congestion caused by historical data. -
Same-Quality Tiers
Models are classified bytier: S/A/B/Clabels. 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. -
Executor Pool
Cheap, high-quota models markedrole: executorare 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. -
Paid Guardrail
Models markedpaid: truehave 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. -
Provider Circuit Breaker
Cooldowns are set for authentication failures (AUTH), insufficient quota (QUOTA), and 429 errors (10 minutes, 90 minutes); cooldown state is persisted. -
Forensics and Logging
The plugin maintains a 50-entry switch log (ring buffer) and TS sample records; all forensic data is persisted to disk. -
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 assetTier(set quality),setRouting(set routing mode),setBadge(show badge),setExpiry(set expiration),clearProviderCooldown(clear cooldown), etc.
Notes¶
- Stateless Routing: Routing decisions are stateless per request and do not permanently modify configuration.
- Escape Hatch: When all free models fail, the plugin switches to the cheapest paid model and sends an SMS notification via
text_me. - Headless Operation: The plugin can run without the Web GUI; CLI tools remain available.