dsh-auto-archive: Automatically archive DSH sessions based on idle duration

Introduction

When running agent sessions on DeepSeek Harness (DSH) over long periods, the sidebar and the on-disk session directories will inevitably grow. Manual organization alone makes it difficult to distinguish between “active” and “cold” (abandoned) sessions. Additionally, attachments stored as sha256 shards under the harness directory will consume increasing amounts of space over time. While the community already has dsh-archived-sessions (based on MuWinds) for viewing and releasing archived sessions, there has been a lack of a mechanism to perform background rule-based scans to move cold sessions into the archive area.

Below, we introduce maintainer wzn16’s dsh-auto-archive (Category: Memory). It adds an auto-archive engine on top of the archive management UI and optionally provides manual scanning to clean up attachments not referenced by active sessions. The plugin runs with the permissions of the current DSH process. Please review the GitHub source code and the MIT license before installation.

What is this

dsh-auto-archive is a session auto-archiving plugin for DSH (current package version 0.4.6, requires DSH >=0.1.5-rc.1). It addresses two main issues: first, automatically moving cold sessions to the archive area based on an idle threshold, with scan previews and manual archiving provided in the Web settings; second, since v0.4.0, it supports reference scanning and manual cleanup for the attachments directory. Capabilities such as listing archives, releasing, deleting from disk, and content previewing are inherited from a refactored implementation of dsh-archived-sessions.

Directory Page: skillhub.cn/plugins/wzn16/dsh-auto-archive
Source Code & Docs: github.com/wzn16/dsh-auto-archive

How Auto-Archive defines “Idle”

The core criterion for auto-archiving is the last active time, not the session creation time displayed in the sidebar.

  1. Idle Threshold: It takes the latest mtime (modification time) of all generation logs (e.g., session.jsonl.zstd, session.v3.jsonl.zstd) within the session directory. If no writes have occurred for more than N days, the session is considered archivable. The default N is 14 days.
  2. Difference from List Display: The sidebar often displays “X days ago” based on creation time. If the session had writes (like “continue session”) a few days ago, the actual idle days might be shorter, and it will not be auto-archived before reaching the threshold. The session list in the settings panel displays both metrics: “Created X days ago · Idle Y days”.
  3. Background Scanning: Scans run once per day by default, with a period adjustable between 0.25–365 days. The first scan runs approximately 3 minutes after Harness startup, and scan tasks do not overlap.

Safety Guardrails and Archiving Channels

Auto-archiving only handles “completely cold” sessions. The README explicitly states that the following situations will not be auto-archived:

  • Sessions currently running a turn;
  • Sessions still residing in memory (live), even if the disk file hasn’t been written to for days;
  • Sessions pinned in the sidebar;
  • Sessions in the manual exclusion list excludeIds;
  • Sessions already in the archive area (idempotent skip).

Archiving prioritizes calling the official workspaceRegistry.archiveSession(). In case of an exception, it falls back to direct storage domain writing and synchronizes the private cache (consistent with the fallback approach of dsh-session-manager). Auto-archiving itself is reversible (via release); however, deleting session files from disk always requires your manual confirmation in the UI and is irreversible.

Settings Page Capabilities

After installation and restarting DSH, you can find the Harness Settings → Archive Sessions page:

Auto-Archive Card

  • Toggle, idle threshold, scan period;
  • Scan Now (Preview Only), Scan and Archive Now (requires secondary confirmation);
  • Last scan audit and pending archive preview list.

Manual Operations

  • Perform “Archive” or “Never Auto-Archive” on individual sessions in the list (maintains excludeIds, no need to wait for the idle threshold).

Archived Session Management (Inherited Capabilities)

  • View archived sessions (title, creation time, directory, path, space usage);
  • Release (single / batch / one-click all);
  • Delete from disk (single / batch / one-click clear, two-step confirmation);
  • Click title to expand and preview user / assistant / tool messages.

Attachment Cleanup (v0.4.0+)

Images and files pasted or dragged into sessions are stored in <harness-home>/attachments/v1/objects (sharded by sha256). The plugin links cleanup with archive status:

  1. Scan: Decompresses all unarchived (including active) session logs to build an attachment reference index. Attachments not referenced by any unarchived session (used only by archived or deleted sessions) are listed as cleanup candidates.
  2. Matching: Matches by sha256 filename, independent of path separators. The strategy is conservative—preferring to clean less rather than risk incorrect deletion.
  3. Execution: Scanning must be triggered manually (takes ~5–20 seconds for hundreds of sessions); no automatic deletion occurs. Cleanup requires two-step confirmation and is irreversible. Files are deleted one by one; a single failure does not interrupt the batch. It only processes sha-named files under objects/ and does not touch request-images/, tmp/, etc.

Configuration Persistence

Configuration and the last scan audit are written to dsh-auto-archive.json in the harness root directory (the path is derived from the session artifact location, e.g., on macOS it might be ~/Library/Application Support/dsh-desktop/harness/dsh-auto-archive.json). Writes are atomic, and you can also manually edit the file and restart DSH to apply changes.

Installation and Activation

The installation method described in the documentation is to pnpm link the local package in the web profile. After completion, restart DSH, and the “Archive Sessions” page and “Auto-Archive” card should appear in the settings.

If the plugin source code is already in a local directory (replace the path with your actual location):

cd ~/Library/Application\ Support/dsh-desktop/harness/profiles/web
pnpm add "link:/path/to/dsh-auto-archive"

The README also provides steps to clone from GitHub and then link (clone location is up to you):

git clone https://github.com/wzn16/dsh-auto-archive.git
cd ~/Library/Application\ Support/dsh-desktop/harness/profiles/web
pnpm add "link:/path/to/dsh-auto-archive"

After restarting DSH, you can use the above features in the settings. The community plugin directory SkillHub and DeepSeek / High-Flyer have no official affiliation. Please refer to the repository README for installation methods.

Typical Usage

  1. Turn on Auto-Archive in Settings → Archive Sessions, set the idle threshold to match your habits (default 14), and keep the scan period at daily or adjust the interval as needed.
  2. Click Scan Now (Preview Only) first to review the pending archive list and the “Created / Idle” metrics, ensuring you haven’t accidentally targeted sessions you still use but which were created long ago.
  3. Use Never Auto-Archive for sessions you need to keep long-term but are currently inactive; use Archive individually for sessions you know are cold, without waiting for the threshold.
  4. After confirming everything is correct, use Scan and Archive Now (secondary confirmation), or wait for the scheduled task to run in the background.
  5. When disk space is tight, manually trigger a scan in the attachment cleanup area, review the candidate list, and then perform the two-step confirmed cleanup (irreversible).

Use Cases and Notes

This is suitable for developers who accumulate a large number of sessions in local DSH over long periods and want to use rules to move cold sessions out of the main list and manage them uniformly in the archive area. When you need to periodically check archived storage usage, batch release, or cautiously delete disk copies, you can do so from the same settings page.

Important Note: The plugin includes the capability to delete session files; auto-archiving does not delete from disk, but deletion must be manually confirmed. The plugin runs in the same process and with the same permissions as DSH. The exclusion list and pinning rules are part of the safety design, but it is still recommended to preview scan results in critical environments first. For development builds, refer to npm install, npm run build, and npm run typecheck in the repository.

Conclusion

dsh-auto-archive complements the archive session management UI with idle determination based on log mtime, scheduled scanning, and multiple skip rules. It also turns attachment orphan scanning into a manual, auditable cleanup process. If you want to integrate or perform secondary development, start with the division of labor in src/auto-archive.ts, src/index.ts, and src/client.tsx mentioned in the repository README.

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

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

Xiaoye