memory-tencentdb 是 OpenClaw 的四层记忆系统插件,支持自动捕获对话、结构化提取(L1)、场景分块(L2)和用户画像(L3)。
本指南涵盖插件安装、依赖配置、常见问题排查。
项目要求OpenClaw 版本>= 0.20.0Node.js 版本>= 18.x操作系统Windows / macOS / Linux
bash
# 从 ClawHub 安装
clawhub install memory-tencentdb
# 或手动下载到插件目录
# Windows: %APPDATA%\mx\openclaw-home\<account>\.openclaw\plugins\memory-tencentdb
# macOS/Linux: ~/.openclaw/plugins/memory-tencentdb
关键步骤:插件依赖必须安装到 Gateway 的 node_modules 目录,而不是插件目录。
powershell
# Windows 示例
# 1. 先在插件目录安装依赖
cd "插件目录"
npm install --ignore-scripts
# 2. 复制到 Gateway node_modules
Copy-Item -Path "插件目录\node_modules\js-tiktoken" -Destination "Gateway目录\node_modules\js-tiktoken" -Recurse -Force
powershell
# Windows 示例
cd "Gateway目录"
npm install js-tiktoken --ignore-scripts
在 openclaw.json 中添加插件配置:
json
{
"plugins": {
"enabled": true,
"allow": ["mx", "memory-tencentdb"],
"load": {
"paths": ["~/.openclaw/plugins/memory-tencentdb"]
},
"slots": {
"memory": "memory-tencentdb"
},
"entries": {
"memory-tencentdb": {
"enabled": true,
"config": {
"pipeline": {
"everyNConversations": 3,
"enableWarmup": true,
"l1IdleTimeoutSeconds": 10
}
}
}
}
}
}
重要:SIGUSR1 信号只重新加载配置,不会重新加载插件。必须完全重启 Gateway。
bash
# 完全重启(推荐)
openclaw gateway stop
openclaw gateway start
# 或使用 mx 客户端重启
项目路径插件目录%APPDATA%\mx\openclaw-home\<account>\.openclaw\plugins\memory-tencentdb\Gateway 目录%LOCALAPPDATA%\openclaw\mx\current\Gateway node_modules%LOCALAPPDATA%\openclaw\mx\current\node_modules\配置文件%APPDATA%\mx\openclaw-home\<account>\.openclaw\openclaw.json记忆数据%APPDATA%\mx\openclaw-home\<account>\.openclaw\memory-tdai\
项目路径插件目录~/.openclaw/plugins/memory-tencentdb/Gateway 目录~/.openclaw/gateway/配置文件~/.openclaw/openclaw.json记忆数据~/.openclaw/memory-tdai/
bash
# 查看日志,确认无报错
tail -f /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log | grep memory-tencentdb
正常输出应无 Cannot find module 错误。
bash
# 查看对话捕获
ls -la ~/.openclaw/memory-tdai/conversations/
# 查看 L1 记录
ls -la ~/.openclaw/memory-tdai/records/
# 查看向量数据库
ls -la ~/.openclaw/memory-tdai/vectors.db
bash
# 使用 OpenClaw CLI 检查配置
openclaw config get | grep -A 20 "memory-tencentdb"
Cannot find module 'js-tiktoken'#原因:依赖安装到了插件目录,但 Gateway 使用 jiti 加载插件时,从 Gateway 目录解析依赖。
解决方案:
powershell
# 将 js-tiktoken 复制到 Gateway node_modules
Copy-Item -Path "插件目录\node_modules\js-tiktoken" -Destination "Gateway目录\node_modules\js-tiktoken" -Recurse -Force
# 完全重启 Gateway
openclaw gateway stop
openclaw gateway start
原因:SIGUSR1 信号只重新加载配置,不会重新加载插件。
解决方案:必须完全重启 Gateway(stop + start)。
诊断方法:
powershell
# Windows: 确认 Gateway 进程使用的 node 路径
(Get-Process -Id <PID>).Path
# 确认启动参数
(Get-WmiObject Win32_Process -Filter "ProcessId=<PID>").CommandLine
检查项:
pipeline.everyNConversations 配置是否合理(默认 3)pipeline.l1IdleTimeoutSeconds 是否设置(默认 10 秒)memory-tencentdb 需要以下核心依赖:
依赖用途js-tiktokenToken 计数,用于上下文管理better-sqlite3本地 SQLite 数据库(可选,用于向量存储)
注意:所有依赖必须安装到 Gateway 的 node_modules 目录。
memory-tencentdb 采用四层记忆架构:
层级名称功能L0原始对话自动捕获所有对话,存储为 JSONLL1结构化记录从对话中提取关键信息(episodic/instruction/semantic)L2场景分块按场景组织记忆,支持上下文召回L3用户画像长期学习用户偏好和行为模式
MIT License