🧠 Memori:14.4k Stars 的 Agent-Native 记忆层,你的 AI Agent 终于不会"转头就忘"了
项目地址:https://github.com/MemoriLabs/Memori | ⭐ 14,442 Stars | 🛠 Python/TypeScript | 作者:Memori Labs
老实说,Agent 开发最烦人的不是模型选哪个,而是每次会话 Agent 都像个金鱼——聊着聊着就把前面说的全忘了。你刚告诉它"我的数据库是 PostgreSQL",下个问题它又问你用什么数据库。烦不烦?
Memori 就是来解决这个问题的。它不是那种"把整个对话历史怼进 context"的笨办法,而是一个 Agent-Native 的记忆基础设施——自动把对话和 Agent 执行过程转成结构化记忆,下次直接召回。LoCoMo benchmark 上 81.95% 的准确率,每次查询平均只用 1294 tokens,只有全量 context 的 4.97%。
⚡ 一句话概括:给 AI Agent 装了个人脑级别的记忆系统。
一、核心设计
Memori 不是简单的 key-value 缓存,它在四个层级追踪记忆:
最骚的操作是 Advanced Augmentation:它不光记你说了什么,还能从上下文中自动推理出你的偏好和习惯。比如你跟 Agent 说"我习惯用 pnpm 而不是 npm",它不光记住这句话,还会建立一条 rule,下次涉及包管理时自动用 pnpm。
二、上手体验
两行代码搞定集成:
pip install memori
Python 集成 OpenAI:
from memori import Memori
from openai import OpenAI
client = OpenAI()
mem = Memori().llm.register(client)
mem.attribution(entity_id="user_123", process_id="my-agent")
# 第一次对话
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "我的数据库是 PostgreSQL,端口 5432"}]
)
# 下次对话——Memori 自动记着
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "我用的什么数据库?"}]
)
# Memori 召回:PostgreSQL,端口 5432
TypeScript 也一样:
import { Memori } from '@memorilabs/memori';
import { OpenAI } from 'openai';
const client = new OpenAI();
const mem = new Memori().llm.register(client)
.attribution('user_123', 'support_agent');
// Memori 自动在后台记录和召回
三、支持全家桶
Memori 兼容的 LLM:Anthropic、DeepSeek、Gemini、Grok、OpenAI(同步/异步/流式全支持)。
兼容的框架:LangChain、Pydantic AI、Agno。
还直接支持 OpenClaw 和 Hermes Agent 的插件集成:
# OpenClaw 插件
openclaw plugins install @memorilabs/openclaw-memori
openclaw plugins enable openclaw-memori
openclaw gateway restart
# Hermes Agent 记忆提供者
pip install hermes-memori
hermes-memori install
hermes config set memory.provider memori
四、MCP 接入
如果你用 Claude Code、Cursor 或 Codex,不需要 SDK 集成,直接走 MCP:
claude mcp add --transport http memori https://api.memorilabs.ai/mcp/ \
--header "X-Memori-API-Key: ${MEMORI_API_KEY}" \
--header "X-Memori-Entity-Id: your_username" \
--header "X-Memori-Process-Id: claude-code"
五、踩坑提醒
别踩这个坑:Memori 需要显式调用 attribution() 才能工作。如果你只初始化了 Memori 但没设 entity_id 和 process_id,它不会记录任何记忆。官方原话说得很直白——"If you do not provide any attribution, Memori cannot make memories for you."
另外 Memori Cloud 免费版有 IP quota 限制,超过额度可以 python -m memori sign-up 注册拿 API key。
总结
如果受够了每次跟 Agent 重复你的配置信息,试试 Memori。装完你就知道——之前那些"失忆"的 Agent 全是残次品。