dsh-flymemory
English | 中文
Long-term memory for DeepSeek Harness.
This is a plugin (a DSH bundle) that runs FlyMemory
as a local MCP service and plugs it into the harness. You end up with 15 memory
tools, plus a pair of hooks that quietly record what you've been working on and
pull the relevant bits back when they matter — so you stop re-explaining the same
context every session.
Everything stays on your machine. The service listens on 127.0.0.1:8791, the
library is a single file under your DSH home, and nothing is sent anywhere.
DSH session ──┬── mcp__flymemory__* 15 tools the model can call
└── hooks recall before a turn, store after it
│
▼
FlyMemory service on 127.0.0.1:8791
│
▼
$DSH_HOME/flymemory-data/flymemory_v3.pkl
Why not just a vector store
Most agent "memory" plugins are a note table plus cosine search. This is a full
store, and the differences show up in ordinary work:
| a note table + cosine search | dsh-flymemory | |
|---|---|---|
| A fact changed | old and new both come back | supersede retires the old one; recall hides it unless you ask for history |
| The same thing said twice | piles up | length-tiered dedup merges or strengthens instead |
| "What is X now" | you write the query yourself | state_key/state_value keep a current value plus its chain of previous ones |
| Age | everything looks equally fresh | power-law decay weights results by retention |
| Where an entry came from | lost | source (model-judged vs mechanically captured) and app:<name> |
| Several clients | one store each | ZCode, Qoder and DSH can share one store; app= tags say who wrote what |
| Per-turn cost | full text or nothing | a bounded pointer index (≤1.2 KB), and the model pulls what it needs |
| Did anyone use it | unknown | usegate.jsonl: every injected pointer accounted as expanded / recalled / superseded |
Measured upstream, not re-run here (protocols live in the FlyMemory repo):
- aggregation questions: one-shot top-5 scored 6% strict, the "collect wide,
then read each entry verbatim" protocol 16% (P-ANSWER); - two-hop questions: letting a retriever filter candidates first cut the evidence
from 100% to 75% (P-COMBO); - pointer injection lifted evidence-in-pool 63.9% → 74.4% but at 12.15×
pool tokens (P-USEGATE, verdict PARTIAL) — which is exactly why this plugin
points at entries and never expands one by itself.
What this page does not claim: that a memory store makes a model smarter, or
that this recall wins on every metric. The honest summary of the upstream record
is that structured memory reproduces across runs, while adaptive read policies
have not (yet) survived independent replication.
The notebook, and who does the thinking
The engine is easier to explain as a notebook than as an architecture.
Every sentence you send gets written on its own line, so topics don't blur
together. Say something nearly identical and the old line is underlined harder
instead of copied twice. Correct something ("actually I moved to Hangzhou") and
the old line is crossed out, not torn out — you can still read crossed-out lines
when you ask about history. Short scribbles condense into summary notes; anything
untouched for months fades (power law: the true half-life is 3τ, 90 days by
default). Finding a line works two ways at once: by meaning, and by the exact
keywords embeddings cannot see — part numbers, file paths, ids.
The division of labour is the design bet: the server never runs an LLM. It owns
the mechanical part — chunking, dedup, fusion, decay math, lineage hygiene,
persistence; the calling model owns every judgment — what matters, what is
outdated, what is worth forgetting. A wrong judgment is therefore a recorded
wrong judgment: supersede leaves a tombstone with valid_from/valid_to
instead of a hole.
An entry's life:
- write — a hook captures it, or the model stores it deliberately (
source
keeps the two apart); - strengthen — a near-duplicate updates the existing entry rather than
adding a second copy; dedup is length-tiered and prefers not merging; - supersede —
supersede(old, new)retires an outdated state; it stays
queryable viainclude_supersededwhile normal recall skips it; - consolidate —
consolidate(ids, conclusion)builds a higher-level entry
that keepsevidence_idsback-links, so abstraction never destroys the raw
material; - fade or forget — power-law decay prunes what nothing touches;
forget
removes something that was simply wrong.
The ablated versions of these rules, including the ones that measured worse than
doing nothing, stay in the engine repo:
source ·
research ledger.

