DAILY READ · 2026-11-06 · 第 1/3 部分

Agent 记忆系统对比精读:MemGPT/Letta、Zep/Graphiti、LangMem

每日页收录该篇完整全文;高亮区间是今天的阅读目标,其余部分随时可读。

目录

题记与说明

来源清单

👉 今日目标从这里开始 — 读到这里为止(约 9,767 字 / 20 分钟)。
#来源链接用途
1MemGPT 论文(Packer et al., arXiv:2310.08560, 2023-10 首发 / 2024-02 v2)https://arxiv.org/abs/2310.08560 、全文 https://arxiv.org/html/2310.08560v2架构与实验数据
2Letta 官方 GitHub README + 博客《Agent Memory》+ 文档 memory-blocks 页https://github.com/letta-ai/letta 、https://www.letta.com/blog/agent-memory 、https://docs.letta.com/v1-sdk/memory/memory-blocks/产品化演进、memory blocks、sleep-time compute
3Zep 论文(Rasmussen et al., arXiv:2501.13956, 2025-01)https://arxiv.org/abs/2501.13956 、全文 https://arxiv.org/html/2501.13956v1Graphiti 架构、bi-temporal、基准数据
4Zep 官方博客《State-of-the-Art Agent Memory》https://www.getzep.com/blog/state-of-the-art-agent-memory/厂商定位、对 MemGPT 的批评、与 GraphRAG 的区别
5Graphiti GitHub READMEhttps://github.com/getzep/graphiti开源框架依赖、与 Zep 的关系、license
6LangMem 文档 + 概念指南 + GitHub READMEhttps://langchain-ai.github.io/langmem/ 、https://langchain-ai.github.io/langmem/concepts/conceptual_guide/ 、https://github.com/langchain-ai/langmem记忆类型学、hot path vs background、API、维护状态

TL;DR

三个系统代表了 agent 记忆的三条技术路线:

  1. MemGPT/Letta —— "LLM 即操作系统":把上下文窗口当 RAM、外部数据库当磁盘,让 agent 自己调用函数在两层之间搬运和改写记忆(self-editing memory)。产品化为 Letta 后,核心抽象是 memory blocks(带 label/description/value/limit 的可编辑文本块,可多 agent 共享),并引入 sleep-time compute(空闲时异步整理记忆)。
  2. Zep/Graphiti —— "时序知识图谱即记忆":记忆不是文本块而是一张 双时间轴(bi-temporal)知识图谱,事实有有效期(valid/invalid),新信息与旧事实矛盾时作废旧边而非删除。检索是 cosine + BM25 + 图遍历的混合搜索加五种重排。论文报告 DMR 94.8%(超 MemGPT 的 93.4%),LongMemEval 上比全上下文基线准确率最高 +18.5%、延迟 -90%、token 用量 <2%。
  3. LangMem —— "记忆是 SDK 原语":LangChain 出品的轻量库(MIT),不做服务不做数据库,提供语义/情景/程序性三类记忆的可组合原语:hot path 工具(agent 对话中即时写)+ background memory manager(异步提取合并)+ prompt optimizer(程序性记忆)。存储落在 LangGraph BaseStore(namespace 化的 JSON 文档)。

一句话选型:要"时间正确性"(事实会过期、会变化)→ Graphiti;要开箱即用的有状态 agent 运行时 + 人可直接编辑的记忆块 → Letta;已在 LangGraph 生态、想低成本起步 → LangMem。三者并不互斥,可组合(详见 §5)。


1. 问题背景:agent 为什么需要记忆系统

MemGPT 论文的出发点(摘要原文):

"LLMs are constrained by limited context windows, hindering their utility in tasks like extended conversations and document analysis."

Zep 论文则把矛头指向 RAG:

现有 RAG 框架 "limited to static document retrieval",而企业级/助手级场景要求从持续进行的对话和业务数据中动态整合知识。

