Introduction¶
The DeepSeek Harness (DSH) plugin ecosystem emphasizes modularity and composability. When building Agents with DSH, a common pain point is the context gap between sessions—after a conversation ends, the Agent loses memory of prior information. dsh-engram is a plugin designed to solve this problem. It provides DSH with cross-session long-term memory capability. The plugin adopts a “Memory Palace” information architecture, translating this psychological method into machine-implementable data structures. Combined with hybrid retrieval, spaced repetition review, and knowledge flywheel mechanisms, it helps the Agent build a stable long-term memory library.
Installation¶
By default, the plugin stores its database shards and model cache in the ~/.dsh/engram directory. Use the official npm package name to install it:
dsh plugin --profile web add @kenz1117/dsh-engram
After installation, basic functionality can be enabled without extra configuration.
Core Architecture: Memory Palace¶
The core design of the plugin does not rely on biological or neuroscience metaphors. Instead, it uses information architecture principles to build a storage and retrieval system. It follows four main principles:
- Position as Index: Each memory is written to a fixed “room#peg” coordinate. Room capacity is 9. Peg slots only accumulate and are never reclaimed. When full, a new room is automatically opened.
- Fixed Route Determines Order: The system maintains a
tour_routeslist and tours memories in peg order. Once this order is established, it is not modified. Recall relies on order rather than re-retrieval. - Long-Term Reuse of Skeletons: Content for the same topic always falls into the same room and the same sequence. Stable physical positions help ensure coherence across memories.
- Unique Markers: During writes, a 0–1 score is assigned based on rules such as database-wide uniqueness, date anchors, and non-repetition of the first six characters within the same room. Low-scoring memories enter the refurbishment list.
Key Features¶
Dual-Layer Databases and Hybrid Retrieval¶
The plugin uses a two-tier database structure:
* Global Database (user.db): Stores personal preferences, experiences, and other cross-project general information.
* Project Database (project-<hash>.db): Isolated by git repository identifier. Stores project-specific technology choices and conventions.
Retrieval uses a hybrid mode, combining FTS5 (with Chinese 2-gram pre-tokenization support) and the local embedding model Xenova/bge-small-zh-v1.5 (512-dimensional, q8 quantization). If downloading the offline embedding model fails, the system automatically falls back to pure keyword retrieval.
Corridor Routing and Spaced Repetition¶
To reduce the pressure of full-database retrieval, the system introduces the concept of corridors. The user profile includes a room directory. engram_search supports a room parameter to narrow the search scope before performing precise lookup. Retrieval results include adjacent pegs in the same room as cues.
The system includes a built-in spaced repetition mechanism based on the SM-2 algorithm. The engram_review tool only displays the coordinates and cues of memories, not their full text, forcing the model to perform active recall first. Self-assessment using a 0–5 score advances the review schedule. Memories that have not passed review will not be subject to automatic decay.
Knowledge Flywheel and Automatic Ingestion¶
The plugin builds a closed-loop knowledge flywheel:
1. Ingestion: After enabling the ingest configuration, the system automatically extracts facts from conversation logs.
2. Reinforcement: High-similarity neighboring memories establish contradicts edges, adjudicated by the user or an external Jev model.
3. Distillation: Similar memory clusters are merged into higher-level patterns, with confidence inherited.
4. Decay: Low-importance memories that have not been accessed for a long time are archived.
Entity Dictionary and Source Audit¶
The system automatically extracts entities such as people, projects, and tools from ingested content and engram_save output, then resolves them against the existing entity dictionary. Each memory records the source session, turn, and event seq, supporting full operation log auditing.
Security and Compliance¶
The plugin includes multiple layers of protection:
* Prompt Injection Protection: All memory recall outputs are wrapped in <engram_memory_context> protocol tags, explicitly telling the model that the content is historical.
* Ingestion Redaction: Before storing, regular expressions remove common secrets (API keys, GitHub tokens) and personal information (phone numbers, ID card numbers), replacing them with [REDACTED:<type>].
* Evidence Gate: Retrieval results are only marked as “relevant.” They are considered final confirmation only when the model determines them to be “sufficient to answer” and provides valid evidence.
Web Admin Panel¶
The plugin provides a fully functional Web admin panel with multiple views:
* Today: View items pending review and the memory health score.
* Entities: Filter or search entities by category and view their associated memories.
* Adjudication: View conflict decisions and pending records from the Jev system.
* Logs: Audit operation records and retrieval evidence.
Typical Usage¶
Saving Memories¶
Use the engram_save tool to save entries. The system automatically cleans the data and processes the content according to a four-state reporting strategy: repetition merged into reinforcement, suspected contradiction, new write, and low-entropy discard.
// 示例调用
engram_save({
items: [
{ content: "用户偏好使用 Python 而非 Node.js 处理数据分析。" }
],
scope: "project" // 按当前会话 cwd 归属项目库
});
Retrieving Memories¶
Use engram_search to retrieve memories. You can use the room parameter to limit the scope.
// 在特定房间内检索
engram_search({
query: "数据分析偏好",
room: "preference" // 偏好阁
});
Reviewing Memories¶
View the entries that need review today and perform a recall test.
engram_review();
Ecosystem and Limitations¶
- Environment Requirements: Requires Node.js version
^22.19.0or>=24.0.0. - Tech Stack: Pure TypeScript implementation, with no dependencies on external processes or a Python environment.
- Ecosystem Positioning: It belongs to the “AGI Architecture Exploration” category in the DSH plugin ecosystem, at the same narrative level as MemGPT.