Foreword¶
The plugin ecosystem of DSH allows mounting more capabilities within the host. In long conversations and cross-session tasks, the model often lacks previously confirmed context: task status, user preferences, project conventions, processes already undertaken, etc., leading to repetitive questioning or redundant exploration.
dsh-layered-memory addresses this type of memory deficiency. It is a DeepSeek Harness memory plugin that deposits conversations into layered memories in the background and injects relevant memories into the context before the model’s next step. Below, its capabilities, installation methods, verification steps, and notes are introduced.
What This Is¶
dsh-layered-memory is an L0~L3 layered distillation memory plugin for DeepSeek Harness, maintained by JunNanLYS under the MIT license.
Its core workflow is:
- Capture conversations to form L0.
- Extract atomic memories to form L1.
- Integrate scenario blocks to form L2.
- Distill core profiles or team methodologies to form L3.
- Automatically recall relevant memories and inject them into the context before each model step.
In simple terms, it transforms “information that appears in conversations” into reusable, recallable, and injectable memory assets.
Core Capabilities¶
Background Layered Distillation¶
The plugin automatically performs the following processes in the background:
- L0: Captures raw conversations.
- L1: Extracts atomic memories.
- L2: Integrates scenario blocks.
- L3: Distills more stable memory content such as core profiles and team methodologies.
This process does not require users to manually organize memories at every step.
Automatic Recall Injection¶
Before each model step, the plugin injects relevant memories into the context.
In the interface, such injections are presented as “context injection · memory” message lines for easy confirmation of whether memories are effective.
The injection process has length and time budgets. Truncation occurs if limits are exceeded, and timeouts result in skipping, aiming to avoid slowing down conversations.
Three Memory Tools¶
The plugin provides the following three memory tools:
memory_searchconversation_searchmemory_read_scene
These can be used to actively search for memories, conversation content, or scenario blocks.
Session-Level Memory Levels¶
The plugin supports session-level memory levels, including:
- Daily
- Work
- Smart
- Off
It also supports a write-only no-read toggle to control whether the current session only deposits memories without injecting them.
Deduplication and Reset¶
The plugin supports same-session deduplication: memories already injected will not be injected again.
When the context is compressed or cleared by /compact, it automatically resets, giving relevant memories a chance to re-enter the context.
Time-Weighted Recall¶
Recall sorting supports time-weighted recall, with the configuration item recall.decayHalfLifeDays.
This value is adjustable; setting it to 0 disables time-weighted recall.
Cost Recording¶
LLM call token costs incurred during the distillation process are written to a SQLite detailed table.
Relevant records can be viewed in the “Cost” tab on the settings page. When cost accounting fails, it only alerts and does not block distillation.
Data Directory¶
Memory data is written to:
~/.dsh/memory/
Which contains the following directories and files:
conversations/records/scenes/memory.db
Installation and Enablement¶
First, confirm that the environment meets the Node version requirement:
Node >= 22.16
The installation target is DSH’s web Profile. As per documentation, only execute the specified commands and do not modify other Profiles.
Method 1: Using npx for Installation¶
Suitable when dsh CLI is not pre-installed:
npx -y @deepseek-ai/dsh plugin --profile web add dsh-layered-memory
This command will execute the official CLI via npm and add the plugin to the web Profile.
Method 2: Using an Installed dsh CLI¶
If you already have dsh CLI installed, you can execute directly:
dsh plugin --profile web add dsh-layered-memory
If the current dsh is a pnpm forwarder and pnpm is not installed locally, first install pnpm:
npm i -g pnpm
dsh plugin --profile web add dsh-layered-memory
Method 3: Using a Repository or Local Path¶
Suitable for debugging or local development:
dsh plugin --profile web add https://github.com/JunNanLYS/dsh-layered-memory
Or:
dsh plugin --profile web add /path/to/dsh-layered-memory
Installation from Source¶
If you want to build and install from source:
git clone https://github.com/JunNanLYS/dsh-layered-memory
cd dsh-layered-memory
npm install
npm run build
dsh plugin --profile web add .
Post-Installation Verification¶
After installation, first check the data directory:
~/.dsh/memory/
The following should appear:
conversations/
records/
scenes/
memory.db
Also check the DSH interface:
- The settings page has a “Memory” page.
- The input bar shows a level pill.
After confirmation, manually restart DSH Web Host. Do not close or restart the running DSH for the user.
Typical Usage¶
After installation and restart, you can use it as follows.
-
Start a session and converse normally with the model.
-
The plugin completes L0 capture, L1 atomic memory, L2 scenario integration, and L3 profile distillation in the background.
-
Before the model’s next step, the plugin injects relevant memories into the context and displays a “context injection · memory” message line in the interface.
-
If the model needs to actively search memories, it can call:
memory_search
conversation_search
memory_read_scene
- Switch session-level memory levels in the input bar or settings:
Daily
Work
Smart
Off
-
If you only want to deposit memories without affecting the current session with memory content, you can enable the write-only no-read toggle.
-
If you prefer to lean towards newer memories, you can adjust:
recall.decayHalfLifeDays
Set to 0 to disable time-weighted recall.
- If the context is compressed or cleared by
/compact, the plugin automatically resets the injection state, and relevant memories can be recalled again later.
Uninstallation¶
If you need to uninstall:
dsh plugin --profile web remove dsh-layered-memory
Then restart DSH Web Host.
After uninstallation, data still remains in:
~/.dsh/memory/
If you confirm it is no longer needed, you can manually delete the entire directory.
Applicable Scenarios¶
dsh-layered-memory is particularly suitable for the following situations:
- Developers or users using DSH
webProfile. - Those who want to retain key context in long conversations.
- Those who want to reuse previously confirmed information across sessions.
- Those who want to reduce repetitive questioning, explanations, and exploration.
- Those who need to view token costs of distilled LLM calls.
- Those who need to switch memory strategies in different sessions, such as daily, work, smart, or off.
Notes¶
-
Environment Requirements: Requires Node
>= 22.16. -
Installation Target: Only install for DSH’s
webProfile; do not casually modify other Profiles. -
Permission Impact: The plugin runs in the DSH host environment, using the session, model call, and file system permissions accessible to the current
dshprocess. It is recommended to check the source code, dependencies, and MIT license before installation. -
Data Location: Memory data is written to
~/.dsh/memory/, which may contain memory content deposited from conversations. For sensitive projects, pay attention to directory permissions and cleanup strategies. -
Restart Requirement: After installation or uninstallation, manually restart DSH Web Host. Do not close or restart the running DSH for the user.
-
Uninstallation Cleanup: Uninstalling the plugin does not automatically clean up data under
~/.dsh/memory/. If no longer needed, manually delete the entire directory.
Related Links¶
- Community Directory: https://www.skillhub.cn/plugins/JunNanLYS/dsh-layered-memory
- GitHub Repository: https://github.com/JunNanLYS/dsh-layered-memory