两者合起来定义了这个问题域的三个子问题:

  1. 容量:上下文窗口装不下全部历史(对话越长越明显)。
  2. 持久化与个性化:跨 session 记住用户,"remember, reflect, and evolve dynamically through long-term interactions with their users"(MemGPT 摘要)。
  3. 时间性:事实会变(换工作、改偏好)。静态检索无法表达"X 在 3 月前为真、现在为假"。这是 Zep 强调的差异化维度。

2. 三个系统精读

2.1 MemGPT(论文)→ Letta(产品)

2.1.1 核心思想:操作系统隐喻

MemGPT 提出 virtual context management,"drawing inspiration from hierarchical memory systems in traditional operating systems"——OS 通过在快慢存储间搬运数据制造"大内存"的假象,MemGPT 对上下文窗口做同样的事,并用中断(interrupt)管理控制流。

2.1.2 内存层级(论文 §3)

Main context(= RAM,即 prompt tokens),"anything in main context is considered in-context and can be accessed by the LLM processor during inference",分三段:

段性质内容
System instructions只读、静态描述 "the MemGPT control flow, the intended usage of the different memory levels" 及函数用法
Working context固定大小的读写文本块,"writeable only via MemGPT function calls"对话场景存 "key facts, preferences, and other important information about the user"
FIFO queue滚动消息历史消息、系统消息、函数调用输入输出;队首是已被驱逐消息的递归摘要(recursive summary)

External context(= 磁盘),"any information that is held outside of the LLMs fixed context window",必须"explicitly moved into main context"才能被处理:

2.1.3 自编辑记忆:函数集与自主性

"Memory edits are entirely self-directed: MemGPT autonomously updates and searches through its own memory based on the current context."

关键函数:

2.1.4 内存压力与驱逐(OS 分页的对应物)

2.1.5 Heartbeat 与函数链

函数调用可带 request_heartbeat=true,输出回填 main context 后立即再次推理,实现多步操作(如翻页式多轮检索);不带该 flag 则 yield,等待下一个外部事件(用户消息、系统消息、定时事件)。这是 agent 能在一次用户输入内完成"检索→判断→再检索→回答"的机制基础。

2.1.6 实验结果(2023 论文)

DMR(Deep Memory Retrieval,多轮对话一致性):

模型基线准确率+MemGPT
GPT-3.5 Turbo38.7%66.9%
GPT-432.1%92.5%
GPT-4 Turbo35.3%93.4%

嵌套 KV 检索(最亮眼的结果):基线在 nesting level 1(GPT-3.5)或 3(GPT-4/4 Turbo)就掉到 0%,而 "MemGPT with GPT-4…is unaffected with the number of nesting levels",是 "the only approach that is able to consistently complete the nested KV task beyond 2 nesting levels"——因为它可以通过函数反复查 main context 里的 KV 对。

文档 QA:性能 "unaffected by increased context length"(对比截断类方法随压缩率上升而退化)。

Conversation opener:GPT-4+MemGPT 的开场白 SIM-1 得分 0.868,超过人工撰写的 0.800。

2.1.7 Letta:产品化演进(2024–2026)

MemGPT 作者创办 Letta,把论文系统做成 "Platform for stateful agents: AI with advanced memory that can learn and self-improve over time"(GitHub README,2026-10 抓取,25.3k stars,Apache-2.0)。

仓库现状(重要,2026-10 抓取):主仓库 letta-ai/letta 已变为指路页——"The current source code lives in letta-ai/letta-code"(含 agent harness、terminal UI、App Server、channels、runtime),V1 API server 归档在 archive 分支;安装方式变为 npm install -g @letta-ai/letta-code,支持 self-hosted App Server、chat.letta.com、Slack/Telegram/Discord 集成、TypeScript Agent SDK。这说明 Letta 在 2025–2026 从 Python 服务端框架转向了 "Letta Code" 形态(对标 Claude Code 一类产品),选型时需注意其架构仍在快速变化。

博客《Agent Memory》中的四层记忆分类:

  1. Message buffer:"the most recent messages in a conversation";
  2. Core memory:"in-context memory blocks that can be managed by the agent itself or by other agents";
  3. Recall memory:"the complete history of interactions that can be searched and retrieved when needed";
  4. Archival memory:"explicitly formulated knowledge stored in external databases"(向量或图数据库 + 专用检索工具)。

