dsh-memory
August 15, 2026 · View on GitHub
Self-learning long-term memory for DeepSeek Harness — a historian that compresses your context, a dreamer that curates what matters, and a sidekick that recalls it exactly when you need it.
Long-term memory for DeepSeek Harness, modeled on magic-context (capture → consolidate → recall). A single host-plane plugin; the store is a local SQLite database with FTS5 full-text search and local ONNX embeddings.
What it does
- Capture — every N turns, a cheap model distills the conversation into durable memories (throttled, never blocks the main flow).
- Historian — when the context window fills up, old messages are folded into tiered summaries; the original session log stays append-only and can always be recovered.
- Recall — before each turn, project-relevant memories are retrieved and injected into the surface as a
<system-reminder>block. - Dreamer — scheduled background maintenance: classify, merge, archive, and promote memories that matter.
- Sidekick — on-demand retrieval augmentation (
memory_aug): search memory to enrich the current answer. - 13 memory tools — the model can write, search, list, update, archive, merge, get, delete, dream, consolidate, expand, and augment memories, plus session notes.
Prerequisites
- deepseek-harness installed from source — this plugin targets the DeepSeek Harness plugin API: https://github.com/deepseek-ai/deepseek-harness.
- Node.js ≥ 22 — the store uses Node's built-in
node:sqlite.
Install
-
Clone (or symlink) this repository into the plugin directory of your harness profile:
<dsh-home>/profiles/<profile>/plugins/dsh-memory -
Run
npm installinside the plugin directory. -
Reference it from the profile composition:
- id: dsh-memory name: dsh-memory config: {}
On first load the database is created and migrated automatically — no manual setup.
Built-in compaction
dsh-memory's historian takes over context folding, so the host's built-in compaction should be turned off in the agent preset you use — the same idea as magic-context's setup wizard, which disables the host compressor at the config layer. scripts/setup.mjs toggles the compaction-basic / command-compact entries of any preset in <dsh-home>/.agent-presets/ with point edits only (comments and formatting are preserved):
node scripts/setup.mjs enable --preset <name> # host compaction off → historian owns folding
node scripts/setup.mjs disable --preset <name> # undo only what this script added
node scripts/setup.mjs status # per-preset compaction state
--home defaults to ~/.dsh; --preset all applies to every preset that has the compaction entries. Each enable backs up the preset yml (agent.cordis.yml.dsh-memory.bak) and records what it changed in .dsh-memory-setup.json, so disable never touches entries the user disabled by hand.
Tools
All tools are model tools: the model calls them through the harness.
| Tool | One-liner |
|---|---|
memory_write | Write a memory; idempotent dedup |
memory_search | Hybrid retrieval across memories, compartments, and session notes |
memory_list | Filter by category / scope / status, with pagination |
memory_update | Edit a memory by id; re-embeds and re-classifies |
memory_archive | Soft delete (auditable) — prefer over delete |
memory_merge | Merge duplicates; keep the most important row |
memory_get | Read memories by id |
memory_delete | Hard delete (last resort) |
memory_dream | One manual consolidation run: merge + classify + curate |
memory_consolidate | Merge cosine duplicates; clean up expired rows |
memory_expand | Recover the original text of a compressed partition |
memory_aug | Sidekick augmentation synthesis |
ctx_note | Session-scoped notes (write / read / dismiss / update) |
Configuration
Every field is optional; out-of-range numbers are clamped, invalid values throw at load. The most common knobs:
config:
embed:
mode: local # local | openai-compatible | none
capture:
everyTurns: 5 # distill the conversation every N turns
inject:
topK: 4 # memories recalled per turn
historian:
triggerRatio: 0.70 # compress when ~70% of the window is used
dream:
enabled: false # scheduled background maintenance (default off)
See lib/config.js for the full field list, defaults, and clamping rules.
Acknowledgments
This is an independent reimplementation for deepseek-harness, inspired by and partially ported from magic-context by ualtinok (MIT License). Not affiliated with cortexkit or DeepSeek.
Ported / derived files (per code comments): lib/redaction.js, lib/cron.js, lib/decay.js, lib/dreamer.js, lib/budgets.js; other modules are modeled on magic-context's design. See NOTICE for the upstream license text.