Introduction

When building agents in DeepSeek Harness (DSH), context is often squeezed out by new rounds of conversation: the ports decided last week, your name preferences, or the fix steps from a specific pitfall often require you to manually scroll through history or re-explain them. Many “memory” approaches in the community focus heavily on retrieval—storing conversations as a running log and using semantic search to fish out fragments next time. However, persistent facts and “what was just learned in this round” often still require manual maintenance.

Below is an introduction to dsh-memory-inject, released by maintainer Ykls53 (GitHub: Ykls53/dsh-memory-inject, Community Directory: skillhub plugin page). It stacks three layers of memory within DSH: short resident injections, medium session summaries, and long full-text retrieval. The injection stage does not call a model, while automatic write-back uses the model you have already selected in the UI.

What is this

dsh-memory-inject is a Cordis plugin for DSH (Category: Memory, current package version 0.4.1, MIT License). Its positioning can be summarized by the sentence in the README: Three layers of memory—resident facts (USER.md / MEMORY.md), per-session summaries, and cross-session full-text recall; zero model calls for injection, and the automatic capture layer uses agent-default-model from settings.yaml (i.e., the field corresponding to the model selector in the settings).

Memories are stored in ~/.dsh/memories/ by default. After installation, a Memory page will appear on the left side of the client “Settings” (located after “Bilibili”), used for toggling switches, editing entries, and rebuilding indexes.

How the Three Layers of Memory Divide Labor

Layer 1  Resident Injection   USER.md + MEMORY.md              Automatically present at the start of every session
                   ↓ Optional refinement and write-back at the end of a turn
Layer 2  Session Summary     2~3 sentences per conversation, stored in index.db      Check here first when asking "What did we talk about last Wednesday"
                   ↓ Drill down into hit sessions
Layer 3  Full Raw Text       All session body text + FTS5 trigram index   Use when checking details
Layer 1 Layer 2 Layer 3
What is stored Refined fact entries Per-session summaries Raw conversation text
Does it cost model tokens? No cost for injection; only for write-back Costs tokens when building index/writing summaries No cost
Maintained by Model auto-backfill / Manual editing Index script Index script
Budget USER 1375 / MEMORY 2200 chars (Hard limit) None None

Layer 1 enters the context entirely in every session, so exceeding the budget will result in a write rejection (no truncation, no silent dropping). There is also a total budget maxTotalChars for a single injection, defaulting to 4000; if exceeded, the corresponding file is skipped entirely.

The entry format is a strict convention: one entry per line, with a separate line containing § between entries. No titles or paragraph blocks—this facilitates adding/deleting by entry rather than rewriting the whole file.

Two Model-Adjustable Tools

The plugin registers tools with the agent; you do not need to teach usage in the conversation:

Tool Function
memory_search Search the past: keywords + optional time window (e.g., 7d / 24h / 2w). Returns title, time, hit fragments, and the session summary, aggregated by session.
memory_remember Write resident memory: add / remove / replace / batch; batch allows delete-then-add in one call, and the budget is calculated based only on the final result.

Write rules: replace must hit a unique entry; if multiple entries are hit, it is rejected. Automatic backup to <memoryDir>/.backup/ before every write, keeping only the latest 20 backups.

Full Automatic Backfill (Optional)

Disabled by default. After a conversation turn ends (turn/end), the turn can be passed to a headless subprocess for refinement, writing back to files categorized by USER: / ENV:. The subprocess uses dsh --profile headless, and the model source is consistent with your agent-default-model; the plugin does not touch API keys.

To enable: Turn on “Auto Summarize” in the settings panel, or set autoCapture to true for memory-inject in the profile’s cordis.patch.yml. When the subprocess carries the environment variable DSH_MEMORY_INJECT_SUMMARIZE=1, the plugin exits immediately to prevent the refinement session from being captured again, forming a loop.

The README provides a rough calculation of overhead (Injection + Auto-backfill fully on, approximately 100 turns): The theoretical total is around 610k tokens. Unit prices vary with the model and cache hits, so platform billing should be the standard.

