DeepSeek Harness (DSH) adopts a plugin-based architecture. In multi-turn conversations or long-running sessions, agents face context loss and fragmented memory. dsh-memory is a persistent atomic-fact memory plugin designed for DSH, enabling agents to remember user preferences and project knowledge across sessions and providing controllable retrieval paths.
Plugin Positioning¶
The plugin is built on Cordis and implements the P0-P2 design specifications for the memory system. It does not rely on external vector databases or graph databases; data persistence and storage are implemented through local JSON documents.
Core Features¶
Atomic Fact Model¶
All memories are ultimately resolved into minimal, self-contained assertions of the form subject - predicate - object - qualifiers. Semantic memory, episodic memory, and procedural memory are unified under this contract and deduplicated using a stable semantic_key.
memory Service and Explicit Tools¶
The plugin provides a memory service (ctx.memory) and a set of explicit tools for the model to invoke:
* recall: Retrieves memories.
* remember: Stores memories. Supports an optional procedure parameter for storing procedural memory (structured steps).
* forget / forget_all: Deletes specific or all memories.
* link: Creates associations between memories.
* consolidate: Background consolidation, handling TTL expiration and deduplication of identical keys.
* extractAndRemember: Extracts and stores memories in the background.
* read_user_profile: Returns aggregated entity cards, including core summaries and topic-based groups.
user.md Round-Trip¶
Supports rendering and synchronization of the user.md view. The plugin can generate a user.md file from entity cards, listen for external edits, and write them into atomic facts as user_edit events (credibility 1.0, highest priority).
Fast-Path Capture¶
Uses a session/event listener to capture signals with zero-LLM rules. Content is placed in a background queue only when triggered by configured trigger phrases (e.g., “remember…”, “my preference is…”) or messages containing factual signals (numbers, dates, proper nouns).
Privacy Guard¶
Built-in PII detection and tiering mechanism:
* Content marked as PII is masked during storage (e.g., <<phone>>) and does not enter raw memory.
* confidential content is masked and marked as [confidential] during recall.
* secret content is returned only when specific conditions are met (secretRequiresExplicitAuth: false and included in the retrieval filter list).
Dynamic Context Injection¶
Recalled facts are injected via DSH’s system-prompt/assemble context channel, presented as data rather than instructions, ensuring session logs can be reconstructed.
Background Consolidation¶
A timer triggers cleanup of TTL-expired entries and merging/deduplication of identical keys.
Typical Usage¶
The model interacts with the system by invoking the tools above.
-
Retrieve memories
The model invokesmemory_recallto retrieve relevant context. -
Store preferences
The model invokesmemory_rememberto save user preferences. If operational steps (procedural memory) need to be stored, pass theprocedureparameter.
{
"subject": "用户",
"predicate": "偏好编程语言",
"object": "Rust",
"qualifiers": ["最近的项目"]
}
- Retrieve entity cards
The model invokesread_user_profileto get an aggregated overview of user information.
Configuration Notes¶
All settings are defined in src/config.ts (using Schemastery’s z.object).
Default Configuration (Profile: personal)¶
| Setting | Default | Description |
|---|---|---|
dataFile |
'' |
Uses in-memory storage by default. Set a specific path to persist data. |
userMdFile |
'' |
Disabled by default. Set a specific path to enable rendering and synchronization of user.md. |
profile |
personal |
Profile name. |
injectContext |
true |
Whether to inject context dynamically. |
captureEnabled |
true |
Whether to enable capture. |
llmExtractionEnabled |
false |
LLM extraction is disabled by default; rule-driven behavior is used. |
Extraction Configuration¶
extraction.triggers configures the trigger list for fast-path capture.
Important Notes¶
- Storage form: Data is stored in files as plaintext JSON/Markdown, with no encryption integration and no OS keychain integration. Ensure secure filesystem permissions for the storage directory.
- Retrieval capability: No external vector database, SQLite, or graph database. Semantic retrieval currently uses a BM25-based approximation.
- LLM extraction: LLM extraction is disabled by default. To enable richer extraction capabilities, enable
llmExtractionEnabledin the configuration and configure Provider/Model. - Dependencies: The Node.js version requirement (
^22.19.0 || >=24.0.0) and corresponding DSH ecosystem dependencies must be met.
Summary¶
dsh-memory provides a lightweight, auditable memory layer for DSH agents. It ensures memory stability through the atomic fact model and enables human intervention through the user.md round-trip mechanism. For projects requiring long-term memory, configure a dataFile path to enable persistence.