Two of the engine's laws. Left: replace-style abstraction scores 10 points below
storing nothing, so consolidation overlays instead. Right: the same 48 turns
through two collection strategies — anchored judgment is near-mechanical,
pre-registered paired experiment, discordant 13:0.
What you get
Fifteen tools, all under the mcp__flymemory__ prefix:
| Tool | What it's for |
|---|---|
flymemory_remember |
Store a decision or finding. Near-duplicates are merged automatically. compartment groups entries by topic; state_key/state_value track "the current value of X" and retire the old one. |
flymemory_recall |
Search. Dense embeddings and keyword matching are fused, older entries fade, and results come back with id, age and where they came from. include_superseded digs into history. |
flymemory_auto |
Recall and store in one call. This is what the hooks use. |
flymemory_recall_index / flymemory_get_memory |
Look first, read later: a one-line index, then the full text of whatever looks interesting. |
flymemory_supersede |
Say "this old entry is out of date, that one replaces it". |
flymemory_state_lookup / flymemory_state_history |
Current value for an entity key, or the whole history of it. |
flymemory_consolidate |
Fold several entries into one conclusion; the originals stay as evidence. |
flymemory_find_conflicts / flymemory_insights |
Pairs that look contradictory; valuable entries that are fading. |
flymemory_forget / flymemory_cleanup |
Delete one entry, or sweep everything that has decayed past a threshold. |
flymemory_session_pack |
A short pack of the recent trail and the latest conclusions. |
flymemory_stats |
Counts, ages, access counts. |
And two hooks that work on their own:
- On every prompt — the prompt is stored, and memories that match it get
appended to the turn. No model call, just local search. - On session start — a recovery pack of recent activity, so a fresh session
isn't starting from nothing.
Both hooks are silent when the service is down, and neither can block a turn.
Requirements
- DeepSeek Harness with
@deepseek-ai/dsh-mcp-clientavailable. Built and
tested against0.2.0-rc.2and44.7.0. - Node 20+ (the add-on and its CLI).
-
Python 3.10+ with the engine's dependencies:
pip install torch sentence-transformers "mcp>=1.30,<2" numpyThe plugin finds the interpreter for you: it checks
FLYMEMORY_PYTHON, the
usual install locations, thenPATH, and it verifies that
sentence_transformersactually imports before picking one. On a machine with
several Pythons that saves you the "why won't it start" half hour.The first run downloads the multilingual embedding model (~470 MB) into the
HuggingFace cache. After that it works offline.
Install
# from npm (published 2026-10-26)
dsh plugin --profile desktop add dsh-flymemory
# from GitHub (use your own profile name)
dsh plugin --profile desktop add github:aujurd22/dsh-flymemory
# from a local checkout (absolute path)
dsh plugin --profile desktop add /absolute/path/to/dsh-flymemory
Or, from inside an agent session, point the plugin_manager tool at the same
spec:
plugin_manager(action: "install_bundle", target: "dsh-flymemory")
plugin_manager(action: "install_bundle", target: "github:aujurd22/dsh-flymemory")
plugin_manager(action: "install_bundle", target: "/absolute/path/to/dsh-flymemory")
Or use the Plugins page in the Web sidebar and pick the folder. The harness
reloads, two rows come up (flymemory, flymemory-mcp), and the tools appear.
Trust signals. License: MIT. Profile: any base-backed profile
(desktop/web); written against DSH 0.2.0-rc.2 and verified on 44.7.0.
Permissions: it writes one data directory under $DSH_HOME, starts a Python
child process, and talks to it over 127.0.0.1 only — no credentials required
and no outbound network calls. External requirement: Python 3.10+ with torch and
sentence-transformers (see above); the engine is vendored, so no separate
FlyMemory checkout is needed.
Check it:
node bin/flymemory.mjs status # what it resolved, and what's live
node bin/flymemory.mjs doctor # interpreter, dependencies, endpoint
Then ask the model to remember something and search for it. If the tools don't
show up, doctor usually says why.
Removing it is the same in reverse:
plugin_manager(action: "remove_bundle", target: "dsh-flymemory")
Your memory file is not deleted — remove it by hand if you want it gone.
How it runs
The bundle inserts two rows:
| Row | Module | Job |
|---|---|---|
flymemory |
this package | Probes the port, starts the engine if nothing is there, records the resolved settings, registers the recall/capture hooks |
flymemory-mcp |
@deepseek-ai/dsh-mcp-client |
Turns the service's tools into mcp__flymemory__<tool> |
The hooks used to ride DSH's Claude-Code hook bridge. Builds from 44.7 onwards no
longer ship that package, so the same logic now runs on the plugin's own
agent/pre-step listener and the bundle declares no hook-bridge dependency.
When the harness starts, the first row checks 127.0.0.1:8791. If a FlyMemory
service is already answering there, it's reused — two harness windows share one
engine and one library. If the port is free, the bundled engine starts in the
background and the row waits for it before letting the next row connect. If
something else owns the port, the plugin says so and leaves it alone; it never
kills a process it didn't start.
Cold starts are slow: the engine imports torch before it can listen, which takes
15–20 seconds. The row waits up to 25 seconds by default, and the mcp-client
reconnects on its own if it has to.
If the engine can't start at all — no interpreter, missing dependency, port
conflict — the harness still boots. You just don't get the tools, and the reason
is in the log.
Settings
Environment variables, read before the harness starts:
| Variable | Default | |
|---|---|---|
FLYMEMORY_MCP_PORT |
8791 |
Service port |
FLYMEMORY_MCP_URL |
http://127.0.0.1:<port>/mcp?app=dsh |
Full endpoint (an ?app= already present is kept) |
FLYMEMORY_APP |
dsh |
Source tag written on every entry this plugin stores |
FLYMEMORY_DATA_DIR |
$DSH_HOME/flymemory-data |
Library, logs, settings record, pid file |
FLYMEMORY_PYTHON |
auto-detected | Interpreter for the engine |
FLYMEMORY_DEVICE / FLYMEMORY_MODEL |
cpu / multilingual MiniLM |
Passed to the engine |
A FlyMemory service can be shared by several clients, and each write carries an
app:<name> tag saying which one produced it. This plugin connects with
?app=dsh, so its entries are marked app=dsh in recall output and counted under
Apps: in flymemory_stats — next to ZCode's app=zcode and older untagged
app=legacy entries. Change the tag with FLYMEMORY_APP if you run several DSH
profiles against one store.
Anything else goes on the row itself, in your profile's cordis.patch.yml. A
patch entry replaces the whole config, so write out everything you need:
- id: flymemory
name: 'dsh-flymemory'
config:
port: 8791
dataDir: 'D:\dsh-memory'
libraryPath: 'D:\dsh-memory\my-lib.pkl'
pythonExe: 'C:\Python313\python.exe'
device: cpu
readinessTimeoutMs: 25000 # 0 = don't wait, let the tools show up later
shutdownOnDispose: true # stop the engine this activation started
nativeHooks: true # recall/capture on every typed prompt
hookTimeoutMs: 6000 # budget per hook request
workingContext: true # publish a bounded memory digest per request
workingContextChars: 1200 # cap for that digest, wrapper included
workingContextMinutes: 240 # how far back the digest looks (pack mode only)
workingContextSource: index # index = retrieve against this step's text; pack = clock window
workingContextTopK: 8 # pointers per digest in index mode
useGate: true # account injected pointers -> expansions/re-calls
# engine-side: FLYMEMORY_SAVE_DEBOUNCE=5 (seconds) batches disk writes; 0 = write-through
writeHooksConfig: true # also write hooks.json for clients outside DSH
seedFromUpstream: false # don't import another library implicitly
upstreamLibrary: '' # set both to import one, once
autostart: true
The rest of the options are documented in resolveOptions() in
lib/index.js. Unknown keys are ignored.
Where your memory lives
$DSH_HOME/flymemory-data/flymemory_v3.pkl — one file, plain data, easy to back
up or delete. Alongside it:
hooks.json— regenerated on every activation; describes the two hooksstate.json— what the last activation resolved (endpoint, library,
interpreter, how the service was obtained);statusanddoctorread it, so
they report an override instead of the defaultsengine.log— stdout/stderr of the engine processserver.log— the engine's own logserver.pid— soflymemory stopknows what to kill
To run the service on its own, without the harness:
node bin/flymemory.mjs start
node bin/flymemory.mjs stop
node bin/flymemory.mjs log -n 40
node bin/flymemory.mjs mute 30m # silence the per-request digest (tools keep working)
node bin/flymemory.mjs mute off
node bin/flymemory.mjs ledger # injection -> use rate and hottest ids (add --json)
node bin/flymemory.mjs version # this copy vs the published one
Nothing auto-updates: DSH never polls the registry, so `dsh plugin --profile