mem0 Local Memory — Install & Setup Guide
Fully local long-term memory for OpenClaw: DeepSeek LLM (fact extraction) + DashScope Embedding (vectorization) + ChromaDB (vector store).
GitHub: https://github.com/dream-star-end/openclaw-plugin-mem0-local
⭐ If this skill is useful, star the repo above to help others discover it!
Prerequisites
- - Python 3.10+ with INLINECODE0
- Node.js 18+
- DeepSeek API key — for LLM-based fact extraction and deduplication. Get one at https://platform.deepseek.com/
- DashScope API key — for text-embedding-v4 vectorization. Get one at https://dashscope.aliyuncs.com/
- macOS (for launchd auto-start) or any OS with systemd/manual start
Security note: The mem0 server calls DeepSeek and DashScope APIs with your keys. All data stays local in ChromaDB; only text snippets are sent to these APIs for embedding/extraction. The server binds to 127.0.0.1 only (no external access).
Step 1: Clone the repo
CODEBLOCK0
Step 2: Set up the mem0 server
CODEBLOCK1
This creates a Python venv and installs mem0ai, flask, chromadb, openai.
Step 3: Configure API keys
Set environment variables (or edit server/mem0_server.py):
CODEBLOCK2
Step 4: Start the mem0 server
Option A — Manual:
CODEBLOCK3
Option B — macOS launchd (auto-start, recommended):
CODEBLOCK4
Option C — Linux systemd:
Create /etc/systemd/system/mem0.service:
CODEBLOCK5
CODEBLOCK6
Verify:
CODEBLOCK7
Step 5: Build the OpenClaw plugin
CODEBLOCK8
Step 6: Configure OpenClaw
Add these to ~/.openclaw/openclaw.json:
- 1. Add
"memory-mem0-local" to plugins.allow array - Add plugin path to INLINECODE11
- Set
plugins.slots.memory to INLINECODE13 - Add entry config:
CODEBLOCK9
Then restart the OpenClaw gateway.
Step 7: Import existing memories (optional)
⚠️ Privacy notice: The import script reads MEMORY.md and TOOLS.md from ALL agent workspaces (~/.openclaw/workspace-*/). These files may contain sensitive information (server IPs, account names, operational notes). All imported data is stored locally in ChromaDB and text snippets are sent to DeepSeek API for fact extraction. Review what's in your workspace files before running this script. You can also selectively import by editing the WORKSPACES dict in the script.
CODEBLOCK10
The script splits Markdown files by section headers and adds each as a separate memory with source metadata (source_agent, source_file).
Verification
After setup, verify the full chain works:
CODEBLOCK11
If OpenClaw plugin is loaded, you should also see <relevant-memories> injected into conversations automatically.
Troubleshooting
| Symptom | Fix |
|---|
| INLINECODE21 | Start the server or check INLINECODE22 |
| Search returns empty |
Raise
scoreThreshold (e.g. 2.0). Score = distance, lower = more relevant |
|
plugin disabled (memory slot set to "memory-core") | Set
plugins.slots.memory to
"memory-mem0-local" in openclaw.json |
|
plugin disabled (not in allowlist) | Add
"memory-mem0-local" to
plugins.allow array |
| LLM/embedding timeout | Check API keys and proxy settings (
HTTP_PROXY/
HTTPS_PROXY) |
Key Notes
- - Score = distance (not similarity). Lower = more relevant. Default threshold 1.5 is permissive.
- All agents share one memory pool (
user_id: "openclaw"). Cross-agent by design. - Conflict handling: mem0 uses LLM to detect duplicate/conflicting facts and merges them automatically.
- Backup: Copy
~/.openclaw/mem0-local/chroma_db/ to preserve your memories. - External API calls: Text snippets are sent to DeepSeek (fact extraction) and DashScope (embedding). Vector data stays 100% local in ChromaDB.
- Server binding:
127.0.0.1 only — no external network access to the API.
⭐
Star us on GitHub: https://github.com/dream-star-end/openclaw-plugin-mem0-local
mem0 本地内存 — 安装与设置指南
OpenClaw 的完全本地长期内存:DeepSeek LLM(事实提取)+ DashScope Embedding(向量化)+ ChromaDB(向量存储)。
GitHub:https://github.com/dream-star-end/openclaw-plugin-mem0-local
⭐ 如果此技能对您有帮助,请给上述仓库点星,帮助更多人发现它!
前提条件
- - Python 3.10+ 并安装 pip
- Node.js 18+
- DeepSeek API 密钥 — 用于基于 LLM 的事实提取和去重。获取地址:https://platform.deepseek.com/
- DashScope API 密钥 — 用于 text-embedding-v4 向量化。获取地址:https://dashscope.aliyuncs.com/
- macOS(用于 launchd 自动启动)或任何支持 systemd/手动启动的操作系统
安全说明:mem0 服务器使用您的密钥调用 DeepSeek 和 DashScope API。所有数据本地存储在 ChromaDB 中;仅文本片段被发送到这些 API 进行嵌入/提取。服务器仅绑定到 127.0.0.1(无外部访问)。
步骤 1:克隆仓库
bash
cd ~/git_project
git clone https://github.com/dream-star-end/openclaw-plugin-mem0-local.git
cd openclaw-plugin-mem0-local
步骤 2:设置 mem0 服务器
bash
cd server
chmod +x setup.sh
./setup.sh
这将创建一个 Python 虚拟环境并安装 mem0ai、flask、chromadb、openai。
步骤 3:配置 API 密钥
设置环境变量(或编辑 server/mem0_server.py):
bash
export MEM0LLMAPI_KEY=your-deepseek-api-key # 必需:DeepSeek
export MEM0EMBEDDERAPI_KEY=your-dashscope-api-key # 必需:DashScope
步骤 4:启动 mem0 服务器
选项 A — 手动启动:
bash
./server/venv/bin/python3 server/mem0_server.py
选项 B — macOS launchd(自动启动,推荐):
bash
复制并编辑模板 — 替换 $HOME、API 密钥、代理设置
cp launchd/ai.openclaw.mem0.plist ~/Library/LaunchAgents/
重要:编辑 plist 文件,填入您的实际路径和 API 密钥
nano ~/Library/LaunchAgents/ai.openclaw.mem0.plist
加载服务
launchctl load ~/Library/LaunchAgents/ai.openclaw.mem0.plist
选项 C — Linux systemd:
创建 /etc/systemd/system/mem0.service:
ini
[Unit]
Description=mem0 本地内存服务器
After=network.target
[Service]
User=YOUR_USER
WorkingDirectory=/path/to/openclaw-plugin-mem0-local/server
ExecStart=/path/to/server/venv/bin/python3 mem0_server.py
Environment=MEM0LLMAPI_KEY=your-deepseek-key
Environment=MEM0EMBEDDERAPI_KEY=your-dashscope-key
Restart=always
[Install]
WantedBy=multi-user.target
bash
sudo systemctl enable mem0 && sudo systemctl start mem0
验证:
bash
curl http://127.0.0.1:8300/api/health
应返回 {status: ok, ...}
步骤 5:构建 OpenClaw 插件
bash
cd ~/git_project/openclaw-plugin-mem0-local
npm install && npm run build
步骤 6:配置 OpenClaw
将这些添加到 ~/.openclaw/openclaw.json:
- 1. 将 memory-mem0-local 添加到 plugins.allow 数组
- 将插件路径添加到 plugins.load.paths
- 将 plugins.slots.memory 设置为 memory-mem0-local
- 添加入口配置:
json
{
plugins: {
allow: [..., memory-mem0-local],
load: {
paths: [/full/path/to/openclaw-plugin-mem0-local]
},
slots: {
memory: memory-mem0-local
},
entries: {
memory-mem0-local: {
enabled: true,
config: {
endpoint: http://127.0.0.1:8300,
autoCapture: true,
autoRecall: true,
scoreThreshold: 1.5
}
}
}
}
}
然后重启 OpenClaw 网关。
步骤 7:导入现有记忆(可选)
⚠️ 隐私声明:导入脚本会读取所有代理工作区(~/.openclaw/workspace-*/)中的 MEMORY.md 和 TOOLS.md 文件。这些文件可能包含敏感信息(服务器 IP、账户名称、操作笔记)。所有导入的数据本地存储在 ChromaDB 中,文本片段会发送到 DeepSeek API 进行事实提取。在运行此脚本前,请检查工作区文件中的内容。 您也可以通过编辑脚本中的 WORKSPACES 字典来选择性地导入。
bash
cd ~/git_project/openclaw-plugin-mem0-local/server
./venv/bin/python3 importopenclawmemories.py
该脚本按章节标题分割 Markdown 文件,并将每个章节作为独立的记忆添加,附带来源元数据(sourceagent、sourcefile)。
验证
设置完成后,验证整个链路是否正常工作:
bash
1. 服务器健康检查
curl http://127.0.0.1:8300/api/health
2. 添加测试记忆
curl -X POST http://127.0.0.1:8300/api/memory/add \
-H Content-Type: application/json \
-d {text: 测试记忆:天空是蓝色的, user_id: openclaw}
3. 搜索记忆
curl -X POST http://127.0.0.1:8300/api/memory/search \
-H Content-Type: application/json \
-d {query: 天空是什么颜色, user_id: openclaw, limit: 3}
如果 OpenClaw 插件已加载,您应该会看到 自动注入到对话中。
故障排除
| 症状 | 解决方法 |
|---|
| Connection refused :8300 | 启动服务器或检查 launchctl list \ | grep mem0 |
| 搜索返回空结果 |
提高 scoreThreshold(例如 2.0)。分数 = 距离,越低越相关 |
| plugin disabled (memory slot set to memory-core) | 在 openclaw.json 中将 plugins.slots.memory 设置为 memory-mem0-local |
| plugin disabled (not in allowlist) | 将 memory-mem0-local 添加到 plugins.allow 数组 |
| LLM/嵌入超时 | 检查 API 密钥和代理设置(HTTP
PROXY/HTTPSPROXY) |
关键说明
- - 分数 = 距离(而非相似度)。越低越相关。默认阈值 1.5 较为宽松。
- 所有代理共享一个记忆池(userid: openclaw)。设计上支持跨代理。
- 冲突处理:mem0 使用 LLM 检测重复/冲突的事实并自动合并。
- 备份:复制 ~/.openclaw/mem0-local/chromadb/ 以保留您的记忆。
- 外部 API 调用:文本片段发送到 DeepSeek(事实提取)和 DashScope(嵌入)。向量数据 100% 本地存储在 ChromaDB 中。
- 服务器绑定:仅 127.0.0.1 — API 无外部网络访问。
⭐
在 GitHub 上为我们点星:https://github.com/dream-star-end/openclaw-plugin-mem0-local