← Back to Skills Marketplace
publieople

Mem0 Memory Setup

by po · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
48
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install mem0-memory-setup
Description
为 Hermes Agent 配置 Mem0 外部记忆层。涵盖 pip install、npm CLI 安装、 Agent Mode 注册、Hermes 集成、账号认领、验证、和国内网络/特殊 shell 的排错。 使用场景:用户问"怎么给 Hermes 加记忆"、"装一下 mem0"、"配置外部记忆"、 "me...
README (SKILL.md)

Mem0 记忆层配置指南

Mem0("mem-zero")是开源的 AI Agent 记忆层(Apache 2.0)。Hermes 内置 8 种记忆 provider,其中 Mem0 支持服务端自动事实提取 + 语义搜索 + 实体提权,一行命令接入。

官方文档: https://docs.mem0.ai Hermes 集成文档: https://hermes-agent.nousresearch.com/docs/user-guide/features/memory-providers GitHub: https://github.com/mem0ai/mem0

触发条件

  • 用户说"配置记忆"、"装 mem0"、"memory provider"、"让 Hermes 记住我"
  • hermes memory status 显示 provider 为 built-in only
  • 需要跨会话持久记忆的场景

完整配置流程

Step 1: 安装 Python 包

pip install mem0ai

中国用户(镜像加速):

pip install mem0ai -i https://pypi.tuna.tsinghua.edu.cn/simple

Step 1b: 验证 Python 库已正确安装

python3 -c "from mem0 import Memory; print('Mem0 lib OK')"
# → Mem0 lib OK

Step 2: 安装 Mem0 CLI(获取 API Key)

Mem0 CLI (@mem0/cli) 用于注册 Agent Mode 账号和获取 API Key:

npm install -g @mem0/cli

如果报 EACCES(权限错误):

npm 默认 prefix 是 /usr,普通用户没有写入权限。不要用 sudo,改为用户目录:

# 检查当前 prefix
npm config get prefix   # 很可能返回 /usr

# 设为用户目录(只需一次,永久生效)
npm config set prefix ~/.npm-global

# 重新安装
npm install -g @mem0/cli

重要:保持 prefix 为 ~/.npm-global,不要改回 /usr 这条设定对所有 npm 全局包(mmx-cli、@mem0/cli 等)都生效,改完后所有 npm install -g 都不再需要 sudo。永久解决 EACCES 问题。

PATH 问题(fish / zsh 等非 bash shell)

CLI 装在 ~/.npm-global/bin/mem0。bash 通过 .bashrc 加 PATH:

export PATH="$HOME/.npm-global/bin:$PATH"

fish shell(通过 .bashrc 启动 fish): 如果 .bashrc 中有上面这行,fish 会继承继承过来的 PATH。验证用:

type mem0
# → mem0 is /home/po/.npm-global/bin/mem0

如果找不到,在 ~/.config/fish/config.fish 添加:

fish_add_path ~/.npm-global/bin

Step 3: Agent Mode 注册(无邮箱)

AI Agent 可以直接注册,无需人类邮箱:

mem0 init --agent --agent-caller hermes

说明:

  • --agent-caller hermes — 告诉 Mem0 这是 Hermes Agent
  • 注册后在 ~/.mem0/config.json 保存 API Key
  • 此账号未认领,30 天内可认领到人类邮箱

Step 4: 读取 API Key

python3 -c "import json; print(json.load(open('/home/po/.mem0/config.json'))['platform']['api_key'])"

或直接查看:cat ~/.mem0/config.json

Step 5: 配置 Hermes

写入 API Key 到 .env

MEM0_KEY=$(python3 -c "import json; print(json.load(open('$HOME/.mem0/config.json'))['platform']['api_key'])")
echo "export MEM0_API_KEY=$MEM0_KEY" >> ~/.hermes/.env

设置 provider:

hermes config set memory.provider mem0

Step 6: 验证

hermes memory status
# → Plugin: installed ✓
# → Status: available ✓
# → Provider: mem0 ← active

Step 7: 测试写入和检索

mem0 add "Test memory: user prefers concise responses"
mem0 search "prefers concise"
# → Found 1 memories:
# → User prefers concise responses in conversations
# → Score: 0.34

Step 8: 账号认领(可选但推荐)

让人类用户认领 Agent 账号,获得 Web 面板和管理权限:

mem0 init --email \x3Cyour-email>
# 输入邮箱验证码即可
# API Key 不变,所有记忆数据保留

认领后可在 app.mem0.ai 查看记忆数据和管理面板。

Hermes 集成后行为

时机 行为
每轮对话前 Mem0 预取相关记忆注入 system prompt(零延迟,后台完成)
每轮回复后 Mem0 自动提取事实并存储(后台线程,不阻塞对话)
会话结束时 服务端处理存储优化和去重
Circuit breaker 连续 5 次失败后暂停 2 分钟,Agent 继续工作不受影响

可用工具

启用 Mem0 后,Hermes 额外获得 3 个工具(自动调用,无需手动触发):