Memory blocks(文档定义):"structured sections of the agent's context window that persist across all interactions",四要素:label(唯一标识)、description("the main information used by the agent to determine how to read and write to that block")、value(内容)、limit(字符上限,示例常用 5000/4000)。默认 read-write,可设 read_only 防止 agent 破坏共享数据;多 agent 可挂同一个 block——"If multiple agents are attached to a block, they will all have the block data in their context windows",更新自动传播。注意两个坑:设置 block value 是整体替换而非 append;并发写是 last-write-wins。

Sleep-time compute:记忆管理作为 "non-blocking operations" 异步进行,空闲期做 "proactive memory refinement",产出 "higher quality memory blocks"。即:把"整理记忆"从对话关键路径上挪走——与 LangMem 的 background 形成、以及"睡眠巩固记忆"的神经科学隐喻殊途同归。

2.2 Zep / Graphiti:时序知识图谱记忆

2.2.1 定位与关系

2.2.2 Graphiti 三层子图

图 𝒢=(𝒩,ℰ,φ),三个层级:

  1. Episode subgraph:原始输入("messages, text, or JSON"),是 "non-lossy data store from which semantic entities and relations are extracted"。无损是关键卖点:episodic edges 让 "semantic artifacts can be traced to their sources for citation or quotation"(可溯源/可引用)。
  2. Semantic entity subgraph:实体节点("extracted from episodes and resolved with existing graph entities")+ 语义边(实体间关系/事实)。
  3. Community subgraph:社区节点代表 "clusters of strongly connected entities",含 "high-level summarizations of these clusters"。

设计明确对标认知心理学:"episodic memory, which represents distinct events, and semantic memory, which captures associations between concepts."

2.2.3 Bi-temporal 模型(全文最核心的架构决策)

两条时间线:

论文称 "this bi-temporal approach represents a novel advancement in LLM-based knowledge graph construction."

Edge invalidation(边作废):新信息与旧事实矛盾时,"employs an LLM to compare new edges against semantically related existing edges to identify potential contradictions";发现时间上重叠的矛盾,就把旧边的 t_invalid 设为新边的 t_valid——作废旧边而非删除,且 "consistently prioritizes new information"。效果:"maintaining both current relationship states and historical records":既能回答"用户现在住哪",也能回答"用户去年住哪"。Graphiti README 的表述:"Facts have validity windows. When information changes, old facts are invalidated — not deleted."

2.2.4 图构建流水线

  1. Ingestion:消息作为 episode 进入,带参考时间戳 t_ref(解析"昨天/下周五"等相对时间),处理当前消息 + 最近 4 条做上下文;
  2. Entity extraction:NER + 自动抽取说话人,用 "a reflection technique inspired by reflexion" 抑制幻觉,并生成实体摘要;
  3. Entity resolution(去重):实体名嵌入 1024 维向量,cosine + 全文双路召回候选,再由 LLM 判断是否同一实体;命中则 "it generates an updated name and summary";
  4. Fact extraction:抽取实体间事实(含 predicate);同一事实可挂多对实体,"an implementation of hyper-edges";
  5. Fact resolution:边去重的混合搜索 "constrained to edges existing between the same entity pairs",显著降复杂度;
  6. Temporal extraction:抽取绝对/相对时间,边上存全部四个时间字段;
  7. Community construction:用 label propagation(而非 GraphRAG 式 Leiden),因为 "straightforward dynamic extension"——新节点归入邻居中占多数的社区,定期全量刷新。

增量 vs 批处理是与 GraphRAG 的本质区别(README:"New data integrates immediately without batch recomputation";博客:Zep "maintains a rich temporal understanding of how information evolves over time")。

2.2.5 混合检索

f(α) = χ(ρ(φ(α))):三种搜索 × 五种重排 × 构造器。

—— 今日目标到此为止,后面是报告其余部分,可继续读也可以明天继续 ——

2.2.6 基准结果(论文,注意是厂商自评)

DMR(500 段多 session 对话,每段 5 session):

