Introduction¶
DeepSeek Harness (DSH) uses a plugin-based architecture, which makes extending functionality flexible. When building agent applications, the AI often remains in an “always-on” state. The dsh-ai-curfew plugin rewrites this state into “working on a shift schedule”. It controls AI behavior through two independent logic axes: one is a time-window-based “peak/off-peak shift”, and the other is a time-based “curfew curve”. The plugin applies whichever rule is stricter.
Core Functionality¶
This plugin implements off-duty control through the short-circuit mechanism of the llm/stream waterfall. Its core behavior is as follows:
- Behavior stages: The AI state is divided into “on duty” (full budget), “closing countdown” (maxTokens 2048→64), “off duty” (only returns “.”), and “lights out” (only returns “Talk tomorrow.”).
- Cost control: After going off duty, it no longer initiates API requests, achieving zero token usage, zero cost, and millisecond-level responses.
- Dual control axes:
- A peak/off-peak shift: Off during peak hours, on during off-peak hours (such as specific windows on weekdays).
- B curfew curve: After the curfew time, the budget slides from 2048 to 64 along the anchor table.
- The stricter rule takes precedence.
- Short-circuit replies: Off-duty replies do not make network calls and directly generate streaming output, preventing request failures from making users think “the AI is dead”.
- Flexibility: Gate A can be disabled independently, falling back to a pure curfew plugin.
Installation and Enablement¶
DSH isolates plugin environments by profile. Replace --profile desktop with the profile you actually use.
Install from GitHub (pinning the version is recommended):
dsh plugin --profile desktop add github:qiz42144-web/dsh-ai-curfew#v0.1.0
Install from a local directory (for development and debugging):
dsh plugin --profile desktop add link:/绝对路径/ai-curfew
The configuration file is located at $DSH_HOME/dsh-ai-curfew/config.json. Changes are hot-reloaded based on mtime and take effect without restarting DSH.
Configuration Guide¶
The configuration file supports the following keys (all others use default values):
{
"enabled": true,
"timezone": "Asia/Shanghai",
"wakeUp": "09:00",
"curfewStart": "23:00",
"lightsOut": "03:00",
"peakShift": true,
"offDutyReply": "。",
"lightsOutReply": "明天再说。",
"anchors": [23, 2048, 24, 64],
"curve": "linear",
"debugNow": "01:30"
}
anchors: Budget anchor table, formatted as[time, tokens].curve: Interpolation mode. Supportslinear(linear),step(step), andeaseIn(stable first, then collapse).debugNow: Time-machine feature; you can manually specify a time for testing.
Usage¶
The plugin provides a set of CLI commands that bypass the model, ensuring they remain usable even when the AI is off duty.
/curfew: View the current decision, budget, and rationale./curfew overtime 30m: Force overtime for 30 minutes (pause curfew; the AI operates normally during this period)./curfew off: Go off duty immediately./curfew auto: Restore the automatic schedule (cancel overtime, forced off-duty, and time-machine override)./curfew debug HH:MM: Time machine; test any time window./curfew debug clear: Return to real time.
Terminology note: In this plugin, “overtime” means you command the AI to stay late, not that the AI requests time off; the off command only covers “AI going off duty” and is not an alias for “disable curfew”.
Notes¶
- Not published to npm yet: Currently, it can only be installed from GitHub.
- Restart required: After code changes, DSH must be restarted for them to take effect.
- safetyMaxTokens disabled by default: Off-duty replies are generated directly by plugin logic, so an additional hard limit is unnecessary. If you enable it manually, adjust it according to the model’s reasoning effort; otherwise, it may cause request failures.
- Permissions: The plugin runs with the permissions of the current DSH process. It is recommended to review the source code and license before installing.