工具 功能
mem0_profile 获取所有已存储的用户记忆
mem0_search 语义搜索(支持 rerank + top_k 过滤)
mem0_conclude 手动存储一条事实(不走服务端提取)

内置记忆 vs Mem0

内置记忆(memory/user 工具)始终并行运行,不受影响:

内置记忆:   MEMORY.md + USER.md 文件 → 2 个分区,各 2200 字符上限
Mem0:       云端语义向量库 → 无大小限制,支持语义搜索 + 自动提取

两者互补:内置记忆存静态事实(项目路径、设备参数、偏好),Mem0 存动态学习(用户习惯、工作模式、历史偏好变化)。

已知问题与排错

1. 国内网络

  • pip install 超时: 用清华镜像 -i https://pypi.tuna.tsinghua.edu.cn/simple
  • npm install 正常: npm 镜像通常够快
  • Mem0 Cloud API (api.mem0.ai) 延迟: 国内访问约 0.5-1.5s 延迟,Hermes 用后台预取 + 缓存屏蔽了感知延迟
  • 自托管选项: Mem0 支持 Docker 自部署,见 Self-hosted docs

2. mem0 命令找不到

# 检查安装位置
ls ~/.npm-global/bin/mem0
ls /usr/lib/node_modules/.bin/mem0

# 加 PATH
export PATH="$HOME/.npm-global/bin:$PATH"

3. Hermes memory status 显示 not available

检查以下 env var 是否已设置:

grep MEM0_API_KEY ~/.hermes/.env

4. npm 全局安装报 EACCES

npm 默认 prefix 为 /usr,普通用户无写入权限。解法:

npm config set prefix ~/.npm-global
# 之后安装无需 sudo

5. fish shell 下 which 找不到

fish 没有 which 命令。用内置的 type 代替:

type mem0
# → mem0 is /home/po/.npm-global/bin/mem0

6. 写入记忆时被安全模块拦截

memory 工具写入 .env 路径、API Key 明文等敏感信息会触发安全模式 hermes_env 导致写入被拒绝。不要在 memory 条目中包含 .envapi_keytokensecret 等字样的路径或值。

解法:将敏感配置步骤写在 SKILL.md 中(不注入 system prompt),只在 memory 中记录无风险的事实(如 "Mem0 已配置"、"provider: mem0" 等摘要)。

Usage Guidance
Install only if you want Hermes to use Mem0 cloud memory. Review the commands before running them, keep the Mem0 API key out of logs and shared terminal output, restrict permissions on any env file containing it, and remember that enabled memory may store conversation-derived facts in Mem0.
Capability Tags
requires-sensitive-credentials
Capability Assessment
Purpose & Capability
The requested capabilities fit the stated purpose: installing Mem0 components, registering an agent account, configuring Hermes, and explaining that Mem0 stores and searches agent memory in the cloud.
Instruction Scope
The trigger language is somewhat broad and could activate for generic memory-provider questions, but the body stays focused on Mem0/Hermes setup and does not include deceptive or unrelated instructions.
Install Mechanism
The skill asks users to run pip and global npm installs and to change npm's global prefix to a user directory; this is disclosed and purpose-aligned, with no bundled executable files.
Credentials
The skill reads a local Mem0 config file and appends MEM0_API_KEY to the Hermes .env file, which is expected for this integration but needs careful secret handling.
Persistence & Privilege
It enables persistent cloud-backed memory and automatic memory tools for Hermes; this is clearly described, though users should understand conversation facts may be stored outside the local machine.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install mem0-memory-setup
  3. After installation, invoke the skill by name or use /mem0-memory-setup
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
mem0-memory-setup 1.0.0 - 初始发布 - 提供 Hermes Agent 集成 Mem0 记忆层的详细配置指南,包括 pip 和 npm CLI 安装步骤 - 涵盖 Agent Mode 注册、API Key 读取与 Hermes 配置流程 - 针对国内网络、npm 权限、shell 兼容等常见问题给出快速排错建议 - 介绍集成后 Hermes 的新能力、可用工具及内置记忆和 Mem0 的互补关系 - 列出已知问题及针对性解决方法,提升配置和排错体验
Metadata
Slug mem0-memory-setup
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Mem0 Memory Setup?

为 Hermes Agent 配置 Mem0 外部记忆层。涵盖 pip install、npm CLI 安装、 Agent Mode 注册、Hermes 集成、账号认领、验证、和国内网络/特殊 shell 的排错。 使用场景:用户问"怎么给 Hermes 加记忆"、"装一下 mem0"、"配置外部记忆"、 "me... It is an AI Agent Skill for Claude Code / OpenClaw, with 48 downloads so far.

How do I install Mem0 Memory Setup?

Run "/install mem0-memory-setup" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Mem0 Memory Setup free?

Yes, Mem0 Memory Setup is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Mem0 Memory Setup support?

Mem0 Memory Setup is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Mem0 Memory Setup?

It is built and maintained by po (@publieople); the current version is v1.0.0.

💬 Comments