方法模型准确率
Recursive summarizationgpt-4-turbo35.3%
Conversation summariesgpt-4-turbo78.6%
MemGPT(论文报告值)gpt-4-turbo93.4%
Full-conversation(全塞上下文)gpt-4-turbo94.4%
Zepgpt-4-turbo94.8%
Full-conversationgpt-4o-mini98.0%
Zepgpt-4o-mini98.2%

作者自己承认 DMR 已过时:对话 "only 60 messages, easily fitting within current LLM context windows",问题都是 "single-turn, fact-retrieval questions"。博客进一步点破:给足全上下文,裸模型就能超过 MemGPT 当年报告分——这既是对 MemGPT 的批评,也是对 DMR 榜单的祛魅。

LongMemEval_s(平均 ~115k tokens 的长历史,更真实的时序推理基准):Zep 检索 top-20 边+实体,注入 ~1.6k tokens:

记忆模型准确率延迟平均上下文
Full-contextgpt-4o-mini55.4%31.3s115k
Zepgpt-4o-mini63.8%3.20s1.6k
Full-contextgpt-4o60.2%28.9s115k
Zepgpt-4o71.2%2.58s1.6k

即 +15.2%/+18.5% 准确率、约 -90% 延迟、<2% token(博客:"less than 2% of the baseline tokens")。分题型(gpt-4o):single-session-preference +184%、temporal-reasoning +38.4%、multi-session +30.7%;但 single-session-assistant -17.7%,作者承认 "suggest further research and engineering work is needed"。

与 MemGPT 的直接对比缺失:作者尝试在 LongMemEval 上跑 MemGPT 但 "were unable to achieve successful question responses",因为 MemGPT "does not support direct ingestion of existing message histories"。所以跨系统的公平横评实际上并不存在。

2.2.7 部署依赖(自托管 Graphiti 的真实成本)

README:Python 3.10+;图库 Neo4j 5.26 / FalkorDB 1.1.2 / Amazon Neptune / Kuzu(已弃用);默认 OpenAI API key(LLM + embedding),也支持 Anthropic/Gemini/Groq;"Works best with LLMs supporting Structured Output"。注意:每条 episode 的入库都要多次 LLM 调用(实体抽取、实体消解、事实抽取、时间抽取、矛盾判定),写入成本与延迟显著高于"存个向量"的方案——这是选型时最容易低估的一项。

2.3 LangMem:记忆作为 SDK 原语

2.3.1 定位

LangChain AI 出品的开源库(MIT,GitHub 显示活跃维护:154 commits / 56 open issues,无 deprecation banner,2026-10-27 抓取),"helps agents learn and adapt from their interactions over time"。它不是服务、不带数据库,而是 "both functional primitives you can use with any storage system and native integration with LangGraph's storage layer"——存储落在 LangGraph BaseStore(多级 namespace 如 ("acme_corp", "{user_id}", "code_assistant") 下的 JSON 文档),开发用 InMemoryStore("in process memory—they'll be lost on restart"),生产推荐 AsyncPostgresStore。"Available by default in all LangGraph Platform deployments."

2.3.2 记忆类型学(概念指南,借鉴认知科学三分法)

类型定义(原文)形态
Semantic(语义)"essential facts and other information that ground an agent's responses"collections(无界记录集,运行时检索)或 profiles("a single document that represents the current state",schema 约束,原位更新)
Episodic(情景)"the full context of an interaction—the situation, the thought process that led to success, and why that approach worked"作为 few-shot 示例指导未来行为(成功交互经验)
Procedural(程序性)"how an agent should behave and respond"系统提示词本身,随反馈持续演化

Profile vs collection 的取舍:只要最新状态 → profile(单一文档原位改);需要保留多条并做冲突调和 → collection("reconciliation of new information with existing beliefs")。

2.3.3 记忆形成的两条路径

Memory manager 的职责:"reconcile new information with previous beliefs, either deleting/invalidating or updating/consolidating existing memories",通过 "memory enrichment process" 平衡新增与合并,指令可由开发者定制。

2.3.4 关键 API

2.3.5 没有的东西(同样重要)


3. 架构对比总表

