MemGPT/Letta 记忆与上下文管理深度解析

本文档整理自 Letta 官方文档、研究论文及 GitHub 仓库 原项目:MemGPT → 现名 Letta 论文:arXiv:2310.08560 📌 项目概览 什么是 MemGPT/Letta? MemGPT(Memory-GPT)是一个创新的 LLM 记忆管理系统,现更名为 Letta。它由 UC Berkeley 的研究团队开发,旨在解决大语言模型的上下文窗口限制问题。 核心理念: “Teaching LLMs to manage their own memory for unbounded context” 让 LLM 学会管理自己的记忆,实现无限上下文 GitHub 数据: ⭐ 21.2k stars 🍴 2.2k forks 👥 158 位贡献者 🧠 核心问题:上下文窗口限制 现有 LLM 的痛点 有限上下文窗口 GPT-4: 128K tokens Claude: 200K tokens 长文档、多轮对话容易溢出 无法持久化记忆 每次对话都是"从头开始" 无法记住用户偏好、历史交互 无法进行长期学习 不能从交互中积累知识 无法自我改进 🎯 解决方案:虚拟上下文管理 核心创新:操作系统启发 MemGPT 借鉴了传统操作系统的虚拟内存机制: ...

February 22, 2026 · 3 min · 599 words · Robert

Agent Infra 深度调研:Memory管理层次与架构设计

执行摘要 本报告对Agent Infrastructure(Agent基础设施)领域进行了系统性深度调研,重点关注Memory管理层次模型。通过对LangChain、LangGraph、LangSmith、Zep、MemGPT等主流技术的分析,揭示了Agent Memory从简单会话存储到复杂知识图谱演进的技术脉络。 1. Agent Infra 分层架构 1.1 Agent执行动态追踪(Trace)层 LangSmith 是LangChain团队推出的LLM应用可观测性平台,截至2025年已处理超过10亿条Trace。 核心架构: Frontend (UI) + Backend API + SDK (Python/TypeScript) ↓ ClickHouse (Trace存储) + PostgreSQL (元数据) + Redis (缓存) 定价模式: Developer计划:免费,5,000 traces/月 Plus计划:$39/月/席位 Enterprise计划:支持私有化部署 1.2 Agent Context管理层 Context生命周期: 创建(Creation) → 传递(Transfer) → 更新(Update) → 销毁(Dispose) │ │ │ │ 初始化状态 节点间流转 Reducer合并 会话结束 LangGraph中的Context管理: class AgentState(TypedDict): messages: Annotated[list, add_messages] documents: list[str] counter: Annotated[int, add] 2. Memory管理深度分析(重点) 2.1 Memory层次模型 基于认知科学和计算机体系结构的启发,Agent Memory采用分层架构: ┌─────────────────────────────────────────────────────────┐ │ Working Memory (工作记忆) │ │ Context Window / Active Reasoning │ │ ~4K-128K tokens │ │ ▲ │ │ │ 实时访问 │ ├───────────────────┼─────────────────────────────────────┤ │ ▼ │ │ Short-term Memory (短期记忆) │ │ Session History / Conversation Buffer │ │ ~10-100 messages │ │ ▲ │ │ │ 快速检索 │ ├───────────────────┼─────────────────────────────────────┤ │ ▼ │ │ Long-term Memory (长期记忆) │ │ ┌───────────────┬───────────────┐ │ │ │ Fixed Attr │ Fuzzy Vector │ │ │ │ Memory │ Memory │ │ │ │ (用户画像) │ (Embedding) │ │ │ └───────────────┴───────────────┘ │ └─────────────────────────────────────────────────────────┘ 2.2 短期记忆(Short-term Memory) 工作记忆(Working Memory): ...

February 22, 2026 · 3 min · 586 words · Robert