Introduction

The official DeepSeek Harness (DSH) API currently only supports session archiving (hiding) and does not reduce the data volume in session.list. Long-lived autonomous sessions continuously generate subagent session records. When these records accumulate to dozens or hundreds of entries, they can slow down Web GUI response (measured 664 entries ≈ 1s/880KB). To address this pain point, the momojie-s/dsh-subagent-cleanup plugin provides a cleanup solution.

Plugin Overview

This is a DSH plugin maintained by Momojie-S, primarily designed to resolve subagent session accumulation. It provides two core capabilities: session self-cleanup (cleaning up descendant sessions of the current session) and operations-side cross-workspace cleanup (cleaning up cold records).

Core Features

  1. Session self-cleanup: Cleans up subagents and deeper descendants that belong to “the current session itself.” It determines ownership and state by enumerating through the subagent service, and only processes settled records, with no idle-hour threshold.
  2. Operations-side cross-workspace cleanup: Scans across workspaces by directory structure and only processes cold records that “have never been written since the current DSH process started and have been idle for longer than a threshold (default 24h).”
  3. Processing modes: Supports two modes: archiving (reversible, default) and complete deletion.

Installation and Activation

Install the plugin:

dsh plugin --profile web add github:Momojie-S/dsh-subagent-cleanup

After installation, restart DSH to apply changes.

Typical Usage

After installation, use natural-language commands directly in conversation:
* “Clear the subagent sessions accumulated for this task” → invokes the subagent_cleanup tool.
* “Clean up old StarRail subagent sessions” or “Do a global cleanup of subagent records” → invokes the subagent_cleanup_global tool.

Configuration

The plugin supports optional configuration through the config field. Main configuration items include:

Field Default Description
toolSelf subagent_cleanup Model-visible name of the self-cleanup tool
toolGlobal subagent_cleanup_global Model-visible name of the global cleanup tool
home DSH_HOME environment variable, falling back to ~/.dsh DSH home override
archiveRoot <home>/sessions-archive Archive target root
defaultIdleHours 24 Idle threshold for global cleanup (hours)
settleBufferMs 30000 Write buffer for disk-side sublevels (milliseconds)
liveBufferMs 600000 Silence period required before in-memory sublevels can be processed (milliseconds)

Mechanisms and Limitations

  • Tool differences:
    • subagent_cleanup: Enumerates only descendants of the current session and processes settled records.
    • subagent_cleanup_global: Scans bare UUIDs (subagents), skips main sessions with the session- prefix, and supports filtering by workspace substring and specifying a parent.
  • Safety boundaries: Archiving is the default and reversible; complete deletion is irreversible.
  • Runtime environment: The plugin runs with the permissions of the current DSH process.

Applicable Scenarios and Notes

  • Environment requirements: DSH version 0.1.5-rc.1 or later; supports Windows / Linux / macOS.
  • Notes: Please review the source code and license before installation; after the plugin loads successfully, the DSH log will display subagent-cleanup: active (tools subagent_cleanup/subagent_cleanup_global...).

Conclusion

This plugin fills a gap in the official DSH experience by adding session deletion capability, helping developers manage subagent session records effectively and improving Web GUI performance.