如何让你的小龙虾不再健忘
官方文档中针对 mem0 的安装教程并不是很详细,而且也可能随着 OpenClaw 版本的不同会出现很多问题,而且通过提示词的方式,小龙虾也并不能自行纠错执行,甚至会出现死循环的情况
本文基于 openclaw@v2026.4.9 和 mem0@1.0.5 版本进行配置,可进行参考
注意
执行期间请停用已经启动的 Openclaw 实例,防止资源被占用,并对相应重要的配置文件、记忆等做备份
安装插件
由于新版的 OpenClaw 在插件安装上进行了安全限制,会优先从 ClawHub 中进行拉取,查询不到才会从 npm 仓库进行查询,因此我们在安装插件时很容易遇到 claw hub rate limit exceeded 的报错信息,这是因为触发了 ClawHub 的限流策略
网上的处理方法很多,但治标不治本,仅供参考:
- 切换网络IP
- 切换梯子网络IP
- 本地执行
clawhub login --token ${在ClawHub页面获取到的CliToken}
然后执行 openclaw plugins install @mem0/openclaw-mem0 进行安装
配置插件
1. 禁用内置记忆模块
我们装的小龙虾内置了记忆模块,根据官方文档介绍,某些插件槽位是独占的,即同一时间只能激活一个,这个时候我们如果不禁用内置记忆模块而是直接启动的话,我们的 openclaw-mem0 插件是无法激活的,控制台会报这样的错误:
plugins.entries.openclaw-mem0: plugin disabled (memory slot set to "memory-core") but config is present
我们需要修改 openclaw.json 配置文件,在 plugins 作用域下配置记忆插件的槽位为 openclaw-mem0 ,如下:
"slots": {
"memory": "openclaw-mem0",
"contextEngine": "legacy"
},
2. 开启 openclaw-mem0 模块
接下来配置我们的 openclaw-mem0 配置,依然是在 openclaw.json 配置文件中
- 允许使用插件:在 plugins.allow 作用域下添加
openclaw-mem0字段,如下:"allow": [ "openclaw-mem0", ... ] - 自定义插件配置:在 plugins.entires 作用域下添加
openclaw-mem0字段,并补充相应配置,如下:"openclaw-mem0": { "enabled": true, "config": { // 使用官方云服务 "mode": "platform", // 从官方云服务获取api_key "apiKey": "m0-xxxx", // 自定义用户id "userId": "openclaw-main" } } - 重启网关服务以应用设置
openclaw gateway restart
3. 查询状态
使用 openclaw plugins list 查看启用状态,如果不是 loaded ,请使用 openclaw plugins enable openclaw-mem0 进行启用
使用 openclaw mem0 status 查询插件状态,确认终端日志中包含 “Connected to Mem0”,如果没有则根据日志进行排查
4. 导入已有记忆
至此我们就成功的启用了该插件,接下来根据官方文档中的 Prompt 方式,导入现在已有的记忆,指令如下:
Import Existing Memories
4. Read these files from ~/.openclaw/workspace/ if they exist:
- SOUL.md, IDENTITY.md, USER.md, MEMORY.md
- Skip: AGENTS.md, BOOTSTRAP.md, HEARTBEAT.md, TOOLS.md
5. Read all files from ~/.openclaw/workspace/memory/ matching the format YYYY-MM-DD.md, most recent 30 days only.
6. Build one combined JSON array — files under 2000 words as a single item, longer files split by heading (#). Write to /tmp/mem0_import.json and run:
openclaw mem0 import /tmp/mem0_import.json
7. Run: openclaw mem0 search "preferences" to confirm memories are searchable.
8. Report: which files were found, total items imported, and search results.
执行完毕后即可前往 dashboard 页面查看是否成功发送请求将记忆进行上传,也可以通过 openclaw mem0 search "关键词" 看是否可以成功检索
记忆自动上传
当我们配置好后,由于默认配置 autoRecall(每回合开始前注入记忆) 和 autoCapture(每回合结束后存储信息) 都为 true ,因此我们无需手动进行上传或者更新,mem0 插件会自动帮我们做好