维度MemGPT / LettaZep / GraphitiLangMem
记忆表示分层文本:working context / memory blocks(in-context)+ recall(消息库)+ archival(向量库)三层子图时序知识图谱(episode 无损层 / 实体-事实层 / 社区层),边带 4 个时间字段namespace 化 JSON 文档(facts / episodes / profile)+ 系统提示词
写入机制agent 自主调函数自编辑("entirely self-directed"),memory pressure 警告触发主动保存系统流水线自动:抽取→消解→时间标注→矛盾检测→边作废,人/agent 不参与双模可配:hot path 工具(agent 写)或 background manager(自动提取合并)
检索机制agent 自主搜索(archival/conversation search)+ 常驻 in-context 直读;heartbeat 支持多步检索混合搜索(cosine + BM25 + 图 BFS)× 5 种重排(RRF/MMR/提及频率/节点距离/cross-encoder)BaseStore 语义搜索 + 元数据过滤 + 直接读取
时间性无显式时间模型;靠递归摘要和文本一等公民:bi-temporal(事件时间 × 事务时间),事实有有效期,作废不删除无内置;靠更新覆盖,需自行加 metadata
可溯源性block 人可读;recall 可全文搜最强:任何实体/事实可回溯到源 episode,"traced to their sources for citation"文档可读,来源需自己存
多 agent 共享原生:同一 block 挂多个 agent,更新自动传播图天然共享(按 group_id 隔离)namespace 天然共享
离线整理sleep-time agents(空闲期主动精炼记忆块)增量入图即整理;社区定期重算background reflection(异步提取合并)
基础设施Letta server(App Server)+ Postgres/pgvectorNeo4j 5.26 / FalkorDB / Neptune + LLM & embedding API纯库 + InMemory/Postgres store
写入成本低(函数调用 + 摘要)高(每 episode 多次 LLM 调用)中(提取/合并各一次 LLM 调用,可挪到后台)
读取成本取决于 agent 检索轮数(多步函数调用往返)低且稳:top-k 注入 ~1.6k tokens,延迟 ~2.6-3.2s(LongMemEval 实测)低(向量搜索 + 直读)
形态开源平台 + 云(2026 已转向 letta-code)开源框架 Graphiti + Zep Cloud 企业服务开源 SDK(MIT)
基准证据DMR 93.4%(GPT-4 Turbo,2023);嵌套 KV 检索唯一 >2 层DMR 94.8%/98.2%;LongMemEval +18.5% / -90% 延迟(厂商自评)无公开基准
LicenseApache-2.0Apache-2.0(Graphiti)MIT
社区规模(2026-10)25.3k stars32.3k stars(Graphiti)较小(154 commits)

三条路线的本质分歧:谁负责管理记忆


4. 证据质量评估(精读者注)

  1. Zep 的数据是厂商自评(论文作者全部来自 Zep 公司),且 DMR 上 MemGPT 用的是对方论文报告值而非复现值;LongMemEval 上 MemGPT 根本没跑起来("unable to achieve successful question responses"),横评缺失。数字方向可信(+18.5%、-90% 延迟的量级与"1.6k vs 115k tokens"的机制自洽),但"超过 MemGPT"的表述要打折扣。
  2. MemGPT 论文是 2023 年的,DMR 93.4% 在当时惊艳,但 Zep 论文显示:2024 年后给足全上下文的裸模型就有 94.4%(gpt-4-turbo)/98.0%(gpt-4o-mini)。DMR 作为基准已失效,这恰说明记忆系统的价值主张必须转向:长上下文吃不下/吃不划算的场景(115k+ tokens、成本、延迟)与时间推理。
  3. Zep 自己的回归项:single-session-assistant 题型 -17.7%——图谱记忆在"用户问助手刚说过的话"这类近距离场景反而不如全上下文,提示图检索不是万能的,近距离对话仍需消息缓冲兜底。
  4. LangMem 零基准:效果完全取决于开发者写的提取/合并 prompt 和 schema,无法先验判断上限。
  5. Letta 主仓库已迁移到 letta-code、V1 server 归档——产品形态剧烈变动中,评估 Letta 时文档/教程的时效性风险高。

