Preface¶
In DeepSeek Harness (DSH), a common approach for long-running agents is to start from scratch in each conversation, or to stuff the entire history into the context. The former loses facts and preferences, while the latter is costly and hard to distinguish between “current task” and “what to retain long-term.” Community plugin dsh-somni (maintained by liuqingman) takes another path: writing while awake and associating on demand, with a sidecar performing sleep-like distillation when idle, precipitating conversations into grep-able Markdown memories. In classification, it belongs to the “memory” category of DSH ecosystem plugins; the directory page is at SkillHub, source code and documentation are on GitHub (MIT, current package version 0.1.0). DSH itself is an agent host where “everything is a plugin”; SkillHub is a community directory, with no official affiliation to DeepSeek / High-Flyer.
What is this¶
dsh-somni provides sleep-organized long-term memory for DSH agents: while awake, identity and unfinished intentions reside in the system prompt, relevant memories are auto-associated and injected before actions/after tools, and the model can also actively retrieve via tools; after being idle for a period, the “dreamer” organizes the day’s session log into four types of memories: episodic, semantic, prospective, and procedural. Persistence is entirely Markdown + YAML front-matter on disk, not dependent on a proprietary database (the vector index SQLite is a deletable, rebuildable derivative).
Architecturally, it is divided into two halves: a TypeScript Cordis plugin (capture, inject, associate, 9 memory tools, dream scheduling) and a Python sidecar somni_memory (memory management, optional vector index, ReAct organization loop), communicating via a single stdio ndjson JSON-RPC (rpc.py); during dreaming, Python makes reverse RPC calls to the host’s llm.chat, by default reusing the harness model, requiring no additional API key.
Core Features¶
Memory types and how the model accesses them¶
| Type | Directory | How the model uses it |
|---|---|---|
| Identity | memory/ (e.g., about_me.md, about_user_*.md) |
Resident section in system prompt |
| Prospective (intentions) | memory/intentions/ |
Resident section + intention-related tools |
| Episodic | memory/episodes/ |
search_episodes, recall_memories, association hints |
| Semantic | memory/knowledge/ |
search_knowledge, recall_memories, association hints |
| Procedural (skills) | skills/agent_learned_skills/*/SKILL.md |
Can work with dsh-skill-filesystem; association hints |
| Working memory | memory/session-log/ |
search_recent_conversation |
While awake: capture, inject, associate¶
- Capture: Subscribe to DSH
session/event, write tomemory/session-log/atsession/flush/turn/end; skip child agent sessions. - Inject: Inject three sections (identity, intentions, discipline) into the system prompt (can be toggled in
cordis.yml). - Associate: Hybrid scoring on knowledge / skills / episodes at
agent/pre-step(latest user message) andtools/post-execute(tool name and parameters); inject hints only when the highest score ≥0.52and leads the second place by ≥0.04, and the same memory is not repeated within the same session. When the vector layer is not enabled, the association hook remains silent, but keyword retrieval is still available.
Memory tools (mounted on ctx.tools)¶
The plugin registers 9 tools, all returning Markdown: recall_memories, search_episodes, search_recent_conversation, search_knowledge, add_intention, complete_intention, cancel_intention, list_intentions, dream_now. During a session, dream_now can be called to force-trigger an organization; any new turn will preempt an ongoing dream, so users don’t need to wait for the organization to finish.
While sleeping: dream organization¶
When the idle timer meets the configuration (defaults like dream.idleMs 15 minutes, dream.maxIntervalMs 6 hours, etc.) and there are pending session logs, the sidecar executes the sleep.run ReAct loop, producing episodes, knowledge, intentions, skills entries and memory/dreams/ run logs, and performs decay and archiving (low-score entries are moved to archived/, not physically deleted).
Optional capabilities¶
- Vector layer: Install
somni-memory[embed]and place ONNX models likebge-small-zh-v1.5to enable semantic recall and association hints; otherwise keyword-only mode. - Tool surface master switch: Configure
tools.gate.stateFileetc., to hot-toggle whether somni tool schemas are exposed to the model via an external JSON state file.
Environment and Dependencies¶
The DSH side requires Node >= 22 (see package.json engines), DeepSeek Harness >= 0.2.0-rc.1, and the peer packages listed in the README (dsh-agent, dsh-session, dsh-llm, etc.). The sidecar requires Python >= 3.9 and on PATH (can be specified via config key python); the core sidecar depends only on the Python standard library. When Python is missing, the plugin gracefully degrades: capture and dream stop, and the host does not crash.
Installation and Activation¶
The installation method given in the official README is as follows (DSH must already be installed; the README’s Chinese installation section mentions node >= 18, which coexists with the package’s declared Node >= 22 — it is recommended to follow the host and engines and use Node 22+):
git clone https://github.com/liuqingman/dsh-somni.git
cd dsh-somni
./install.sh # Install into default profile
./install.sh --profile mybot # Or any profile under $DSH_HOME/profiles
install.sh will pip install the sidecar, link the plugin into the profile’s node_modules, merge the sample config into the profile’s cordis.patch.yml, and validate the sidecar with a stdio ping; the script is idempotent and can be run repeatedly.
If semantic recall and association hints are needed, you can install the optional vector dependencies and place the model according to the documentation:
python3 -m pip install "somni-memory[embed]"
# Place the ONNX files of BAAI/bge-small-zh-v1.5 into ~/.dsh/somni/models/ and configure embed.provider: local
In the profile’s cordis.patch.yml, the plugin entries need to be mounted under the top-level - insert: (install.sh will write it correctly automatically). Common snippets include enabling somni and pointing to the distillation skills directory, for example:
- insert:
- name: dsh-somni
- name: '@deepseek-ai/dsh-skill-filesystem'
config:
customSkillDirs: [~/.dsh/somni/skills/agent_learned_skills]
The default data directory is <DSH_HOME>/somni (config key dataDir). For the full optional configuration, see the repository’s examples/cordis.patch.yml.
Typical Usage¶
- Daily conversation: No extra operations needed; the plugin automatically writes session logs, refreshes identity/intention sections, and injects association hints at appropriate times.
- Active recall: Let the agent call
recall_memoriesorsearch_knowledge/search_episodesto retrieve disk memories. - To-dos and intentions: Manage prospective memories via
add_intention,complete_intention,cancel_intention,list_intentions; unfinished intentions maintain high activation on the model side (no decay). - Immediate organization: Call
dream_now, or wait for the scheduler to auto-dream after idle. - Manual maintenance: Directly edit Markdown under
dataDir/memory/andskills/; audit agent memories with grep and version control tools.
Disk layout overview (see README):
dataDir/
├── memory/
│ ├── about_me.md
│ ├── intentions/
│ ├── episodes/
│ ├── knowledge/
│ ├── session-log/
│ └── dreams/
├── skills/agent_learned_skills/
├── models/ # Optional embedding
└── index.sqlite # Derived index, can be deleted and rebuilt
Use Cases and Notes¶
Suitable for: DSH agents that need to retain identity, facts, decisions, and skill accumulation across sessions; those who want memories to be readable, editable, and backup-able; scenarios willing to accept “async organization when idle” rather than real-time full-write to a database.
Notes:
- The plugin and Python sidecar run with the current DSH process permissions, can read/write
dataDirand call the host LLM; please read the source code and MIT license before installation, and confirm that the data directory and model calling strategy comply with your environment. - JSON-RPC goes through stdio; the sidecar must not print debug information to stdout, otherwise it will break the protocol (see
docs/HANDOFF.mdfor design). - When embedding is not configured, association hints are disabled, but keyword retrieval and dream organization are still available (depending on whether the Python sidecar is functioning properly).
- The memory core, which shares the same origin with the Feishu agent “somni”, is a decoupled fork; the disk format and organization strategy are consistent, but this repository is aimed at the DSH Cordis plugin form.
Conclusion¶
dsh-somni implements “awake recall + sleep organization” in the combination of a DSH plugin and a Python sidecar, using Markdown long-term memory to supplement the agent’s continuity and operability. For further design details, see the repository’s docs/design.md and README.zh.md.
- Directory page: https://www.skillhub.cn/plugins/liuqingman/dsh-somni
- GitHub: https://github.com/liuqingman/dsh-somni