In the development and use of DeepSeek Harness (DSH), agents can often retain context only within a single session, and important information is lost after the session ends. The nattocb/dsh-plugin-memory plugin is designed to solve this problem. It provides DSH with a persistent five-layer memory model, enabling agents to “remember” user information and project details across sessions.

Core Features

This plugin implements its functionality through two layers of the Cordis interface: it injects relevant memories during the agent/pre-step phase and registers 6 dedicated tools via ctx.tools.register.

Five-Layer Memory Model

Memories are structured into five layers (L0-L4), each with independent write paths, truncation budgets, and injection rules:
- L0 User Identity: Located in ~/.dsh/AGENTS.md, managed directly by the user, and not modified by the plugin.
- L1 Profile: Stored in profile.md, containing work background, personal background, current concerns, and recent updates, with support for version rotation.
- L2 Project Context: Includes the global index MEMORY.md and specific <topic>.md topic files.
- L3 Daily Logs: Records daily entries in append mode, with file names formatted as YYYY-MM-DD.md.
- L4 Skills: Inherits from the existing DSH skill system.

Index and Topic Splitting (L2)

To keep files lightweight and easy to manage, MEMORY.md contains only one-line pointers (no more than 150 characters), while the actual content is stored in the corresponding <topic>.md files. The index file has hard limits (200 lines or 40,000 characters), ensuring a controlled context cost during cold start.

6 Agent Tools

The plugin registers the following tools via ctx.tools.register for agents to invoke at runtime:
- memory_write: Writes or overwrites a topic file, optionally adding an index line.
- memory_read: Reads a topic file or the global index.
- memory_search: Performs keyword searches within global, project, or bidirectional scopes.
- memory_daily: Appends one line to the daily log file in the current working directory.
- memory_forget: Deletes a topic file and its index pointer.
- memory_profile: Reads or merges updates into the profile.

Relevance Injection and Automatic Extraction

  • Relevance Injection: For each step execution, the plugin selects relevant topic files based on the latest query and inserts them into the context as a <system-reminder data-role="memory"> block. If no LLM routing is available, keyword scoring is used.
  • LLM Automatic Extraction: When the session enters an idle state (60-second debounce), the plugin scans recent events and uses an LLM to attempt extracting new topic files and index lines.

Installation and Enablement

During installation, an enabled plugin profile must be specified (e.g., web). After installation, the service must be restarted.

dsh plugin --profile web add github:NattoCB/dsh-plugin-memory

After restarting dsh web, the plugin initializes its memory storage root directories at startup:
- Global storage: ~/.dsh/memory/
- Project storage: <cwd>/.dsh/memory/

Configuration Options

The plugin supports configuration through DSH Bundle, primarily controlling the behavior of injection, extraction, and relevance filtering:

Configuration Item Default Value Description
enableEntryInjection true Whether to insert memory guidance instructions at the start of each session.
enableRelevance true Whether to append relevant topic files for each step.
enableExtraction true Whether to trigger LLM automatic extraction when idle.
maxRelevant 5 Maximum number of relevant files displayed per step.
relevanceTopK 8 Number of candidate files used for LLM ranking.
llm.provider "" LLM provider used for extraction/ranking. If left empty, only keyword matching is used.
llm.model "" The corresponding model name.

Usage Examples

After installing and restarting dsh web, you can use the memory features in the following ways:

  1. Inform Memory: Directly tell the agent information worth remembering, or let the agent automatically extract it after completing a task.
  2. Check Memory Roots: When opening a session later, inspect ~/.dsh/memory/ or .dsh/memory/ under the project directory to view MEMORY.md and generated topic files.
  3. Use Tools: The agent can use registered tools (such as memory_search) to proactively retrieve historical memories.

Notes

  • No LLM Dependency: The plugin remains usable even if an llm route is not configured. In this case, only entry injection, keyword-based relevance, and profile rotation are available, while automatic extraction and LLM ranking are disabled.
  • Data as Context: Memory files are written directly via fs/promises and serve as context for agent reading, not as a permission-granting mechanism.
  • Pure Plugin Architecture: This plugin does not provide HTTP APIs or GUI panels; it runs entirely through DSH’s internal interfaces.
  • Path Restriction: All write operations are restricted to the storage root directory and do not involve user UID-level paths.

Ecosystem Context

DeepSeek Harness adopts an “everything is a plugin” architecture. This plugin is maintained by community developer NattoCB and is intended to enrich the DSH ecosystem. For the plugin’s complete directory and source code, please refer to its GitHub repository.