[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"pack-detail-agent-memory-layer-zh":3,"seo:pack:agent-memory-layer:zh":78},{"code":4,"message":5,"data":6},200,"操作成功",{"pack":7},{"slug":8,"icon":9,"tone":10,"status":11,"status_label":12,"title":13,"description":14,"items":15,"install_cmd":77},"agent-memory-layer","🧠","#F59E0B","stable","稳定","Agent 记忆层","Mem0 \u002F Zep \u002F Cognee 三家 + 跨会话记忆设计模式 — 不再把所有东西塞 prompt。",[16,28,38,45,52,60,70],{"id":17,"uuid":18,"slug":19,"title":20,"description":21,"author_name":22,"view_count":23,"vote_count":24,"lang_type":25,"type":26,"type_label":27},703,"96da1f40-1823-4d87-a84f-7d8269edeb24","mem0-memory-layer-ai-applications-96da1f40","Mem0 — Memory Layer for AI Applications","Add persistent, personalized memory to AI agents and assistants. Mem0 stores user preferences, past interactions, and learned context across sessions.","Mem0",916,0,"en","skill","Skill",{"id":29,"uuid":30,"slug":31,"title":32,"description":33,"author_name":34,"view_count":35,"vote_count":24,"lang_type":25,"type":36,"type_label":37},852,"a3fe5165-33ca-11f1-9bc6-00163e2b0d79","codebase-memory-mcp-code-intelligence-ai-agents-a3fe5165","Codebase Memory MCP — Code Intelligence for AI Agents","High-performance code intelligence MCP server. Indexes repos in milliseconds via tree-sitter AST, supports 66 languages, sub-ms graph queries. MIT, 1,300+ stars.","MCP Hub",340,"mcp","MCP",{"id":39,"uuid":40,"slug":41,"title":42,"description":43,"author_name":34,"view_count":44,"vote_count":24,"lang_type":25,"type":36,"type_label":37},715,"554c4dc2-663c-489a-b57f-814948e9f714","memory-mcp-persistent-ai-agent-knowledge-graph-554c4dc2","Memory MCP — Persistent AI Agent Knowledge Graph","MCP server that gives AI agents persistent memory using a local knowledge graph. Stores entities, relationships, and observations across sessions for Claude Code.",295,{"id":46,"uuid":47,"slug":48,"title":49,"description":50,"author_name":34,"view_count":51,"vote_count":24,"lang_type":25,"type":26,"type_label":27},743,"ffde39a9-bd16-4c41-8168-aacfb05b7622","zep-long-term-memory-ai-agents-assistants-ffde39a9","Zep — Long-Term Memory for AI Agents and Assistants","Production memory layer for AI assistants. Zep stores conversation history, extracts facts, builds knowledge graphs, and provides temporal-aware retrieval for LLMs.",309,{"id":53,"uuid":54,"slug":55,"title":56,"description":57,"author_name":58,"view_count":59,"vote_count":24,"lang_type":25,"type":26,"type_label":27},334,"b6ad223f-51da-4179-863c-5f9b3c7d08ef","cognee-memory-engine-ai-agents-b6ad223f","Cognee — Memory Engine for AI Agents","Cognee adds persistent structured memory to any AI agent in 6 lines of code. 14.8K+ stars. Knowledge graphs, vector stores, LLM integration. Apache 2.0.","Skill Factory",224,{"id":61,"uuid":62,"slug":63,"title":64,"description":65,"author_name":66,"view_count":67,"vote_count":24,"lang_type":25,"type":68,"type_label":69},829,"b52189f9-e04a-4425-89db-e16fa7e81eec","ai-agent-memory-patterns-build-agents-remember-b52189f9","AI Agent Memory Patterns — Build Agents That Remember","Design patterns for adding persistent memory to AI agents. Covers conversation memory, entity extraction, knowledge graphs, tiered memory, and memory management strategies.","Agent Toolkit",328,"prompt","Prompt",{"id":71,"uuid":72,"slug":73,"title":74,"description":75,"author_name":22,"view_count":76,"vote_count":24,"lang_type":25,"type":26,"type_label":27},402,"b61fca8c-edd9-4ffa-bdc3-f21ce6715af9","mem0-memory-layer-ai-agents-b61fca8c","Mem0 — Memory Layer for AI Agents","Add persistent, personalized memory to any AI agent. Learns user preferences, adapts context, reduces tokens. 51K+ stars, used by 100K+ devs.",416,"tokrepo install pack\u002Fagent-memory-layer",{"pageType":79,"pageKey":8,"locale":80,"title":81,"metaDescription":82,"h1":13,"tldr":83,"bodyMarkdown":84,"faq":85,"schema":101,"internalLinks":111,"citations":124,"wordCount":137,"generatedAt":138},"pack","zh","Agent 记忆层：Mem0 \u002F Zep \u002F Cognee 七件套","Mem0 \u002F Zep \u002F Cognee —— agent 跨会话记忆方案 + 四个实现模式。再也不用把所有东西塞 prompt。TokRepo 一条命令装齐。","三个生产级记忆库（Mem0 \u002F Zep \u002F Cognee）+ 四个能让你不再把所有上下文塞 prompt 的模式。TokRepo 一条命令装好。","## 这个 pack 装了什么\n\n这个 pack 收齐了**七个记忆层资产**，是任何需要跨会话记住东西、不想每次都把所有上下文重新粘进 prompt 的 agent 必备组合。三个是头部库。四个是 Anthropic 和 OpenAI 在长任务 agent 指南里都提到的模式模板。\n\n| # | 资产 | 类型 | 给你什么 |\n|---|---|---|---|\n| 1 | Mem0 | 库 | 自动抽取并更新用户事实，开箱即用 API |\n| 2 | Zep | 服务 | 时序知识图谱，长期记忆 |\n| 3 | Cognee | 库 | 图 + 向量混合记忆管道 |\n| 4 | 情节摘要模式 | 模板 | 把长会话压缩成摘要记忆 |\n| 5 | 工作记忆草稿板 | 模板 | 不让 prompt 膨胀的步骤间状态 |\n| 6 | 用户事实抽取器 | 模板 | 从对话里抽出稳定事实存入 memory |\n| 7 | 跨会话回忆 | 模板 | 「上周我们定了什么？」模式 |\n\n## 为什么要装\n\nClaude \u002F GPT-4 \u002F Gemini 默认设置零记忆。每次对话都从头开始。多数应用靠把历史轮次塞进 system prompt 来假装记忆 —— 短期能用，过段时间 context window 爆掉、账单翻三倍、模型还跑题。记忆层把事实存到 prompt 之外，每轮只注入相关的。\n\n三个库各下了不同的赌注：\n\n- **Mem0** 最简单。一句 `mem0.add(messages, user_id=...)`，库自动抽取值得记的东西。聊天机器人型应用最适合。\n- **Zep** 是生产选项。跑成服务，给你时序知识图谱（带时间戳和关系的记忆），支持多租户。需要审计或组织内共享记忆时最佳。\n- **Cognee** 是图原生那派。从第一天就把记忆建模成知识图谱 —— 调研、代码、强实体关系的领域用得上。\n\n四个模式不是库，是 prompt 模板和小适配器，三个库都能搭配用。它们就是「我装了 Mem0」和「我应用里记忆真在工作」的区别。\n\n## 一条命令装齐\n\n```bash\n# 装整个 pack\ntokrepo install pack\u002Fagent-memory-layer\n\n# 或者一个一个装库\ntokrepo install mem0\ntokrepo install zep\ntokrepo install cognee\n```\n\nTokRepo CLI 把文件放对位置：Claude Code subagent 进 `.claude\u002Fagents\u002F`，Cursor 规则进 `.cursor\u002Frules\u002F`，Codex CLI 进 AGENTS.md。库本身用 pip \u002F npm 装 —— TokRepo 只是把它们接进你 AI 工具的配置，让 agent 知道记忆层存在。\n\n## 常见坑\n\n- **别什么都存**。记忆成本随写入量涨，不随检索量涨。用事实抽取器（模式 6）过滤 —— 只有用户 \u002F 项目的稳定事实值得进长期记忆。\n- **别忘记近期偏置**。纯向量召回会拉到语义相似但陈旧的记忆。Zep 的时序图和 Mem0 的就地更新都解决这个；自己写的话务必按时效加权，否则一直检索半年前的上下文。\n- **别跨租户共用 user ID**。三个库都支持按用户分命名空间，必须用。用户间记忆泄漏比完全没记忆糟得多。\n- **召回步骤要做 token 预算**。即使有记忆层，把 `top_k=50` 你照样能爆 context。从 `top_k=5` 起步，有遗漏再调大。\n- **冲突要协调**。用户三月说「我吃素」、五月说「我纯素」时，得有更新策略。Mem0 自动处理；Zep 把冲突暴露给你；Cognee 留给你自己写。\n\n## 常见误解\n\n**「RAG 和记忆是一回事」**。不是。RAG 从静态语料（文档、代码库）检索。记忆基于用户 \u002F agent 说的话写新条目，之后再检索。RAG 只读，记忆读写。pack\u002Frag-pipelines 的模式跟这个 pack 故意不同。\n\n**「我用对话历史就够了」**。5 轮会话内可以。同一个用户下周还会回来的应用就不行 —— 你得把所有历史轮次永远塞进 prompt。记忆把事实抽出来、把对话丢掉。\n\n**「Mem0 vs Zep 是个艰难选择」**。多数团队先用 Mem0 因为 5 分钟搭好，需要多租户或审计时再升级 Zep。两者足够相似，迁移是个周末的活，不是一个季度的项目。",[86,89,92,95,98],{"q":87,"a":88},"Mem0 免费吗？","Mem0 OSS 库是 MIT 许可，自托管免费。他们也有按使用量计费的托管云方案，省得自己跑嵌入 \u002F 向量存储。Zep 是同样的 OSS + 云模式。Cognee 截至 2026 年中是完全开源、无托管选项 —— 自己跑。",{"q":90,"a":91},"Cursor \u002F Codex CLI \u002F Windsurf 能用吗？","库是语言级（Python \u002F Node），所以任何 agent 框架都能用，不只是 Claude Code。TokRepo CLI 给每个 AI 工具装对应配置文件。Codex CLI 用户把记忆层和 AGENTS.md 指令搭配；Cursor 用户嵌进规则集。",{"q":93,"a":94},"Mem0 跟 Zep 怎么选？","Mem0 是库优先 —— import 进来调 .add() \u002F .search() 即可。Zep 是服务优先 —— 跑一个 server（Docker）拥有图，你的 app 调 API。Mem0 出第一条记忆最快；Zep 在多租户、审计、显式关系建模上赢。原型用 Mem0，有运维了上 Zep。",{"q":96,"a":97},"跟 RAG 流水线 pack 有啥区别？","RAG 从固定语料（你的文档、代码库）检索。记忆在 agent 跑的过程中写新事实之后再检索。RAG 只读、记忆读写还累积。多数生产 agent 都需要：RAG 管静态知识、记忆管用户特定的东西。",{"q":99,"a":100},"什么时候*不*该上记忆层？","会话无状态又短的时候 —— 单次任务比如「总结这个 PDF」从记忆获益不到，反而增加延迟。纯事实查询也跳过（用 RAG）。记忆层值回成本的场景是：同一个用户会回来、agent 多步、或两者都有。",{"@context":102,"@type":103,"name":104,"description":105,"numberOfItems":106,"publisher":107},"https:\u002F\u002Fschema.org","CollectionPage","Memory Layer for Agents","Mem0, Zep, Cognee, and the patterns to make agents remember across sessions.",7,{"@type":108,"name":109,"url":110},"Organization","TokRepo","https:\u002F\u002Ftokrepo.com",[112,116,120],{"url":113,"anchor":114,"reason":115},"\u002Fzh\u002Fpacks\u002Frag-pipelines","RAG 流水线","记忆与检索是姐妹问题",{"url":117,"anchor":118,"reason":119},"\u002Fzh\u002Fpacks\u002Fmulti-agent-frameworks","多 Agent 框架","多 agent 共享记忆",{"url":121,"anchor":122,"reason":123},"\u002Fzh\u002Ftools\u002Fclaude-code","Claude Code","这些记忆适配器的主要宿主",[125,129,133],{"claim":126,"source_name":127,"source_url":128},"Mem0 is an open-source memory layer for LLMs that auto-extracts and updates user-specific facts","mem0ai\u002Fmem0 on GitHub","https:\u002F\u002Fgithub.com\u002Fmem0ai\u002Fmem0",{"claim":130,"source_name":131,"source_url":132},"Zep is a long-term memory service with temporal knowledge graphs","getzep\u002Fzep on GitHub","https:\u002F\u002Fgithub.com\u002Fgetzep\u002Fzep",{"claim":134,"source_name":135,"source_url":136},"Cognee builds memory pipelines for AI applications using graph + vector hybrid stores","topoteretes\u002Fcognee on GitHub","https:\u002F\u002Fgithub.com\u002Ftopoteretes\u002Fcognee",539,"2026-05-02T15:00:00Z"]