Introduction

When running long sessions in DSH, the context stacks up continuously: tool outputs, command results, and intermediate reasoning all remain in the visible history. Once the window is full, the entire segment must be recomputed, and prefix caching is easily interrupted under the “change one thing, invalidate everything after it” rule. Common practices like deleting messages or crude truncation compromise auditability or modify the toolset, making cache discipline harder to maintain.

Below is an introduction to dsh-memory-context-lab (current version 0.13.1, MIT) maintained by DreamRift. It is a context management plugin activated per DSH session. Its core capability is context cooling—sinking executed operations into an isolated cold store and replacing them with minimal receipts on the session surface. Starting from 0.9.0, it extends to full-history memory context and plan-first modes. The plugin does not add or remove tools visible to the model (changing the toolset invalidates the entire prefix cache), nor does it rewrite DSH’s append-only event log; archiving is handled via surface replacement in the host, keeping original events restorable, auditable, and replayable.

Community Directory Page: dsh-memory-context-lab. Source code and the sole operational documentation are in the GitHub README.

What is this

dsh-memory-context-lab is categorized as “Memory,” aimed at developers who need to control context volume within the same DSH session while hoping for readable and restorable original text.

What it does includes: archiving completed operations; keeping the recent N operations active (older ones are archived in batches once a threshold is met); recalling archive highlights based on relevance; and restoring original text or clearing isolated session data at any time.

What it does not do has been explained in the introduction: it does not touch the toolset or rewrite the underlying event log.

The cold store uses a composite backend: the Lingshu subprocess (T2) or a local Node store (T1). The session data directory is:

$DSH_HOME/.memory-context-lab/sessions/<first 24 chars of session-id sha256>/

The optional dependency is dsh-memory 0.8.1; it runs in standalone mode when absent. When enabled, it suppresses automatic read/write of dsh-memory per session (without modifying the toolset). Verified hosts include DSH Desktop 0.2.0-rc.2. Unavailable cold stores do not block enabling (T1 fallback); archiving or recall failures will shut down. Occupancy-related features will fail-close if requestHeader(), tokenMeter.measure, or contextWindow are missing; reasons can be checked via status / dry-run.

Prefix Cache Discipline (Why “Batching”)

Replacing content at position i forces everything after i to be recomputed at a miss price. Accordingly, the plugin does enough in one batch (batch count is the cost source), recall only lands at the batch tail, and the toolset remains constant. The README points to the “Prefix Cache Discipline” section in the workspace document docs/架构与边界.md.

“Keep recent N operations” is always active, constrained only by the batch threshold: a batch is committed only when enough units accumulate outside the window. Hard protection applies only to system instruction nodes and the latest user message. Commits are segmented by adjacency; protected, ineligible, or cold-write-failed units create segments, so the receipt count per batch may be less than the threshold.

Core Features

Context Cooling (Default Path)

Daily usage is enabled via /memory-lab on. Disabling uses /memory-lab off: it first restores original text, then lifts suppression and deletes the isolated directory; the documentation explains the cold store logic retained upon disabling, and turning off via the panel follows the same deactivation path.

The model-visible read-only tool is memory_lab_recall(record_ids=[…])—you can copy the call directly from the “readable” line in the receipt.

Full-History Memory Context (fullhistory)

/memory-lab set fullhistory on

Switches to full-history mode: fully retains the system header, all human user messages, the cooling receipts themselves, and plan artifacts; the rest sink into the isolated ArchiveStore, with an isolated Lingshu backend started automatically and incremental index synchronization per batch (plugin sources are not indexed or recalled). In this mode, “keep recent operations” is invalidated (panel greys out); retention is ruled by the active evidence protection layer, with soft retention constrained by set protect <budget> (default 32768) and TTL. Turning off full history restores first, then flips the mode.

Plan First (planfirst)

When enabled, brand new conversations automatically enter DSH plan mode before the first message (uses the service if available, otherwise writes to plan/mode): the AI generates a plan first, and cooling is automatically enabled the moment the user approves (no need to type /memory-lab on). During planning, cooling, recall, and working status cards are suspended (manual commands remain available); the full plan text is retained forever and cannot be cooled. Sessions with existing history do not auto-enter. The plugin-level default is planFirst: true, overridable per session. set planfirst off will also exit plan mode if the current session is still in active/pending.

Layered Card Desensitization and Member-Level Exclusion (0.11.0)

Cards do not copy body text by default: excerpt-type values render as (正文摘录未共享) [Body excerpt not shared], leaving only entity, attribute labels, polarity/relationship labels, source ID, and the expand entry; structured attributes (exit codes, test summaries, version numbers) are retained as usual. set sharel2content on enables excerpts (default off, fail-close).