5. 个人助手项目选型建议

5.1 先把需求拆开

个人助手(personal assistant)场景的记忆需求画像:

需求例子对应记忆类型
长期用户画像姓名、职业、饮食禁忌、沟通偏好semantic / profile
事实的时间演化"用户 3 月换了工作"→ 现在问职业要答新的,问"去年在哪上班"要答旧的bi-temporal(Zep 独有)
事件史"上周我们讨论过的那个方案"episodic / recall
行为适应助手逐渐学会"回答要先给结论"procedural(LangMem 独有)/ Letta persona block
成本与延迟敏感个人项目,高频短对话,token 要省读取端注入量小者优(Zep 1.6k tokens)
数据主权全是个隐私数据自托管优先
单人维护运维精力有限依赖越少越好

5.2 四条路径

路径 A:LangMem(已在/愿意进 LangGraph 生态,想快速起步)

路径 B:Graphiti 自托管(把记忆当核心资产认真做)——对"时间正确性"要求高时的首选

路径 C:Letta(不想自己搭 agent loop,要 runtime + 记忆一体)

路径 D:Zep Cloud(Graphiti 的托管版)

5.3 我的推荐

默认推荐:路径 B(Graphiti 自托管)作为记忆层 + 自备轻量 agent loop;若已在 LangGraph 生态则先 A 后 B。 理由:

  1. 个人助手的记忆难点排序是:时间正确性 > 长期容量 > 检索精度。容量问题在 2026 年已被长上下文大幅缓解(Zep 论文自己承认 60 条消息的 DMR 场景全上下文就能打),而"用户三个月前说的偏好现在改了"这类问题,全上下文和向量检索都给不出正确答案,只有 bi-temporal 图能。
  2. Graphiti 是 Apache-2.0 纯框架,不绑定 agent 框架——你可以用 LangGraph、裸 SDK 或任何 loop 调它,迁移成本远低于 Letta。
  3. 写放大问题可以工程化解决(异步入图 + 小模型抽取),而"没有时序模型"这个问题在 LangMem/Letta 上无法工程化补全——要补就等于自己重写一个简化版 Graphiti。
  4. 混合架构是可行且值得的:近期对话用消息缓冲(覆盖 Zep 回归的 single-session-assistant 场景),中长期记忆走 Graphiti 图检索;若同时用 LangGraph,可保留 LangMem 的 prompt optimizer 做程序性记忆——三者职责不冲突。
  5. 无论选哪条,借鉴 sleep-time compute:把记忆整理(合并、作废、摘要)放到空闲时段异步跑,别占对话关键路径。

5.4 决策树(速查)

需要"事实随时间演化且可回溯"?
├─ 是 → 自托管意愿 + 运维能力?
│        ├─ 有 → Graphiti + Neo4j/FalkorDB(路径 B)
│        └─ 无 → Zep Cloud(路径 D,付费换运维)
└─ 否 → 已在 LangGraph 生态?
         ├─ 是 → LangMem 起步(路径 A),需求升级再迁 Graphiti
         └─ 否 → 想连 agent runtime 一起外包?
                  ├─ 是 → Letta(路径 C,注意 letta-code 迁移期风险)
                  └─ 否 → LangMem / 自建 blocks + 向量库(借鉴 Letta 的 block 设计)

6. 七维度提取(主题层面)

6.1 核心问题

如何让 LLM agent 在有限上下文窗口下拥有持久、可演化、可高效检索的记忆,支撑跨 session 的长期交互(扩展对话、个性化助手、动态知识整合)。

6.2 主要主张

6.3 方法

6.4 数据与证据

6.5 结论

三条路线各自成立且不完全互斥:Letta = 记忆内建于 agent 运行时(agent 自管),Zep/Graphiti = 记忆外置为时序图谱服务(管线自管),LangMem = 记忆拆为可组合原语(开发者编排)。对时间敏感、长期陪伴型的个人助手,Graphiti 类时序图谱是当前架构上最完备的答案;对快速起步和生态内用户,LangMem 够用;Letta 适合接受全家桶的场景。近期对话仍需消息缓冲兜底,纯图检索在近距离问答上有实测回归。

