Preface¶
DeepSeek Harness (DSH) adopts a plugin-based architecture. For complex agent development or task orchestration, maintaining a stable set of system instructions is a core requirement. dsh-instruction-memory specifically addresses this pain point: it allows users to manage long-term instructions in the DSH settings interface. These instructions are automatically injected into the system prompt of every subsequent conversation turn, without requiring users to manually re-enter them.
Core Features¶
This plugin provides the following core capabilities:
- User-driven maintenance: Instruction content is only entered and modified by the user. The model has no write permission, ensuring the accuracy of the instructions.
- Automatic injection: Maintained instructions are automatically appended to the system prompt of each conversation turn.
- Multi-instance concurrency protection: Supports concurrent use across multiple instances and multiple windows, using write locks and revision numbers to prevent data conflicts.
- External file synchronization: Via SSE, external modifications to the file automatically trigger a refresh of the settings page.
- Data management: Supports exporting and importing memory, as well as directly editing the JSON file.
Installation and Activation¶
Installing the plugin requires using DSH’s plugin management command. Ensure the host version is within the compatibility range declared in peerDependencies; otherwise, installation will be rejected.
dsh plugin --profile web add dsh-instruction-memory
After installation, restart DSH. An “Instruction Memory” entry will appear on the settings page. To uninstall:
dsh plugin --profile web remove dsh-instruction-memory
Usage¶
- Add an instruction: In the “Instruction Memory” module on the settings page, click Add Entry, and enter the title, content, and applicable scenarios.
- Configure priority: Use priority to control the injection order.
- Use applicable scenarios: Filling in “Applicable Scenarios” helps the model determine whether an instruction applies to the current conversation.
- Data migration: The disk file is not created immediately on first run (lazy creation); it is automatically generated on the first save or import.
Data Storage and Synchronization¶
The memory file is stored under the DSH data root directory by default:
<DSH_HOME>/instruction-memory/memory.json
DSH_HOME defaults to ~/.dsh. Path priority follows the official @deepseek-ai/dsh-home-paths specification.
- External file changes: While the settings page is open, if an external process modifies
memory.json, the settings page will automatically refresh via SSE, without requiring manual reload. - Backup and recovery: Save operations use an atomic replacement strategy. If
memory.jsonfails to parse, the system automatically attempts to restore it frommemory.json.bak. - Export and import: Supports exporting memory to a JSON file, and importing from a file and merging it with existing memory (deduplication: by id and “title+content”).
Technical Requirements and Considerations¶
- Environment requirements: The host environment must satisfy Node.js >= 20.
- Injection limit: The maximum injected characters is 40,000. If exceeded, content is truncated by priority.
- Version compatibility: The host version must be within the range declared in
peerDependencies; otherwise, installation will be rejected. - Security notice: If the host is bound to a non-loopback address (such as
0.0.0.0), the plugin automatically disables Host header validation to avoid blocking normal access. In this case, the route no longer provides security protection, creating a risk that malicious requests may modify instructions. Users must bear full responsibility for security.