Introduction¶
The philosophy of DSH is “everything is a plugin.” Memory, tools, and channels outside the model are assembled via plugins. When building long-term companion robots (developmental partners, like “Big Fat Fish”), the common approach is to stuff chat logs into a database or wrap a vector database for retrieval. The former lacks forgetting; the more the robot remembers, the stiffer it becomes. The latter lacks the concept of “not remembering clearly,” making it prone to confidently hallucinating.
Below, I introduce dsh-hippocampus, a memory layer designed for this type of robot, maintained by kianajunjie. It organizes memory according to the stages of the human hippocampus. It can forget, become invalid if the user changes their story, and admits when it doesn’t know.
What is this¶
- Plugin Name: dsh-hippocampus
- Repository: kianajunjie/dsh-hippocampus
- Maintainer: kianajunjie
- Version: 0.3.1
- License: MIT
- Runtime Requirements: Node.js >= 22.5
- Category: Memory
One-sentence positioning: Provides a memory layer for long-running companion robots, neither database storage nor a vector database wrapper. The documentation describes it as “copied from the hippocampus,” broken down into five stages: event encoding, consolidation, forgetting, association, and meta-memory.
Core Features¶
Event Memory: Converts dialogue into “who, when, what happened, what emotion.” At the core, it categorizes tables into events, relationships, facts, chapters, and skills/gaps.
Emotion-Weighted Forgetting: Forgetting is not uniform. The documentation states, “Memories from days you were scolded can last seven months, while an ordinary day vanishes in a month and a half.” 90-day testing shows a recall rate of 27% for old memories with emotion weights, dropping to 9% without them.
Certainty: Each memory carries a confidence score, categorized as “remembered clearly / vaguely remember / only know it happened.” It won’t state vague memories with absolute certainty.
Contradiction Handling: If a user first says they like coffee and then says they quit, the old record automatically becomes invalid to avoid contradictions.
Relationship Layer: Intimacy, trust, and unresolved issues with each person. Relationships fade if not seen for a long time and only resolve when forgiven.
Person-Isolated: A cannot see B’s memories; group chats cannot see private chat history.
Platform Agnostic: Compatible with QQ, IM, web, and Telegram. The same person entering through multiple channels shares one memory. The underlying mechanism unifies identities into a single subject via the identities table.
Zero Dependencies: Uses Node’s built-in SQLite; a single local file holds all memory, no uploads, no extra services needed.
The entry point is handleTurn(): Parse identity → Assemble context → Recall, outputting r.context (fed into system prompt) and r.recall (recall result). Run replay() once a day to consolidate and forget.
Installation and Usage¶
Install directly via npm, suitable for direct library calls or CLI:
npm i dsh-hippocampus
Enable as a DSH plugin (for IM / Web integration):
dsh plugin --profile web add github:kianajunjie/dsh-hippocampus
The package.json also declares a dsh.bundle.patch field pointing to ./cordis.patch.yml; pay attention to this patch file when using the dsh plugin process.
Typical Usage¶
Direct Library Call
import { createHippocampus } from 'dsh-hippocampus'
const hip = await createHippocampus({ apiKey: process.env.DEEPSEEK_API_KEY })
// For every message
const r = await hip.handleTurn({ channel: 'qq', externalId: msg.user_id, text, reply })
// r.context → fed into system prompt, r.recall → recall result
// Once a day
await hip.replay()
Install the package with npm i first, then write this code. Pass apiKey during construction, indicating that semantic processing for encoding and recall relies on the model; retrieval and organization are handled locally.
HTTP Interface (callable from any language)
import { createMemoryServer } from 'dsh-hippocampus/http'
await createMemoryServer({ hip, port: 7717, token: 'secret' })
curl -s localhost:7717/context -H 'authorization: Bearer secret' \
-H 'content-type: application/json' \
-d '{"channel":"telegram","externalId":"42","text":"我腿疼"}'
Start the service first, then send a POST /context. Authentication uses Bearer, ports and tokens are configurable.
Command Line
node cli.mjs demo # No model needed, see the effect first
node cli.mjs encode --turns turns.json
node cli.mjs replay
node cli.mjs context --subject 主人 "我腿疼"
node cli.mjs list 20 | audit | stats
demo does not touch the model, used to see the effect first; encode requires a turns.json input, replay is used to run consolidation and forgetting. npm test has 26 tests.
See docs/integration.md for more integration methods, docs/prompt.md for prompt tuning, and docs/bench.md for benchmark data.
Suitable Scenarios and Notes¶
Suitable for: Long-term companion robots, developmental partners. When the same person needs to share memory across multiple entry points (QQ, IM, Web, Telegram), and you want the robot to forget, have certainty, and update based on user contradictions.
Not Suitable for: Customer service FAQ, general assistants, multi-tenant SaaS, knowledge base Q&A. The documentation explicitly states that RAG is more suitable for these scenarios.
Two Notes:
- The plugin runs with the permissions of the current dsh process. Before installing, you should check the source code and license (this plugin is MIT); don’t install just based on the directory page description.
- It manages memory, not the model itself. You need to provide
DEEPSEEK_API_KEYduring construction; encoding and recall will not run without the token.
Conclusion¶
The value of dsh-hippocampus lies in its ability to “forget” and “admit not knowing”: It does not strive to store every sentence, but maintains a memory that changes over time based on emotion, contradictions, and certainty, while remaining localized and platform-agnostic. For those building companion robots, it is closer to the shape of long-term dialogue than a “chat log table + vector retrieval.”
Directory page: https://www.skillhub.cn/plugins/kianajunjie/dsh-hippocampus
GitHub: https://github.com/kianajunjie/dsh-hippocampus