Ported Tencent Cloud's open-source 4-layer memory system (TDAI Agent Memory) into DSH: automatically captures conversations and uses LLM to extract facts, preferences, and profiles; during next conversation, automatically recalls and injects relevant memories based on current message; legacy memory directory remains functional.
- Language
- JavaScript
- License
- MIT
- Branch
- main
Install
$ dsh plugin --profile web add dsh-tdai-memoryRun the command above in your terminal to install this plugin via the dsh CLI. You can switch Profile in the top-right corner. New to dsh? Read the beginner tutorial
Install via your agent
Install the DeepSeek Harness plugin Scorp1o117/dsh-tdai-memory for me: review the repository at https://github.com/Scorp1o117/dsh-tdai-memory first, then run the install command and verify the plugin loads successfully.
Paste this instruction to the DSH Web GUI assistant — it will install and verify for you.
One-Sentence Positioning
Port Tencent Cloud's four-layer memory system (TencentDB Agent Memory, formerly OpenClaw plugin) into DeepSeek Harness: automatically save every conversation round, use LLM to extract facts/preferences/profiles, and automatically inject relevant memories into the prompt based on the current message when asking questions again—so the model can "recall" past events out of thin air.
Core Capabilities
- Automatically save every conversation round to local SQLite + JSONL + FTS + vector index (L0 raw capture)
- Background LLM extracts facts, preferences, and events from conversations, writing to structured memory (L1) + auto-generating user profiles and scene blocks (L2/L3)
- Before each message is sent, automatically retrieve relevant memories based on current user input and inject as dynamic context into the prompt (no manual search needed)
- Model can actively call
tdai_memory_search(structured memory search) andtdai_conversation_search(raw conversation search) two tools - Web UI settings page has a dedicated "Memory" section for visual editing of all configurations (data directory, extraction model, Embedding, toggles), leaving key empty preserves original value
- Data directory reuses
~/.memory-tencentdb/memory-tdai, Tencent Cloud version legacy memories can be directly migrated for use
Technical Implementation
- Language: JavaScript (ESM, Node native, TypeScript only used for vendored core)
- Key Dependencies:
@deepseek-ai/schemastery(config schema),@deepseek-ai/dsh-tools(tool registration),@tencentdb-agent-memory/tcvdb-text(vector DB binding),sqlite-vec(local vector search),@node-rs/jieba(Chinese word segmentation) - Architecture Pattern: Cordis plugin (profile bundle).
index.jslistens tosession/event+session/flushfor capture, listens tosystem-prompt/assemblefor recall injection;client.jsrenders Web UI settings section;recall-inject.jsserves as preset line-level fallback recall injector. Underlying coreTdaiCorecomes from vendored Tencent Cloud version, zero changes viaStandaloneHostAdapterdirectly connects to OpenAI-compatible LLM/Embedding - Entry Files:
index.js(host-side Cordis plugin) +client.js(browser-side ModuleLoader plugin) +recall-inject.js(fallback line in agent preset)
Use Cases
For users who use the same conversation/Agent in DSH for a long time and want the model to remember facts you've mentioned (project background, personal preferences, historical decisions); or those who want to "ask one question and recall what was discussed last time" instead of restating the background every time. This plugin is not needed for one-off Q&A scenarios—you need a long-running session/Agent to notice its value.
Prerequisites and Compatibility
| Dependency | Minimum Version | Description |
|---|---|---|
| DSH | 0.1.0-rc.7+ | peerDependencies declared, tested on rc.7 / rc.8 / 0.1.1-rc.1 (README.md:112-115); use rc.6 requires pinning plugin version to 0.2.11 |
| Node | >=22.18 | engines.node |
| Platform | Cross-platform | Pure JS + optional native build, no OS restrictions |
| Native Module | node-llama-cpp (optional) | Only needed when choosing fully local embedding backend; default package install does not trigger native build (package.json:70-74) |
| Web UI | React 18.2+ | peerDependencies declared, provided by DSH host |
Installation
dsh plugin --profile web add github:Scorp1o117/dsh-tdai-memory
Configuration Options
| Config | Type | Description | Default |
|---|---|---|---|
| Data Directory | String | Memory database storage path. Empty uses ~/.memory-tencentdb/memory-tdai, compatible with Tencent Cloud version | Empty (default above path) |
| Extraction LLM Base URL | String | OpenAI-compatible interface address for L1/L2/L3 extraction | Empty (falls back to TDAI_LLM_BASE_URL env var) |
| Extraction LLM API Key | String (password) | Key for above interface, empty keeps original value | Empty |
| Extraction LLM Model | String | Model name; deepseek-v4-flash output is often non-compliant, mimo-v2.5 recommended | deepseek-v4-flash |
| Extraction LLM Max Output Tokens | Number | Single extraction response limit | 4096 |
| Extraction LLM Timeout (ms) | Number | Single LLM call timeout | 120000 |
| Embedding Base URL | String | Vector interface address (OpenAI-compatible /v1/embeddings) | http://127.0.0.1:8088/v1 |
| Embedding API Key | String (password) | Vector interface key | Empty |
| Embedding Model | String | Vector model name | Qwen3-Embedding-0.6B |
| Vector Dimension | Number | Embedding output dimension | 1024 |
| Request with dimensions param | Boolean | Whether to include dimensions field in request (some services require) | false |
| Capture Conversations (L0) | Boolean | Whether to write each conversation round to raw storage | true |
| Structured Extraction (L1) | Boolean | Whether to enable LLM auto-extraction of facts/preferences/events | true |
| Conflict Detection | Boolean | Use LLM to check duplicates before writing; extra LLM calls and unstable parsing, off by default | false |
| Recall Injection | Boolean | Whether to automatically inject relevant memories during prompt assembly | true |
| Max Recall Items | Number | Maximum memory items returned per recall | 5 |
| Similarity Threshold | Number | Minimum similarity score for recall; results below this are discarded | 0.3 |
| Recall Timeout (ms) | Number | Single recall timeout | 3000 |
| Register Search Tools | Boolean | Whether to register tdai_memory_search and tdai_conversation_search for model to call | true |
FAQ
Q: Do I need to manually modify cordis.patch.yml after the installation command finishes?
A: No. The - insert declaration in cordis.patch.yml has already registered tdai-memory as a profile bundle; dsh plugin automatically merges and mounts it during package installation.
Q: Why don't changes to the settings page take effect?
A: TdaiCore is built once at plugin startup; runtime changes to settings don't rebuild it. You must restart dsh web after modifying for changes to actually take effect (there's also a warn in index.js:380).
Q: Can I use deepseek-v4-flash as the extraction model?
A: Not recommended. Its JSON output is often non-compliant, which can cause L1 extraction to yield zero items; README defaults to mimo-v2.5, which takes 20-30s per run but executes in the background without blocking conversations.
Q: Do I have to install node-llama-cpp?
A: No, it's not required. It's only an optional peer for the "fully local embedding" backend; using OpenAI-compatible remote embedding (default) doesn't need it.
Q: Will memories accumulated with the Tencent Cloud version on old machines be lost?
A: No. The data directory is fixed at ~/.memory-tencentdb/memory-tdai; content written by the Tencent Cloud version is preserved as-is, and the new plugin reuses it directly.
Q: Can the model actively search old memories?
A: Yes. After registration, tdai_memory_search (L1 structured search) and tdai_conversation_search (L0 raw search) will appear in the tools list for the model to actively call.
Q: Will data remain after uninstalling the plugin?
A: Yes. dsh plugin remove only uninstalls the package and unmounts it; ~/.memory-tencentdb/memory-tdai won't be cleared; to completely delete, manually rm that directory.
Difficulty Level
Advanced — requires you to select and integrate an OpenAI-compatible extraction LLM and embedding service yourself (the default http://127.0.0.1:8088 Qwen3-Embedding may not exist), and understand the four-layer memory architecture's L0/L1/L2/L3 to tune parameters properly; it runs out of the box, but to extract value you need to choose the right model and embedding backend.
Known Issues and Limitations
- Extraction model
deepseek-v4-flashoutputs non-compliant JSON, which can cause L1 to extract zero items;mimo-v2.5is recommended by default (20-30s/run, executes in background) (README.md:125-127) - Conflict detection (dedup) LLM output parsing is unstable, has caused
stored=0, off by default; enabling requires a more reliable model (README.md:128-129 / index.js:63) - Single
mimo-v2.5extraction takes 20-30s; with multiple rounds in long sessions, overall L1 extraction time is considerable (README.md:125) - L0 vector writes go through background tasks; in headless one-shot tasks,
destroy()drains them on exit, and excessive task volume may lose tail items (README.md:130-131) - The
seed-runtime.jsin vendored core has a FIXME: teardown waits for L1 to finish then destroys, but L2/L3 pipelines may be interrupted before completion (vendor/tdai/core/seed/seed-runtime.js:8-14) - The
tcvdb.jsin vendored core has a TODO: vector collection creation is not delayed to first use, which may block plugin initialization during startup (vendor/tdai/core/store/tcvdb.js:178) - Web settings page configuration changes require restarting
dsh webto take effect; runtime settings changes only write to disk without rebuilding the core (README.md:111 / index.js:379-382) - After upgrading if pulling new upstream code, need to re-run
npx tsc -p dsh-tsconfig.jsonin the tdai project directory (README.md:132-133)
dsh-tdai-memory
GitHub: Scorp1o117/dsh-tdai-memory · npm: dsh-tdai-memory
Part of the DeepSeek Harness Enhancement Suite — Vision · Soul/Persona · Long-term Memory · Plugin Marketplace.
A port of TencentDB Agent Memory (Tencent Cloud's open-source four-layer memory system, originally an OpenClaw plugin) into DeepSeek Harness.
Features
- L0 conversation capture: every turn (turn end, request boundary) is written to raw conversation storage (JSONL + SQLite + FTS + vectors)
- L1 structured memory: a background pipeline uses an LLM to extract
facts / preferences / events (persona / episodic / instruction) from
conversations, stored in
records/+ SQLite + FTS + vectors - L2 scenes / L3 persona: scene blocks and user profile generation (pipeline-scheduled)
- Automatic recall injection: on every prompt assembly, relevant memories and the user profile are retrieved by the current user message and injected as dynamic context (the model "just remembers")
- Tools:
tdai_memory_search(L1 structured search),tdai_conversation_search(L0 raw-text search)
The data directory reuses the existing ~/.memory-tencentdb/memory-tdai, so
previously accumulated memories carry over seamlessly.
Architecture (porting approach)
| Layer | Content |
|---|---|
| Core | The host-neutral core of tdai-memory-openclaw-plugin (src/core, src/utils), tsc-compiled to ESM (dist-dsh/), zero changes |
| Host adapter | StandaloneHostAdapter (official standalone mode, direct OpenAI-compatible calls) |
| dsh shell | index.js: config mapping, session/event + session/flush capture, system-prompt/assemble recall injection on agent.ctx, tool registration, lifecycle |
| Fallback | recall-inject.js: preset-row recall injection (used when mounted inside an agent preset) |
Hard-won wiring details:
- Capture:
session/flushlistener (await semantics; must complete before headless exits);turn/starttimestamps as the L0 cursor floor; turn-id dedup - Headless one-shot runs: wait for
core.handleSessionEnd()inside flush (L1 extraction finishes before exit; otherwise the 5s shutdown timeout kills it) - Recall injection: must be registered on
agent.ctx(assembly runs in the agent scope; root listeners never see it); attach one tick aftersession/createdby resolving the agent from theagentsservice
Configuration (profile patch + settings)
Configuration is settings-namespace driven: the profile patch is the base
layer, and the tdai-memory: section of $DSH_HOME/settings.yaml overrides it
(LLM/embedding keys live in settings.yaml). The Web UI Settings → 记忆
section edits every field (v0.2.0, write-only keys); TdaiCore is built at
startup, so changes apply after a restart.
# $DSH_HOME/settings.yaml
tdai-memory:
llm:
apiKey: 'sk-...'
embedding:
apiKey: 'local-no-key'
# profile patch (base layer)
- id: tdai-memory
name: 'dsh-tdai-memory'
config:
extraction:
enabled: true
enableDedup: false # dedup LLM output parsing is flaky; off by default
llm: # L1/L2/L3 extraction model (OpenAI-compatible)
baseUrl: 'https://opencode.ai/zen/go/v1'
model: 'mimo-v2.5' # deepseek-v4-flash produces invalid extraction JSON
embedding: # vectors (OpenAI-compatible /v1/embeddings)
baseUrl: 'http://127.0.0.1:8088/v1'
model: 'Qwen3-Embedding-0.6B'
dimensions: 1024
sendDimensions: false
Install
dsh plugin --profile web add dsh-tdai-memory
then mount it in $DSH_HOME/profiles/web/cordis.patch.yml:
- insert:
- id: tdai-memory
name: 'dsh-tdai-memory'
config: {} # keys can live in settings.yaml instead
and restart dsh web. LLM/embedding API keys can be set in the Web UI
settings page (记忆 / Memory) or directly in settings.yaml under
tdai-memory:.
Note for users
- This plugin is a standard profile bundle (
dsh.bundle.patch):dsh plugin --profile web add dsh-tdai-memoryinstalls and mounts it in one step — no manualcordis.patch.ymledits needed.- The settings section needs the
dsh-host-apiproxynamespace allowlist; the plugin patches it automatically on first start — restartdsh webonce more and the section appears. A dsh update overwrites the patch; the next plugin start re-applies it.- Settings changes apply after a restart (TdaiCore is built at startup).
- Tested against DSH
0.1.0-rc.6,0.1.0-rc.7, and0.1.0-rc.8.
Known trade-offs
- Extraction model:
mimo-v2.5extracts correctly but takes 20-30s per call (background execution, does not block the conversation);deepseek-v4-flashis fast but its JSON output is non-compliant (extracts 0) - dedup: LLM conflict-detection output parsing is unstable (once caused stored=0); off by default; enable only with a more reliable model
- L1 memory vectors: written with storage (8088 embedding is fast); L0
vectors run as a background task, drained by
destroy()on headless exit - Upgrades: after pulling new upstream code, rerun
npx tsc -p dsh-tsconfig.jsonin the tdai project dir (output indist-dsh/)
License
MIT
Read the usage guide →
Install steps, key points, FAQ and compatibility for this plugin — auto-derived from indexed fields.
Listing badge
[](https://deepseek-plugin.org/plugins/Scorp1o117/dsh-tdai-memory)Paste this markdown into your GitHub README to link back to this listing. The badge only states the listing — not a security endorsement.