cache-sentinel: Intercepting Misdispatched “cache expired” Sessions in DSH

Preface

It is common to leave an old session hanging in DeepSeek Harness (DSH) and then append a message later. If the validity window of the prompt cache has passed since the model’s last reply, the entire accumulated conversation will be billed as uncached input, causing costs to spike unexpectedly. Relying on manual time tracking or checking billing statements is not reliable.

Below is an introduction to the community plugin cache-sentinel (maintainer AliceSaikawa, categorized under admin-security). It determines whether the cache might have been invalidated based on “how long it has been since the last reply/update” and uses two methods—intercepting sends or automatic archiving—to reduce accidental sends.

What is this

cache-sentinel is a Host plugin for DSH: it prevents accidental message sends to old sessions when the prompt cache is likely expired, or archives sessions that haven’t been updated for a long time. The summary matches the description in package.json: DSH host plugin that guards against uncached prompts: blocks sends (read-only) and/or archives sessions after the prompt cache likely expired.

The community plugin directory is an independent site and has no official affiliation with DeepSeek / HF Trade. Please review the source code and license before installing. The plugin runs with the permissions of the current DSH process.

Core Functions

The plugin provides two protective measures on sessions where the cache lifecycle may have expired (can be used individually or in combination):

  1. Input Interception (block)
    The session can still be opened and read, but sends that would call the model are blocked. To continue the conversation, you can use the button above the input box or /unlock to allow the “next” send.

  2. Automatic Archiving (archive)
    Sessions not updated for a period of time are automatically archived, hidden from the sidebar, and cannot be opened, preventing accidental entry into old sessions.

You can use /sentinel within the chat to view status and switch between block, archive, both, and off. both is a combined mode: by default, it intercepts input after 60 minutes from the last reply and archives after 1440 minutes (24 hours) from the last update.

Mode Behavior (See README for default values)
block (default) Blocks sends after idleMinutes (default 60) since last reply; /unlock allows a single send
archive Auto-archives after idleMinutes (default 60) since last update
both Interception and archiving thresholds controlled separately by idleMinutes and archiveAfterMinutes (default 1440)
off No interception or archiving; /sentinel and /unlock remain available

The interception logic is executed at the head of the agent/pre-step hook (prepend: true), earlier than automatic compaction. On expired sessions, it prevents model calls triggered by compaction (see README “How It Works”).

The official Web UI displays a cache status banner above the input area; M3E (dsh-webui-m3e) displays an explanation in the conversation when interception occurs, but the pre-send banner requires support for loading other plugins’ client bundles on the M3E side. Additionally, GET /api/cache-sentinel.status?sessionId=<id> (requires Connection authentication) is provided to query session status.

Interface text adapts to the environment language (English/Japanese/Simplified Chinese); the log line prefix [cache-sentinel] is in Japanese.

Installation and Activation

  1. Run the installation command under the profile you actually use (web is just an example; you need a profile that includes the Web app, such as web or desktop):
dsh plugin --profile web add github:AliceSaikawa/cache-sentinel

To pin a version, you can add #v<version> at the end (e.g., github:AliceSaikawa/cache-sentinel#v1.2.3). The README notes: tags up to v0.5.0 and earlier do not contain build artifacts (lib/) and cannot be installed this way; you can also install using the cache-sentinel.tgz URL attached to the GitHub Release.

  1. Restart DSH. The plugin loads at process startup; if using a systemd user service, the example is:
systemctl --user restart deepseek-harness

Check, update, or remove:

dsh plugin --profile web list cache-sentinel --depth 0
dsh plugin --profile web remove cache-sentinel

To update, re-run the installation command and restart again; simply toggling the plugin before a restart will not replace the already loaded old code.

Typical Usage

Chat Commands

  • /sentinel: Displays the currently active mode and its source (chat settings or YAML), thresholds, minutes since the last reply in this session, and dryRun status.
  • /sentinel block | archive | both | off: Switches mode, writes to $DSH_HOME/cache-sentinel/state.json, and persists after restart (takes precedence over mode in YAML).
  • /sentinel default: Clears the mode saved in the chat, reverting to the YAML mode.
  • /unlock: Allows the next send on an expired session under block / both; the permission is valid for unlockTtlMinutes (default 10 minutes). Once the model returns, if the session hasn’t expired again, the conversation can continue normally.

Configuration Example

Adjust in the profile’s cordis.patch.yml (omitted items use default values). No DSH restart is required after modification, but in-memory /unlock permissions will be cleared:

- id: cache-sentinel
  config:
    mode: block               # block / archive / both / off
    idleMinutes: 60
    archiveAfterMinutes: 1440
    unlockTtlMinutes: 10
    checkIntervalSeconds: 60  # 10 or higher
    skipPinned: true
    archiveExisting: false
    maxPerCycle: 20
    dryRun: false

When dryRun: true, it only logs without actually intercepting or archiving, making it easy to verify thresholds.

Use Cases and Notes

Suitable for developers who frequently keep long DSH sessions but worry about triggering full uncached billing when sending a message hours later. If you want old sessions to disappear from the sidebar to reduce accidental opening, choose archive or both; if you still need to read history but forbid accidental sends, the default block is more appropriate.

Notes:

  • Only applies to profiles containing the Web app; see the repository README’s “Supported Versions and Environment” for environment and version details.
  • In archive mode, pinned sessions are skipped by default (skipPinned: true).
  • When continuously rejecting auto-continuation steps for zero-input messages, notifications for the same session are limited to once every 10 minutes.
  • The plugin runs with DSH process permissions; please read the source code and MIT license before installing.

Conclusion

cache-sentinel turns “cache might be expired” into a configurable interception or archiving strategy. It can be implemented using /sentinel, /unlock, and YAML, mitigating the billing risks caused by accidental sends to old sessions.

羽毛球分组比赛记分
小程序二维码

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

Xiaoye