Preface¶
When using Subagent in DeepSeek Harness (DSH), session logs (session log v4) and projection cache together record entries in the Subagent panel. If the panel gets stuck, desyncs, or entries cannot be deleted in the UI, you are often left staring helplessly at session.v4.jsonl.zstd and storages/session_projcache on disk. Directly deleting log lines or modifying seq will cause v4 validation to fail (e.g., format v4 event N is not dense), making the entire session unable to load.
The dsh-agent-clean described below (maintainer PolitaryMonicy, community category admin-security) is a cleaning tool for DSH: dry-run by default, full backup before writing, uses the approach of “changing type + marking ignorable” to move Subagent entries out rather than deleting lines; and can clean up orphaned projection caches, purge entire sessions on demand. The same repository contains both an independently runnable CLI and an optional DSH Desktop plugin half (settings page + auto-cleanup after exit).
What is this¶
dsh-agent-clean is positioned to: clean Subagent entries in DSH sessions, entire session data, and orphaned files where “session directory has been deleted but projection cache still exists”. The implementation has zero third-party dependencies, only using Node.js built-in modules (including node:zlib’s zstd). The project background comes from a real failure: a session’s Subagent panel got stuck/desynced, entries could not be removed; the author reverse-engineered DSH session log v4 and the loader, then packaged the non-destructive fix into a CLI, and covered it with regression tests.
DSH data defaults to DSH_HOME (usually ~/.dsh, on Windows C:\Users\<you>\.dsh), can be overridden via environment variables. Typical session-related paths are:
$DSH_HOME/sessions/<escaped-workspace-name>/<session-id>/session.v4.jsonl.zstd
$DSH_HOME/storages/session_projcache/sessions/<session-id>.json
Running the CLI requires Node.js >= 22 (zstd support is checked at startup); optionally install DSH Desktop for “real loader” self-check, otherwise can point --modules to node_modules containing @deepseek-ai/*.
Core Features¶
Non-destructive removal of Subagent entries¶
- Does not delete any log lines, does not reorder
seq(v4 requires dense seq). - Only rewrites the session’s own
subagent/cataloglines tosubagent/catalog-dismissed, and setsignorable: true. - Simultaneously writes the projection cache’s
subagentCatalogas a valid empty state (when session directory is deleted, DSH’sdsh-chat-managerdoes not automatically delete the corresponding projection cache, easily leaving orphans).
Full session purge and orphan cache¶
purge: After complete backup, deletes session directory, related generation logs and projection cache.orphans: Lists or deletes entries where “session directory no longer exists, but projection cache still exists”.
Backup and recovery¶
Full backup before each write; restore --backup <dir> can restore byte-by-byte.
Optional plugin half¶
After installing the Desktop plugin, open the diagnostic page at Settings → Session cleanup: the scan logic is consistent with the CLI’s list + orphans, displays the number of Subagent entries in each session, log size, cache titles and orphan items, and provides copyable dismiss / purge / orphans commands (including commands to clean up Subagent entries for all sessions in one go).
The plugin does not modify committed session storage during DSH runtime (the persistence contract requires dense seq, single writer; the projection cache also has no invalidation API). Actual changes occur after completely exiting DSH, going through the same clean.mjs process as manual execution: full backup per session → structural self-check → real loader verification.
“Auto-cleanup on exit” is enabled by default: writes the switch state each time DSH is started, and spawns a detached helper (clean.mjs autowait --pid <DSH process>), waits for that pid to disappear then executes the same pipeline as dismiss --all --apply for sessions that still have Subagent entries, with results written to auto-report.json. For it to actually run to completion, you need to completely exit DSH (just closing the window may still leave it running in the background), wait for the helper to finish before reopening.
Installation and Activation¶
As a DSH Desktop plugin (optional)¶
Add in the plugin manager (choose one of the following sources, after installation you need to completely exit and restart DSH):
dsh plugin --profile desktop add dsh-agent-clean
dsh plugin --profile desktop add github:PolitaryMonicy/dsh-agent-clean
dsh plugin --profile desktop add /path/to/this/repo
Uninstall:
dsh plugin --profile desktop remove dsh-agent-clean
If the diagnostic page shows “Host returned HTTP 404”, it means the host half is not loaded; you can check the plugin items in dsh --profile desktop --dump-config, and on Windows %TEMP%\dsh-agent-clean-host.log.
The DSH engine requirement declared in package.json is dsh >= 0.2.0-rc.1; the license is MIT (npm package version information shows 1.3.7).
Standalone CLI¶
No npm install needed. After extracting from the GitHub page Code → Download ZIP, execute in the repository root directory (choose one of three):
node clean.mjs list
chmod +x clean.sh
./clean.sh list
On Windows you can use clean.cmd list. The wrapper script will look for %DSH_NODE% / $DSH_NODE, node on PATH, or common installation paths in sequence.
Typical Usage¶
By default without --apply it is a dry-run; after confirming the output, add --apply to write.
| Command | Effect |
|---|---|
list [--workspace <substr>] |
Lists sessions, titles, log sizes, and the number of Subagent entries per session |
dismiss --session <id\|prefix> [--apply] |
Non-destructively removes Subagent entries from the specified session |
dismiss --all [--workspace <substr>] [--apply] |
Performs the same operation on multiple sessions |
purge --session <id\|prefix> [--apply] |
Deletes the entire session and associated cache after backup |
orphans [--apply] |
Lists or deletes orphaned projection caches |
restore --backup <dir> |
Restores from a backup directory |
Example: first check, then apply dismiss to a single session:
node clean.mjs list
node clean.mjs dismiss --session <session-id or prefix> --apply
Clean up Subagent entries for all sessions (consistent with the logic used by the plugin’s auto-cleanup after exit):
node clean.mjs dismiss --all --apply
Applicable Scenarios and Notes¶
Who it is for: Session Subagent panel anomalies, entries that cannot be cleared; need to batch dismiss or delete entire sessions; projection caches left without corresponding session directories after upgrades or migrations. The category falls under admin-security, belonging to management operations on local DSH data, not business logic plugins.
Permissions and security: The CLI reads and writes DSH_HOME with your current user permissions; the plugin host routes and detached helper also run locally. Before installation, you should read the repository source code and MIT license, and confirm you accept the scope of rewriting session files; for production or important sessions, always dry-run first, and keep the backup directory until you confirm both the UI and loader are normal.
Operation habits: The plugin instructions emphasize “dry-run first, backup first”; after modifying sessions, you need to completely exit DSH before reopening, otherwise the in-memory projection cache may still have old values. If you turn off the auto-cleanup switch, the commands given by the diagnostic page are the same as manual CLI.
For more complete Chinese documentation, see the repository README.zh.md.
Links¶
- Community directory page: https://www.skillhub.cn/plugins/PolitaryMonicy/dsh-agent-clean
- Source code and documentation: https://github.com/PolitaryMonicy/dsh-agent-clean
The DSH community plugin directory is independently maintained by sites like SkillHub, and has no official affiliation with DeepSeek / High-Flyer; when selecting plugins, use the repository README and local self-checks as the standard.