6.6 局限

6.7 对我的启发

  1. OS 隐喻是可迁移的设计模式:memory pressure 警告(让模型在驱逐前主动保存)和 heartbeat 函数链,是任何自研 agent loop 都可以低成本复刻的机制。
  2. "作废不删除"应成为个人助手记忆的默认语义:bi-temporal 的四字段(valid/invalid × created/expired)值得在任何自研记忆 schema 里预留,哪怕先用 SQLite/Postgres 简化实现。
  3. 写入路径与读取路径的成本要分开算:Zep 证明"写贵读贱"在助手场景是划算的(高频短对话读、异步慢慢写);sleep-time/background 整理是三家共识,异步化记忆巩固应作为默认架构决策。
  4. profile 与 collection 是两种画像范式:单一 profile 文档(LangMem/Letta block)适合"当前状态",collection/图适合"历史与证据";成熟系统多半两者都要(块给人看/给 agent 常驻,图给检索)。
  5. 警惕基准营销:DMR 的兴衰(2023 年 93.4% 惊艳 → 2024 年裸模型 94.4%)提醒我,评估记忆系统要看它在"长上下文吃不下"的场景(LongMemEval 类)与时间推理上的表现,而不是排行榜数字。
  6. 程序性记忆是被低估的通道:LangMem 的 prompt optimizer 把"agent 行为改进"也纳入记忆体系——个人助手长期陪伴中,"学会怎么跟你说话"可能比"记住你说过什么"更提升体验。

7. 关键原文引述辑录

MemGPT 论文(arXiv:2310.08560)

"virtual context management, a technique drawing inspiration from hierarchical memory systems in traditional operating systems"
"Memory edits are entirely self-directed: MemGPT autonomously updates and searches through its own memory based on the current context."
Working context: "A fixed-size read/write block of unstructured text, writeable only via MemGPT function calls."
"MemGPT with GPT-4…is unaffected with the number of nesting levels and is able to perform the nested lookup by accessing the key-value pairs stored in main context repeatedly via function queries."

Letta(GitHub / 博客 / 文档)

"Platform for stateful agents: AI with advanced memory that can learn and self-improve over time."
Core memory: "in-context memory blocks that can be managed by the agent itself or by other agents."
Memory blocks: "structured sections of the agent's context window that persist across all interactions."
"If multiple agents are attached to a block, they will all have the block data in their context windows."
Sleep-time compute: "proactive memory refinement" producing "higher quality memory blocks."
"The current source code lives in letta-ai/letta-code"(主仓库 README,2026-10)

Zep 论文(arXiv:2501.13956)

"a novel memory layer service for AI agents";Graphiti: "a temporally-aware knowledge graph engine"
Episode subgraph 是 "non-lossy data store from which semantic entities and relations are extracted";"semantic artifacts can be traced to their sources for citation or quotation."
"bi-temporal approach represents a novel advancement in LLM-based knowledge graph construction."
Edge invalidation: "employs an LLM to compare new edges against semantically related existing edges to identify potential contradictions";"consistently prioritizes new information."
DMR 局限:conversations "only 60 messages, easily fitting within current LLM context windows."
回归项:single-session-assistant 下降 "suggest further research and engineering work is needed."
MemGPT 对比缺失:"were unable to achieve successful question responses",因 MemGPT "does not support direct ingestion of existing message histories."

Zep 博客 / Graphiti README

Graphiti: "an open source library that builds dynamic, temporally-aware knowledge graphs";"Zep is the unified context layer for enterprises","Graphiti is the graph construction framework inside Zep."
"Facts have validity windows. When information changes, old facts are invalidated — not deleted."
"Combines semantic embeddings, keyword (BM25), and graph traversal for low-latency, high-precision queries."
"New data integrates immediately without batch recomputation."(vs GraphRAG 批处理)
LongMemEval: "aggregate accuracy improvements of up to 18.5%","less than 2% of the baseline tokens."

LangMem(文档 / 概念指南 / GitHub)

