Introduction¶
The plugin system of DeepSeek Harness (DSH) allows dynamic adjustment of model routing strategies at runtime. When the billing windows of certain models have a price gap compared to fixed-rate plans from other services, manually switching between them can be costly. This article introduces a plugin that automatically switches routing during configured peak/off-peak periods and falls back to a backup route when the target quota is insufficient.
What It Is¶
dsh-peak-router is a provider-agnostic peak/off-peak routing rule plugin maintained by LegifyX. It executes routing switches at session boundaries via agent.model.select() and leaves auditable event records in session logs. The plugin also provides a Web Extensions settings page for managing configurations and viewing real-time status.
Core Features¶
Peak/Off-Peak Switching
Within the configured peakWindows time windows, the plugin attempts routes from the peakRoutes list in order; outside those windows it uses the primary route (off-peak). Windows support crossing midnight (e.g., 22:00-02:00) and can be scoped to weekdays or all days via peakDays.
Subscription Quota Guard
The plugin reads the remaining quota of the target provider through quotaAdapter. When any route’s quota drops below minRemainingPercent, that route is skipped and the next one is tried. Currently, deeprelay is the only implemented adapter; other providers are treated as having no quota limits.
Manual Selection Protection
The respectManualSelection toggle controls whether the plugin respects a user’s manual model selection within a session. When set to true, once a user manually switches models, the session will no longer be touched by routing rules until the process ends; set to false to continuously enforce the schedule.
Web Interface
The plugin provides a browser-based settings page (Settings → Web Extensions → Peak Router). The page displays the current period, next switch time, active route count, and the most recent switch record. It supports online editing of the primary route, peak/off-peak route list, behavior toggles, as well as time, quota, and advanced settings.
Installation & Activation¶
The plugin is injected into the profile via dsh.bundle.patch, and its Web Extensions page is registered in dsh.client. The install command is as follows:
dsh plugin --profile web add github:LegifyX/dsh-peak-router#<commit>
After installation, enable dsh-peak-router under Settings → Plugins.
Typical Usage¶
Basic Peak/Off-Peak Switching
The default configuration switches to DeepSeek-V4.1-Flash on deeprelay during the Shenxin peak-rate period, and uses deepseek-flash for the rest of the time:
- id: dsh-peak-router
name: dsh-peak-router
config:
peakProvider: deeprelay
peakModel: deeprelay/deepseek-v4.1-flash
offPeakProvider: deepseek-account
offPeakModel: deepseek-flash
Multiple Peak Routes
Attempt multiple peak providers in order; fall back to the primary route when all are exhausted:
- id: dsh-peak-router
name: dsh-peak-router
config:
offPeakProvider: deepseek-account
offPeakModel: deepseek-flash
peakRoutes:
- provider: deeprelay
model: deeprelay/deepseek-v4.1-flash
- provider: openrouter
model: anthropic/claude-x
- provider: zai
model: glm-4.6
One-Way Switching
Only switch when entering a peak/off-peak period; do not switch back when the period ends:
swapBack: false
Disabling the Plugin
Set enabled: false in the configuration to pause routing behavior.
Use Cases & Notes¶
This plugin is suitable for scenarios where you need to automatically switch between providers with different billing strategies, especially when the target provider offers a fixed-rate plan and the original provider charges a higher rate during specific periods.
The plugin runs with DSH process privileges. You should review the source code and license (MIT) before installing.
Summary¶
dsh-peak-router enables peak/off-peak routing in DSH, supporting multi-route fallback, quota guards, and manual selection protection. Configuration and monitoring can be completed entirely through the Web interface, making it well-suited for developers who need fine-grained control over model routing costs.
- Plugin directory: https://www.skillhub.cn/plugins/LegifyX/dsh-peak-router
- GitHub repository: https://github.com/LegifyX/dsh-peak-router