Installation and Activation

The plugin runs with the current DSH process permissions; it is recommended to review the repository source code and MIT license before installation. Requires Node >=22.15.0.

# npm (after release)
dsh plugin --profile desktop add dsh-memory-inject

# Local path (for development)
dsh plugin --profile desktop add /path/to/dsh-memory-inject

After installation, dsh will register the plugin in the profile’s dsh.profile.bundles within package.json and apply the included cordis.patch.yml. Starting a new conversation is sufficient for it to take effect; there is no need to restart the entire client.

Rollback:

dsh plugin --profile desktop remove dsh-memory-inject

Memory files remain in ~/.dsh/memories/; whether to manually delete them is up to you.

Building Index and Session Retrieval (Layer 2 / 3)

The plugin only queries the index and is not responsible for building it. Use the scripts in scripts/ within the plugin directory:

# 1) Unzip all DSH session transcripts into JSONL
node scripts/dsh-memory-dump.mjs

# 2) Build FTS5 trigram index → ~/.dsh/memories/index.db
python scripts/dsh-memory-index.py build

# Optional: Write 2~3 sentence summaries for each session (requires model, slower)
python scripts/dsh-memory-index.py search "keyword"

The index uses trigrams instead of the default unicode61 to facilitate precise hits in Chinese. The summary step can be skipped: Layer 1 and Layer 3 do not depend on summaries. If skipped, the “Session List” in the settings panel will have a weaker sense of directory. The panel provides a “Rebuild Index” button, equivalent to running dump + build, so there is no need to remember commands.

Configuration Highlights

Override using the id memory-inject in the profile’s cordis.patch.yml; switches and character limits written by the panel are saved in <memoryDir>/.settings.json, which has higher priority than the patch.

Config Default Description
memoryDir ~/.dsh/memories Memory directory
files[].maxChars USER 1375 / MEMORY 2200 Hard budget per file
maxTotalChars 4000 Total budget for a single injection
turns [] Empty means check for deduplication every turn; [1] means only the first turn.
includePreamble true Whether to include the “This is memory” instruction line
autoCapture false Full automatic backfill
captureTimeoutMs 180000 Refinement subprocess timeout

There are a few design points worth knowing in advance: Memory is injected via agent/pre-step as a user message marked with plugin:dsh-memory-inject, rather than modifying the system prompt; deduplication relies on source.kind, and if the context is compressed, it will be restored in the next turn; content written to disk mid-session will not enter the injection snapshot until the next new session.

Post-Installation Self-Check

You can verify HTTP endpoints without opening the DSH interface:

node selfcheck.mjs

The README states: Use real plugin code to start a temporary service; read-type endpoints access your real memory directory, while write-type operations only execute in a temporary directory; the expected result is 18 passed / 0 failed. If a yellow bar saying “Backend plugin is an old version” appears at the top of the settings panel, you need to fully exit and restart the DSH client (The server side loads and caches at process startup; changing files will not trigger a hot reload).

Applicable Scenarios and Notes

Suitable for DSH desktop users who need “resident facts + searchable history + drillable raw text” but want to avoid burning extra model tokens during the injection stage. If you only want minimalist notes, maintaining the two md files in Layer 1 is sufficient; if you want to ask “what was discussed on a certain day last week,” you need to build index.db and keep summaries or rely on FTS hits.

The community directory skillhub.cn and GitHub repository are maintained by the community and have no official affiliation with DeepSeek / High-Flyer; the DSH ecosystem itself follows the “everything is a plugin” mindset, so plugin selection should be based on your local profile and permission boundaries.

Conclusion

dsh-memory-inject separates resident memory, session summaries, and full-text retrieval into three layers. Injection does not call a model, while write-back and summary indexing consume your selected model on demand. See above for installation commands; details and pitfalls (Windows multiline prompts, cordis inject dependencies, etc.) are subject to the repository README.

  • Directory Page: https://www.skillhub.cn/plugins/Ykls53/dsh-memory-inject
  • GitHub: https://github.com/Ykls53/dsh-memory-inject