"helps agents learn and adapt from their interactions over time."
Semantic memory: "essential facts and other information that ground an agent's responses."
Episodic memory: "the full context of an interaction—the situation, the thought process that led to success, and why that approach worked."
Procedural memory: "how an agent should behave and respond."
Profile: "a single document that represents the current state."
Hot path: "immediate updates when critical context emerges";Background: "deeper pattern analysis without impacting response time."
Memory manager 职责:"reconcile new information with previous beliefs, either deleting/invalidating or updating/consolidating existing memories."
"both functional primitives you can use with any storage system and native integration with LangGraph's storage layer."

8. 参考链接汇总

  1. MemGPT 论文:https://arxiv.org/abs/2310.08560 (全文:https://arxiv.org/html/2310.08560v2)
  2. Letta GitHub:https://github.com/letta-ai/letta (主代码已迁至 letta-ai/letta-code)
  3. Letta 博客《Agent Memory》:https://www.letta.com/blog/agent-memory
  4. Letta 文档 memory blocks:https://docs.letta.com/v1-sdk/memory/memory-blocks/
  5. Zep 论文:https://arxiv.org/abs/2501.13956 (全文:https://arxiv.org/html/2501.13956v1)
  6. Zep 博客《State-of-the-Art Agent Memory》:https://www.getzep.com/blog/state-of-the-art-agent-memory/
  7. Graphiti GitHub:https://github.com/getzep/graphiti
  8. LangMem 文档:https://langchain-ai.github.io/langmem/ (概念指南:https://langchain-ai.github.io/langmem/concepts/conceptual_guide/)
  9. LangMem GitHub:https://github.com/langchain-ai/langmem

思考题(读完后想一想,参考答案可展开)

  1. 为什么说“事实作废而不删除”是 Zep/Graphiti 最核心的架构决策?它解决了什么别的方案解决不了的问题?
    参考答案

    因为它用双时间轴——事件时间 t_valid/t_invalid 与事务时间 t'_created/t'_expired——把“事实何时为真”与“何时进入系统”分开记录。新信息与旧边矛盾时只把旧边 t_invalid 设为新边 t_valid,不删除,同时保留当前状态与历史:既能答“用户现在住哪”,也能答“去年住哪”。这是静态 RAG 与向量检索无法表达的,也是时间性成为分水岭的原因。

  2. 三个系统在“谁负责管理记忆”上分歧何在?各自付出的代价是什么?
    参考答案

    Letta 让 agent 自调函数自编辑记忆,灵活有元认知,但质量强依赖底模 function calling,小模型易写坏漏写,检索轮数不可控、延迟方差大。Zep 由管线自动抽取、消解、判矛盾、作废旧边,写入稳、读取快而省,代价是每条 episode 多次 LLM 调用的写放大,且检索是被动注入而非自主探索。LangMem 只给原语由开发者编排,轻、可组合,但一切自建、无时间模型、无基准背书。

  3. 这篇笔记对 Zep 论文数据的可信度打了哪些折扣?对评估记忆系统有何方法论启示?
    参考答案

    三点:作者全属 Zep,属厂商自评;DMR 上 MemGPT 取对方报告值而非复现值,LongMemEval 上 MemGPT 因不支持导入历史未能作答,横评缺失。且 DMR 已失效:60 条消息全上下文即达 94.4%/98.0%,超过 MemGPT 当年 93.4%。另:回归项 single-session-assistant 降 17.7%。故选型看长上下文装不下场景与时间推理,不看排行榜。

  4. 对个人助手项目,作者的默认推荐是什么?理由何在,又该如何规避所选方案的短板?
    参考答案

    默认推荐 Graphiti 自托管,配轻量 agent loop;在 LangGraph 生态则先 LangMem。理由:排序为时间正确性 > 长期容量 > 检索精度——容量已被长上下文缓解,“三月前的偏好现已改”只有 bi-temporal 图能答;且它是 Apache-2.0 纯框架、不绑 agent 框架,迁移成本低于 Letta。工程上异步入图、小模型抽取压写放大,近期对话用消息缓冲兜底。

← 2026-11-05完整条目页