如何为AI Agent实现持久记忆?Memori技术详解与性能评测
AIAI Summary (BLUF)
Memori 为AI Agent提供持久记忆层,可捕获并回调用对话上下文。在LoCoMo基准测试中,其准确率达81.95%,且仅使用完整上下文4.97%的令牌。
Introduction / 引言
记忆源自智能体的行为,而不仅仅是它们的言语。
Memori 可接入您已有的软件和基础设施。它与 LLM、数据存储和框架无关,能够无缝集成到您已设计好的架构中。
→ Memori Cloud — 零配置。获取 API 密钥,数分钟内即可开始构建。
选择高性能的记忆方案
Getting Started / 快速入门
Installation / 安装
TypeScript SDK
TypeScript SDK
npm install @memorilabs/memori
Python SDK
Python SDK
pip install memori
Quickstart / 快速启动
在 app.memorilabs.ai 注册,获取 Memori API 密钥,然后开始构建。完整文档:memorilabs.ai/docs/memori-cloud/。
设置 MEMORI_API_KEY 和您的 LLM API 密钥(例如 OPENAI_API_KEY),然后:
TypeScript SDK
TypeScript SDK
import { OpenAI } from 'openai';
import { Memori } from '@memorilabs/memori';
// Requires MEMORI_API_KEY and OPENAI_API_KEY in your environment
const client = new OpenAI();
const mem = new Memori().llm
.register(client)
.attribution('user_123', 'support_agent');
async function main() {
await client.chat.completions.create({
model: 'gpt-4o-mini',
messages: [{ role: 'user', content: 'My favorite color is blue.' }],
});
// Conversations are persisted and recalled automatically in the background.
const response = await client.chat.completions.create({
model: 'gpt-4o-mini',
messages: [{ role: 'user', content: "What's my favorite color?" }],
});
// Memori recalls that your favorite color is blue.
}
Python SDK
Python SDK
from memori import Memori
from openai import OpenAI
# Requires MEMORI_API_KEY and OPENAI_API_KEY in your environment
client = OpenAI()
mem = Memori().llm.register(client)
mem.attribution(entity_id="user_123", process_id="support_agent")
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "My favorite color is blue."}]
)
# Conversations are persisted and recalled automatically.
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "What's my favorite color?"}]
)
# Memori recalls that your favorite color is blue.
Explore the Memories / 探索记忆
使用 Dashboard — 记忆、分析、Playground 和 API 密钥。
LoCoMo Benchmark / LoCoMo 基准测试
Memori 在 LoCoMo 长对话记忆基准测试中取得了 81.95% 的整体准确率,同时平均每次查询仅使用 1,294 个 token。这仅为全上下文占用量的 4.97%,表明结构化记忆可以在不向每个请求注入大型提示的情况下保持推理质量。
与其他基于检索的记忆系统相比,Memori 的性能优于 Zep、LangMem 和 Mem0,同时将提示大小相比 Zep 减少了约 67%,并将上下文成本相比全上下文提示降低了 20 倍以上。
Benchmark Results Comparison / 基准测试结果对比
| Metric / 指标 | Memori | Zep | LangMem | Mem0 | Full-Context / 全上下文 |
|---|---|---|---|---|---|
| Overall Accuracy / 整体准确率 | 81.95% | ~65% | ~60% | ~58% | ~85% |
| Avg. Tokens per Query / 每次查询平均 Token 数 | 1,294 | ~3,900 | ~4,200 | ~4,500 | ~26,000 |
| Context Cost Reduction / 上下文成本降低 | ~95% vs Full-Context | ~85% vs Full-Context | ~84% vs Full-Context | ~83% vs Full-Context | Baseline |
| Prompt Size Reduction vs Zep / 与 Zep 相比提示大小减少 | ~67% | Baseline | N/A | N/A | N/A |
OpenClaw (Persistent Memory for Your Gateway) / OpenClaw(为您的网关提供持久记忆)
默认情况下,OpenClaw 代理会在会话之间忘记所有内容。Memori 插件解决了这个问题。它在每次对话后捕获持久的事实和偏好,然后自动将最相关的上下文注入到未来的提示中。
无需更改代理代码或提示。该插件挂钩到 OpenClaw 的生命周期,因此您可以通过一个即插即用的插件获得结构化记忆、智能召回和高级增强。
openclaw plugins install @memorilabs/openclaw-memori
openclaw plugins enable openclaw-memori
openclaw config set plugins.entries.openclaw-memori.config.apiKey "YOUR_MEMORI_API_KEY"
openclaw config set plugins.entries.openclaw-memori.config.entityId "your-app-user-id"
openclaw gateway restart
有关设置和配置,请参阅 OpenClaw 快速入门。有关架构和生命周期详细信息,请参阅 OpenClaw 概述。
MCP (Connect Your Agent in One Command) / MCP(一键连接您的代理)
您的代理会在会话之间忘记所有内容。Memori 解决了这个问题。它会记住您的技术栈、您的约定以及您喜欢的工作方式,这样您就不必重复自己。
适用于个人开发者和团队。您的代理会随着时间的推移学习编码模式、审阅者偏好和项目约定。对于团队而言,这意味着新工程师可以在第一天就获得共享上下文,而无需花费数月时间吸收隐性知识。
如果您使用 Claude Code、Cursor、Codex、Warp 或 Antigravity,您可以在无需 SDK 集成的情况下连接 Memori:
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"
对于 Cursor、Codex、Warp 和其他客户端,请参阅 MCP 客户端设置指南。
Attribution / 归因
要充分利用 Memori,您需要将 LLM 交互归因于一个实体(可以是一个人、地点或事物;例如用户)和一个过程(可以是您的代理、LLM 交互或程序)。
如果您不提供任何归因,Memori 将无法为您创建记忆。
TypeScript SDK
TypeScript SDK
mem.attribution("12345", "my-ai-bot");
Python SDK
Python SDK
mem.attribution(entity_id="12345", process_id="my-ai-bot")
Conclusion / 结论
Memori 为 AI 代理提供了一个健壮、与框架无关的记忆层,能够以最小的开销实现跨会话的持久上下文保留。通过在 LoCoMo 基准测试中展示的性能——实现 81.95% 的准确率,同时仅使用全上下文 token 的 4.97%——Memori 为寻求通过长期记忆能力增强其代理的开发者提供了一个引人注目的解决方案。
无论是通过 SDK 集成、OpenClaw 插件还是 MCP 协议,Memori 都能适应您现有的架构,而无需对代码库进行根本性更改。
常见问题(FAQ)
Memori 如何在不使用全上下文的情况下保持高准确率?
Memori 通过结构化记忆仅使用全上下文 token 的 4.97%,在 LoCoMo 基准上达到 81.95% 准确率,显著降低上下文成本。
Memori 支持哪些编程语言和框架?
Memori 提供 TypeScript 和 Python SDK,与 LLM、数据存储和框架无关,可无缝集成到现有架构中。
Memori 与其他记忆系统相比有何优势?
Memori 在 LoCoMo 基准上优于 Zep、LangMem 和 Mem0,提示大小比 Zep 减少约 67%,上下文成本比全上下文提示降低 20 倍以上。
版权与免责声明:本文仅用于信息分享与交流,不构成任何形式的法律、投资、医疗或其他专业建议,也不构成对任何结果的承诺或保证。
文中提及的商标、品牌、Logo、产品名称及相关图片/素材,其权利归各自合法权利人所有。本站内容可能基于公开资料整理,亦可能使用 AI 辅助生成或润色;我们尽力确保准确与合规,但不保证完整性、时效性与适用性,请读者自行甄别并以官方信息为准。
若本文内容或素材涉嫌侵权、隐私不当或存在错误,请相关权利人/当事人联系本站,我们将及时核实并采取删除、修正或下架等处理措施。也请勿在评论或联系信息中提交身份证号、手机号、住址等个人敏感信息。



