Preface¶
When running Agents in DeepSeek Harness (DSH), each new session starts with “amnesia” by default: preferences confirmed in the previous round, environment facts, and project conventions don’t automatically carry over to the next. Common approaches either stuff the entire memory into the system prompt (requiring writing, maintenance, and solving the injection mechanism), or rely on a background LLM to distill it from conversations (adding a model call per round, with content potentially going into third-party vector databases).
The following introduces the community plugin dsh-memory (maintainer jipika): it persists long-term memory as local plain markdown, performs progressive injection through DSH’s native prompt seam, relies on the current session’s Agent to complete writes, and the plugin itself makes no additional model calls.
What Is This¶
dsh-memory is a progressive long-term memory plugin for DSH: the body is sharded markdown, and what enters the system prompt is mainly a real-time generated shard-level map (shard name · keywords · entry count · latest date); specific entries are retrieved via memory_search for leads, then pulled back line by line with read (use grep only when exact regex is needed). The two-layer structure consists of a global layer (cross-project) + a project layer (switches with workspace), plus a global rules file; it can be viewed and edited in DSH settings, taking effect immediately after writing (functional re-reading, no restart required).
- Category: Memory
- npm package:
@jipika/dsh-memory(the README indicates the current npm version can be viewed via badge; the repositorypackage.jsonshows 0.9.0) - License: MIT
- Directory page: skillhub.cn/plugins/jipika/dsh-memory
- Source code: github.com/jipika/dsh-memory
The DSH ecosystem is “everything is a plugin”; community directories like SkillHub are independent sites and have no official affiliation with DeepSeek / Hithink RoyalFlush.
Core Features¶
Two-Layer Memory and File Layout¶
The global layer defaults to ~/.dsh/memory/topics/*.md, sharded by topic (e.g., user preferences, platform facts, etc.). The project layer lives under ~/.dsh/memory/projects/, with the directory name derived from the session’s cwd (path / replaced with -, wrapped with -- on both ends, consistent with session directory naming). Both directory-sharded and single-file forms are supported and can be migrated between each other without changing plugin configuration.
The human-readable navigation index ~/.dsh/memory.md does not participate in injection; the global rules are in ~/.dsh/AGENTS.md, injected in new sessions, and editable in the settings panel.
Progressive Injection and Constant Prompt Overhead¶
Default map mode: only the shard-level map is in the prompt, with entry titles and bodies not entering the system prompt; no matter how long the memory grows, the injection volume remains controllable (the README provides character count comparisons before and after sharding, as well as under a larger real library). Layers with ≤ 12 entries are still inlined entry by entry to avoid an extra retrieval step for small layers.
Three injection tiers (Settings → Memory → “Injection Method”):
- Map mode (default): shard-level map + on-demand
memory_search/read. - Index mode: map + the latest N entries’ “title · line number” per shard; when exceeding the “index budget” (default 12000 characters, panel options 6K/12K/18K/24K/unlimited), it shrinks stepwise by
[8,5,3,2,1], still preserving shard-level clues. - Full-text injection: entire shard body enters the prompt; when exceeding the limit, it automatically falls back to index mode and explains the reason.
The header line of the injection segment deliberately omits dynamic statistics (shard count/entry count/character count moved to an HTML comment at the end of the segment) to reduce disturbance to the provider’s KV cache prefix; shard-level statistics lines are retained as routing information.
memory_search and Retrieval Discipline¶
Starting from v0.8, memory_search is registered: Chinese bigram, field-weighted, relevance-ranked, synchronously scanning files with no additional index. The discipline block requires prioritizing memory_search; when spanning multiple shards, multiple entries, or large shard bodies, it recommends delegating to a retrieval subagent (use subagent_memory when available); 1–2 entries can be directly read.
Zero Additional LLM Cost and Immediate Effect After Writing¶
The plugin only reads files and assembles prompts; writing memory relies on the Agent already running in the current session. What is registered is a functional text that re-reads files every time the prompt is assembled.
Settings Panel and Per-Turn Memory Bar¶
A “Memory” section appears in DSH settings: global rules, global layer (by shard tabs), project layer switch; in-place editing and saving (auto .bak before saving). Starting from v0.8, each AI reply has a collapsible “This turn’s memory · read N · written M” bar at the bottom, with data projected from the session’s persistent log, and rendering can be disabled in settings.
Write Guards and Permission Boundaries¶
The plugin involves: read/write of ~/.dsh/memory/**, per-round prompt injection and index generation; memory write guards and audit logs on tools/pre-execute / tools/post-execute. When coexisting with trinity-hooks etc. as pre-execute listeners, this plugin only audits the memory path. Rollback: remove @jipika/dsh-memory from dsh.profile.bundles and restart the app.
Installation and Activation¶
Recommended to install from npm (already listed in DSH 1024Store). Installation commands follow the README:
dsh plugin --profile web add @jipika/dsh-memory
The plugin ships with cordis.patch.yml (package.json declares dsh.bundle.patch); on installation, DSH automatically mounts it into the profile composition tree, no manual editing of profile files needed.
If using link: local source development, the README requires running pnpm install after changing the link, and recommends restarting DSH once (the host part loads at boot); daily changes to memory or toggles generally don’t require a restart.
Typical Usage¶
Convention for Write Discipline in AGENTS.md¶
Memory is appended by the Agent in the same turn when facts are learned, with the recommended format - [YYYY-MM-DD] fact. README example (in English, can be placed in ~/.dsh/AGENTS.md):
Memory upkeep (long-term memory):
- TWO layers, both injected on every assembly (no restart needed):
· GLOBAL `~/.dsh/memory/topics/*.md` — facts that would bite in ANY repo,
sharded by topic (each file starts with a comment saying what belongs there).
`~/.dsh/memory.md` is only a navigation index — never append memory to it.
· PROJECT `~/.dsh/memory/projects/--<cwd-with-slashes-as-dashes>--.md` — facts
that only hold in this workspace.
- What the prompt shows is an INDEX (shard · count · path), not the full text:
read that shard when you need the detail. Index lines carry line numbers.
- Append one line `- [YYYY-MM-DD] fact` under the matching section, in the SAME
turn you learn it. Do not batch for "later". Keep each shard small (~12k chars)
— when one outgrows that, split it by sub-topic in the same directory.
- Do NOT log narration or anything re-derivable from the repo.
- NEVER put secrets in it — both layers ride every request to the model provider.
- Record what IS true, never a removal: "X was uninstalled" is stale the moment
it is written and taxes every future session.
The keywords after · or : in the first-line comment <!-- shard name · keywords… --> of each shard enter the map/index, helping the Agent decide whether to read deeper.
Agent-Side Read Path¶
- Look at the shard-level map (or index line numbers) in the system prompt.
- Call
memory_searchto find hit lines by task keywords. - Use
readto fetch entries by line number; usegrepwhen exact regex is needed.
Use Cases and Cautions¶
Who it’s for: DSH users who want long-term memory to stay on the local machine, be git-diffable, and manually editable, while not wanting to burn separate LLM calls for a “memory plugin”; the two-layer model matches well for global preferences + per-repo/project conventions and pitfall records.
Must pay attention:
- The plugin runs with the current DSH process’s permissions, reading/writing
~/.dsh/memory/**and injecting memory-related fragments to the model provider in each request; before installing, read the source code and MIT license to assess the trust boundary yourself. - Do not write secrets; both layers’ content is sent to the model side with requests.
- Only record facts that are still true; avoid writing transient states like “X was uninstalled” into long-term memory.
- Community directories and GitHub stars (3 at time of data scraping) are for discovery reference only and do not represent official endorsement.
Conclusion¶
dsh-memory’s trade-offs are straightforward: memory is just markdown files, injection goes through DSH’s native seam, and scaling relies on maps and on-demand retrieval rather than dumping the entire library into the system prompt. If you’re doing cross-session Agent work in DSH, you can install it with a single npm command, open the “Memory” section in settings, and use AGENTS.md to clearly write the write discipline.
- Directory page: https://www.skillhub.cn/plugins/jipika/dsh-memory
- GitHub: https://github.com/jipika/dsh-memory