Introduction¶
The core philosophy of DeepSeek Harness (DSH) is “everything is a plugin.” After DeepSeek implemented peak/off-peak pricing on 2026-08-17, the unit price for model calls during peak hours (Beijing Time 9:00-12:00 and 14:00-18:00) becomes 2 times that of off-peak hours. For scenarios requiring long-running sessions, manually controlling pauses is not only inefficient but also difficult to align precisely with peak/off-peak windows.
dsh-session-guard is designed to solve this problem. Through an automatic session gate mechanism, it provides automatic peak pauses, weekend mode, and session-level freeze/resume, helping developers optimize costs without modifying DSH source code.
Plugin Introduction¶
dsh-session-guard is a DSH plugin maintained by drscrewdriver and licensed under the MIT License.
It does not require modifying DSH source code or submitting a Pull Request. Instead, it assembles Cordis plugins using the dsh plugin command and a bundle patch. Its core features include automatic peak pauses, weekend mode, official source two-dimensional determination, session-level freeze/resume, and automatic backend retries.
Core Features¶
Weekend Mode¶
The plugin identifies weekend status using Intl.DateTimeFormat based on the configured timezone, avoiding timezone boundary bugs that could occur when directly using raw getUTCDay(). In weekend mode, the plugin ignores peak/off-peak pricing rules and allows sessions to run freely.
Automatic Peak Pause (Global)¶
When entering peak hours (and not on a weekend), the plugin automatically pauses all root sessions in the running state. After peak hours end, all sessions resume automatically. This is a global switch that requires no manual intervention.
Official Source Two-Dimensional Determination (providerGuard)¶
The interception strategy during peak hours is fine-grained. The plugin intercepts a request only when the target is the DeepSeek official source. If a local or third-party Provider is used (for example, local-35b), requests pass normally regardless of whether peak hours are active, and are not affected by peak gating. The determination logic proceeds in the following order: explicit ID list → baseURL endpoint → catalog default endpoint → built-in ID.
Session-Level Freeze/Resume¶
The plugin provides session-level control. In addition to automatic pauses, it supports freezing or resuming specific sessions through the POST /session-guard/rpc endpoint or an integrated freeze button in input traffic. It also provides the manual commands /pause, /resume, and /cancel.
Automatic Backend Retries¶
During a freeze or gating period, if a transient failure occurs (such as an error, 429, or max-tokens issue), the plugin uses an adaptive backoff automatic retry mechanism until a permanent failure occurs. This ensures that occasional errors during a pause do not interrupt tasks.
Fail-Open Silent Degradation¶
To ensure system stability, the plugin is designed with a fail-open mechanism. If the built-in session gate is unavailable, session-guard is not installed, or the settings service is missing, the system silently degrades. Missing dependencies do not cause the entire DSH process to crash.
Installation¶
Install it using the DSH plugin management command. Choose the corresponding dist-tag according to your host version.
# 安装 dsh-session-guard (推荐使用指定 dist-tag)
dsh plugin --profile web add dsh-session-guard@dsh-0.1.5
Note:
Do not rely on the bare package name dsh-session-guard. npm’s latest tag cannot simultaneously serve two mutually exclusive version lines (the engines.dsh values on the two lines are mutually exclusive according to semver pre-release rules). You must use the specified dist-tag (for example, @dsh-0.1.5).
Compatibility and Limitations¶
- Language support: Version v0.1.1 includes Japanese (
ja) and Korean (ko) dictionaries, but the current official DSH only provideszhandenthroughLocaleRuntime. Selectingjaorkoin the original DSH will fail and display a “locale not registered” message. You need to wait until official DSH adds the corresponding locale IDs before it can be used normally. - Degradation strategy: As mentioned above, all types of missing dependencies trigger silent degradation, ensuring that the plugin does not affect the host runtime.
Conclusion¶
dsh-session-guard provides a complete session gating solution. Combined with DeepSeek’s peak/off-peak pricing strategy, it can help developers reduce calling costs while maintaining business continuity. Its fail-open design also ensures the robustness of the plugin ecosystem.