Member-level exclusion: forgetting one member no longer invalidates the whole group—the forgotten one is excluded from the participation set, and the rest are compressed normally; full exclusion still results in the whole group failing close.

Security and Reversibility

Before archiving, body text is written to the isolated cold store and read back for hash verification; failures, missing data, or hash mismatches result in retaining the original text and reporting the stage. If the single node limit is exceeded, verification is chunked by code points. Receipt text consists only of stable identifiers; restore writes back by original bytes. clean refuses to delete if unrestored receipts remain. The plugin only cleans data owned by $DSH_HOME/.memory-context-lab/ and never writes to the real Lingshu.

Installation and Uninstallation

The README states: the plugin is already installed as a bundle in the desktop profile; modifying host-side source requires restarting DSH, while modifying src/client.js only requires refreshing the page. The documentation does not provide installation commands like dsh plugin add github:…; please refer to your current DSH release’s bundle / plugin management methods.

Uninstallation and data clearing:

Uninstall: plugin_manager remove_bundle dsh-memory-context-lab
Clear data: delete $DSH_HOME/.memory-context-lab/ (or execute /memory-lab clean in each session)

/memory-lab clean confirm delete-session discards the isolated cold store for the current session (irreversible; must off first). 0.13.1 is incompatible: /memory-lab2 has been removed; old session directories sessions/<key>/state.json are no longer read (not deleted or migrated). Archived originals remain on disk; you can manually delete $DSH_HOME/.memory-context-lab/sessions/ after confirming they are no longer needed.

Runtime and development require Node >=22.19 (README test environment: Node v24.19.0).

Typical Usage

The sole main command is /memory-lab (v1 engine and /memory-lab2 have been removed since 0.13.1).

Enable and status:

/memory-lab on | off          Enable / Disable
/memory-lab status            Engine status, record count, recent actions, occupancy, single-batch release cap, cost ledger
/memory-lab restore           Restore original text for all restorable receipts, engine remains enabled
/memory-lab now | dry-run     Run one "measure → gate → commit → replace"; dry-run has zero side effects

Readback and settings:

/memory-lab read <RecordID…>    Read back original text (Exact ID / Cold node basename / callId all valid)
/memory-lab set <key> <value>  auto | recall | autorestore | batch | retain | readlease | pressure | protect |
                             fullhistory | compress | compressmodel | sharel2content | planfirst
/memory-lab card | cost        Working status card / Cost ledger

Search, forget, compress, and sub-sessions:

/memory-lab recall <Query> · verify | mark-stale | relations | history | working-set | index
/memory-lab forget preview|apply|undo|status · compress preview|run|status · expand <CredentialID>
/memory-lab fork <SubSessionID> | fork-status | fork-reset <SubSessionID>
/memory-lab help               Grouped by "Lifecycle / Readback & Search / Evidence / Forget / Compress / Migration / Settings"

Graphical Entry: The “Cooling” trigger to the right of the composer permission controls (uses the same settings and actions as the command); status, full history, and plan-first summaries appear at the bottom of the popover along with the last output. Global defaults are in Settings → Components → “Memory Context”.

Following these steps, in a long session, you can start with on, use status / card to check occupancy and batches, use read or memory_lab_recall to pull back highlights when needed, and restore or plan off / clean before finishing.

Use Cases and Notes

Suitable for: Long-term coding, troubleshooting, and multi-round tool calls in the same DSH session where you want to control context length, adhere to prefix cache discipline as much as possible, and require restorable, auditable original text; enable fullhistory / planfirst when full history or “plan first, then auto-cool” is needed.

Notes:

  1. The plugin runs with the current dsh process permissions. Before installing or using it, you should review the source code and MIT license yourself and confirm the bundle source is trusted.
  2. If restoration cannot fit into the window, it will honestly refuse (original text remains in the cold store for readback); isolated data will not be deleted if unrestored receipts remain.
  3. SkillHub etc. are community directories and have no official affiliation with DeepSeek / Hiflux; metadata such as stars are subject to the display at the time on each site (GitHub README side repo has approx. 3 stars, 3 forks).

Conclusion

dsh-memory-context-lab sinks “completed operations” into an isolated cold store, replaces surface context with stable receipts, and recalls by relevance or fully restores when needed, while explicitly not touching the toolset or append-only logs. If you are doing long-session context governance in DSH, start with /memory-lab on and status, then enable fullhistory or planfirst as needed.

  • Directory Page: https://www.skillhub.cn/plugins/DreamRift/dsh-memory-context-lab
  • GitHub: https://github.com/DreamRift/dsh-memory-context-lab