dsh-idle-compact: Pre-generate Session Compaction During User Idle Time, Apply with One Click and Eliminate Extra Model Calls

Introduction

When running long sessions in DeepSeek Harness (DSH), the context length continuously grows. Model providers typically implement KV caching for conversation prefixes: when the cache is valid, the cost to re-read long history is low; once it expires, the next message is often re-billed at the uncached input rate for the entire history.

Manually executing DSH’s /compact can compress history, but if you are away from the keyboard for a while, the cache may have already expired, meaning that single summarization step will be billed at full price. The plugin introduced below runs the same summarization request as /compact in advance during a window when the user is idle and the cache might still be valid, staging the result temporarily. You can apply it with a single click upon returning to the session, and the apply phase initiates no new model calls.

What is this

dsh-idle-compact is a plugin for DeepSeek Harness, published by maintainer Arrosam and categorized as a “Workflow” in the SkillHub plugin directory. Source code and documentation are available at GitHub: Arrosam/dsh-idle-compact.

In short: during idle periods when the user has left and the session is waiting for input, if the context reaches a threshold, it prepares a compression summary while the KV cache may still be valid. The session content remains unchanged until you click to apply.

Core Features

Idle Timing and Cancellation

  1. After a conversation turn ends and the session enters a state waiting for your input, the plugin starts a timer.
  2. Any new activity within that session cancels the timer, including your reply or the agent starting work again.

Conditions for Pre-preparing Compression

When the timer expires, compression is prepared only if the following conditions are met simultaneously:

  • The agent is still idle, and the previous turn ended normally (not an error or stop);
  • There are no running background tasks or subagents in the session;
  • The session context length (as measured by the DSH token meter) has reached the configured threshold.

The pre-preparation process executes the same summarization request as DSH /compact. The result is saved in memory and does not modify the current session.

One-Click Apply

An Apply compaction bar appears above the message input box, displaying the number of history items this summary will overwrite. Clicking it invokes DSH’s native /compact command and answers its summarization request with the prepared summary, thus generating no new model calls; the interface displays the same card as a manual /compact (e.g., “Compacted N history items”).

If you have sent a message after the preparation, or the history has changed in other ways, the prepared summary is discarded and the button disappears; it will be prepared again during the next qualifying idle period. If the conversation state at the time of clicking differs from when it was prepared, /compact will initiate a model call itself rather than using a potentially stale summary.

Startup and Reload Behavior

When the plugin starts or reloads (e.g., DSH restart, plugin update), sessions already waiting for input will re-time from the end of the previous turn: if the idle time has not yet reached the configured duration, only the remaining seconds are counted; if the session has been idle for longer than the configured duration, it is skipped this time (at this point, the provider cache is likely expired, and pre-preparation would be billed at full price), and it will wait for the next conversation turn to end before participating in the judgment again.

Subagent sessions are skipped (they do not wait for user replies). If the timer triggers while the agent is still busy, compression is not prepared, and a log is recorded.

Installation and Enablement

Requires the DSH Web UI. The README states it has been tested on DSH 0.2.1-alpha.3 and 0.2.1-rc.2; earlier versions are untested. The plugin uses DSH’s authenticated /api routes, settings form components, and the conversation.input.dock above the message input area.

Command line installation:

dsh plugin add github:Arrosam/dsh-idle-compact

Alternatively, open Plugins → Add plugin in the Web UI and enter github:Arrosam/dsh-idle-compact or a local checkout path.

The plugin runs with the permissions of the current DSH process; please review the source code and license (MIT) before installing.

Configuration

Open Plugins → Idle Compact in the DSH Web UI:

Setting Default Description
Context length threshold (tokens) 256000 Only prepare compression when the session context reaches this token count
Idle time (seconds) 300 (5 minutes) How long to wait without a reply before starting preparation

Both values are integers greater than or equal to 1. Changes take effect without restarting DSH; idle duration changes take effect the next time a session enters a waiting state.

You can also write the following in the profile’s cordis.patch.yml:

- id: idle-compact
  config:
    contextThresholdTokens: 200000
    idleSeconds: 240

Typical Usage

  1. Install and enable the plugin, adjusting the context threshold and idle seconds as needed.
  2. Interact with the agent normally in a long session; when a turn ends and you step away from the keyboard, once the threshold is met and the idle time is full, the plugin completes the summarization in the background (when the cache is still hot, the cost is lower).
  3. Upon returning to the session, if an Apply compaction bar appears above the input box, confirm the number of items to be overwritten and click to apply; the session updates via the standard DSH /compact flow, and the apply does not incur additional model calls.

No extra commands need to be memorized; the conversation history remains unchanged until you click to apply.

Token Cost and Use Cases

Each successful pre-preparation initiates one summarization model call. Because it usually executes while the cache is still valid, it is generally cheaper than compacting after the cache expires, but that call has already occurred—even if you never click Apply or never open that session again. If you have many sessions that are “open and forget,” you can increase contextThresholdTokens to reduce unnecessary pre-preparation.

Prepared summaries are stored only in memory and are cleared when DSH restarts.

Best for: DSH Web UI users who frequently keep long-context sessions open, leave and return intermittently, and want the compression timing to fall within the cache window.

Note: Requires the Web UI; subagent sessions are not involved; pre-preparation is bound to the /compact capability; the browser side communicates with the Host via the /api/idle-compact/* routes registered by the plugin, and DSH validates login and origin.

Conclusion

dsh-idle-compact transforms “when to compact” from a completely manual process to an automatic pre-calculation of summaries when idle and the context is sufficiently long. Upon returning to the session, a single click applies DSH’s native /compact, reducing the overhead of re-billing for long history in appropriate scenarios.

  • Directory Page: https://www.skillhub.cn/plugins/Arrosam/dsh-idle-compact
  • GitHub: https://github.com/Arrosam/dsh-idle-compact
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye