Overview¶
The core design of DeepSeek Harness (DSH) is lightweight, plugin-based. When handling Agent memory, most existing approaches choose “automatic injection every turn,” causing memory content to be repeatedly sent in every conversation turn and leading to unnecessary Token waste. dsh-memory-lite addresses this pain point by treating memory as hierarchical Markdown and returning only matched snippets during queries.
This plugin uses a “zero resident” and “zero dependency” design, keeping the memory read volume for a single query to about 700 characters, saving around 92% compared with full reading. It is both a DSH plugin and a standalone CLI.
Core Design: Three Invariants¶
- Zero resident: Memory does not enter the system prompt. The only always-on item in the plugin version is a tool schema (about 50-100 tokens), and memory content is generated only when queried.
- Zero dependency: It uses only Node.js built-in modules and introduces no database, server, or background process.
- Traceable: Every memory entry carries a
sourcemark, and theverifycommand can check it back to the original conversation.
Installation and Enablement¶
Install the plugin to a specified Profile with the following command:
dsh plugin --profile web add github:MiHjy12138/dsh-memory-lite
After installation completes, the backend needs to be restarted (DSH assembly rule: newly added bundles are not hot-loaded).
Usage¶
This project provides two usage modes, both sharing the src/lib.mjs implementation.
Mode A: As a DSH Plugin¶
After installation, mem_query appears in the Agent’s tool list. The Agent can directly invoke this tool to retrieve memory. The memory store is located in the workspace’s memory/ directory by default.
Mode B: As a CLI Tool¶
It does not depend on the DSH environment and can be run directly with Node. It is suitable for manual retrieval or non-DSH scenarios.
Workflow and Commands¶
Before using the plugin, you need to complete data collection, distillation, and construction.
- Collect material
Scan conversation logs and generate material files under the.stagingdirectory.
node src/mem.mjs collect
- Build the memory store
Distill the material intoSUMMARY.md,INDEX.md, andtopics/*.md.
node src/build.mjs
- Query memory
Retrieve by keywords and return only matched snippets.
node src/mem.mjs query "powershell bom" --n 5
- Verify provenance
Verify whether the extracted memories accurately correspond to the original material.
node src/verify.mjs examples/extracts-example.json --staging examples/staging
Features¶
- Hierarchical Markdown: Includes a top-level
SUMMARY.md(one-sentence distillation), anINDEX.mdindex, and topic-partitionedtopics/*.md. - Token optimization: Measured memory queries reduced from 11,819 characters to 738 characters, saving about 92%.
- Zero dependency: Pure Node.js implementation, cross-platform.
- Low summary tax: The resident summary accounts for only 0.9% of the full text.
Applicable Scenarios¶
Suitable for scenarios sensitive to Token cost and requiring precise control of retrieved content by a human or an Agent. Not suitable for scenarios requiring semantic recall, knowledge graphs, or cross-machine synchronization.
Summary¶
dsh-memory-lite solves the Token waste problem in Agent memory retrieval through hierarchical storage and on-demand retrieval. It does not use automatic injection; instead, it manages memory through the explicit mem_query tool or CLI commands, ensuring that only necessary information is passed in each interaction.