Introduction¶
The built-in compression mechanism in DeepSeek Harness (DSH) usually operates only based on request pressure and provider-confirmed context overflow. It does not consider how long a session has been idle. The dsh-idle-compactor plugin adds a new dimension: when a session exceeds the token threshold and has remained quiet (idle) for a long time, compression is triggered. This avoids paying for stale context tails on every request.
Core Features¶
The plugin implements the following capabilities:
- Idle-triggered context compaction.
- Compression of sessions that remain quiet after exceeding the configured token threshold.
- Support for idle time and context size as triggers.
- Configurable scan interval.
- Support for dry-run mode.
- Ability to handle archived sessions.
- Ability to handle background work.
Installation and Dependencies¶
Prerequisites:
* DeepSeek Harness version 0.1.2-alpha.3 (verified).
* The Harness built-in compaction interface and tokenMeter.
The plugin has no runtime dependencies. All @deepseek-ai/* imports in the source code are import type and are erased by the compiler, so lib/index.js is a single-file, self-contained ESM module.
Installation Steps:
Run the following command in the project directory:
dsh plugin --profile web add ./dsh-idle-compactor
After installation, restart the profile; the patch layer will be reloaded, whereas bundled mounts will not.
Configuration and Usage¶
The configuration file is located in the profile’s cordis.patch.yml. The plugin’s configuration items control compaction behavior through thresholdTokens (context size) and idleMs (idle time). Both conditions must be satisfied simultaneously for compaction to occur.
Add the following configuration to cordis.patch.yml:
- id: idle-compactor
config:
thresholdTokens: 131072 # 128K
idleMs: 600000 # 10 分钟
Configuration Items (partial):
| Key | Default | Meaning |
|---|---|---|
enabled |
true |
When false, scanning is completely disabled. |
thresholdTokens |
131072 |
The threshold for context size. |
idleMs |
600000 |
The time window after which a session is considered idle. |
scanMs |
30000 |
The scan interval, determining how long after idleMs compaction is triggered. |
skipAwaitingWork |
true |
Skip compaction when background tasks are present, preventing context rewrites while tasks are running. |
Applicable Scenarios and Notes¶
- Applicable scenarios: Scenarios that require managing the context size of long conversations, especially when there has been no new user input for a long time but the context keeps growing.
- Background work handling: The plugin checks sessions and their sub-sessions for whether they are handling background tasks (such as jobs, inbox messages, or sub-agents). If background work is detected as still in progress, the session is skipped and not compacted, in order to avoid affecting ongoing background tasks.
- Archived sessions: The plugin skips the set of archived session IDs.
- Security check: Please inspect the source code and license before installation. The plugin runs with the permissions of the current DSH process.
Summary¶
dsh-idle-compactor adds a time- and state-based automatic compaction policy to DSH. By configuring thresholdTokens and idleMs, it can keep the context concise while avoiding interruptions to the conversation flow during background tasks or inactive periods.
- GitHub repository: https://github.com/QuanhuZeYu/dsh-idle-compactor
- Plugin directory: https://www.skillhub.cn/plugins/QuanhuZeYu/dsh-idle-compactor