Introduction¶
The core of DeepSeek Harness lies in its plug-in architecture. Memory management is an essential requirement in agent development, but existing memory solutions often involve trade-offs: Hermes-style lightweight snapshots (MEMORY.md) save tokens and preserve prefix caching, but are not searchable; Noema-style searchable knowledge bases are comprehensive, but introduce Rust server-side dependencies and additional prompt operations.
dsh-hybrid-memory aims to combine the advantages of both. It provides a hybrid memory solution with no automatic injection and locally stored data, using a layered design to balance the lightness of resident memory with the retrieval efficiency of a knowledge base.
Plugin Overview¶
dsh-hybrid-memory is a DeepSeek Harness memory plugin developed by Frog755, released under the MIT license. It integrates memory capabilities through a three-layer architecture (L1/L2/L3), addressing the performance and functional shortcomings of single memory solutions.
Core Capabilities¶
The core functionality of the plugin is divided into three layers:
- L1 Snapshot Memory: Inherits the Hermes style and supports
memory_add,memory_replace, andmemory_remove. Data is stored asMEMORY.mdandUSER.md; the character limit is independent of the model, and the data is read on demand only when the model actively invokes it. - L2 Searchable Knowledge Base: Implemented using SQLite FTS5 and supports
memory_remember,memory_search, andmemory_browse. It is stored in a “one fact per file” Markdown format, with tokenization optimizations for Chinese. - L3 Multi-Tool Import: Supports importing existing memories from tools such as Hermes, Claude, Codex, and WorkBuddy, using content hashing for deduplication.
In addition, the plugin includes the following auxiliary mechanisms:
* On-Demand Reading (zero context overhead): From v0.2.0 onward, the plugin removed all automatic injection logic (such as persistent systemPrompt injection and pre-step recall). Memory enters the context only when the model actively calls memory_* tools.
* Security and Stability: Built-in threat scanning (detecting prompt injection/leakage), atomic write operations (preventing drift), and a review queue (pending/).
* Chinese Search: Leverages the FTS5 unicode61 feature to support Chinese full-text search.
Installation and Configuration¶
The plugin requires a Node.js 22.5+ environment and must run under the Web Profile of DeepSeek Harness.
The installation command is as follows:
dsh plugin --profile web add @frog755/dsh-hybrid-memory@latest
After the initial installation, restart DSH once; hot reloading is supported thereafter.
Data is stored locally on disk by default, at the path D:\Develop\DeepSeek Harness\memory. If you need to change it, set the environment variable DSH_HYBRID_MEMORY_ROOT.
Typical Usage¶
1. Managing resident entries (L1)
Adding resident entries or modifying existing entries takes effect immediately without requiring retrieval.
# 新增关于用户的条目
memory_add(user, "用户偏好使用 Python 而非 JavaScript,且喜欢详细注释。")
# 替换已有条目
memory_replace(agent, "项目约定", "项目约定:所有 API 响应需包含 CORS 头。")
2. Saving knowledge base facts (L2)
Convert temporary information into retrievable knowledge; by default it is written directly, or it can enter the review queue by using review=true.
# 写入知识库
memory_remember("项目依赖", "本项目依赖 Node.js 22.5+ 版本。")
# 强制进入审核队列
memory_remember("安全规则", "禁止访问敏感网络段", review=true)
3. Searching and browsing
Use full-text search or directory browsing to find information.
# 按关键词搜索
memory_search("数据库配置")
# 浏览知识库目录
memory_browse()
4. Fusion recall
When the model needs memory, call memory_recall. It merges L1 snapshots and L2 retrieval results and returns them packaged according to the token budget.
5. Importing memory
Migrate historical memories from other tools.
# 从 Hermes 导入
memory_import(sources=["hermes"])
Data and Privacy¶
All memory data is stored on local disk, and no data is sent to any external service. The data root directory is located by default at D:\Develop\DeepSeek Harness\memory and contains the following structure:
MEMORY.md/USER.md: L1 snapshots.facts/: Activated knowledge base facts.pending/: Memories pending review.index.db: FTS5 index database.imports.json: Import deduplication ledger.
Notes¶
- No automatic injection: This is an important behavioral change in the plugin. If the model does not actively call
memory_*tools, memory will not automatically appear in the context. Although this increases the model’s usage cost, it yields zero context overhead for memory. - Review mechanism: The default is
auto-accept(direct write). If manual review of memories is required, setreview=truewhen callingmemory_remember. - Compatibility: Supports only the Web Profile of DeepSeek Harness (Cordis architecture).
- Local permissions: The plugin runs under the permissions of the current process. Please review the source code and license before installation.