项目: letta-ai/letta | Stars: 24.6K | License: Apache 2.0
定位: 有状态 AI Agent 平台——具有高级记忆系统,能够随时间学习和自我改进
前身: MemGPT(UC Berkeley BAIR 实验室研究成果)
当前状态: V1 服务器代码归档于此仓库 archive 分支,新代码已迁移至 letta-ai/letta-code
1. 整体架构哲学:LLM 即操作系统
Letta 的核心理念源自 MemGPT 论文——将 LLM 视为操作系统的内核,Agent 就是运行在这个操作系统上的进程。系统采用分层记忆架构,灵感来自计算机体系结构中的虚拟内存管理:
- 核心记忆(Core Memory) → 寄存器/L1 缓存:始终在上下文窗口内
- 对话记忆(Recall Memory) → RAM:可搜索的历史对话
- 归档记忆(Archival Memory) → 磁盘:长期向量存储
- 文件系统(Filesystem) → 外部存储:Git 版本化的文件
class ContextWindowOverview(BaseModel):
"""Overview of the context window, including the number of messages and tokens."""
context_window_size_max: int = Field(..., description="The maximum amount of tokens the context window can hold.")
context_window_size_current: int = Field(..., description="The current number of tokens in the context window.")
num_messages: int = Field(..., description="The number of messages in the context window.")
num_archival_memory: int = Field(..., description="The number of messages in the archival memory.")
num_recall_memory: int = Field(..., description="The number of messages in the recall memory.")
num_tokens_external_memory_summary: int = Field(..., description="The number of tokens in the external memory summary.")
num_tokens_system: int = Field(..., description="The number of tokens in the system prompt.")
num_tokens_core_memory: int = Field(..., description="The number of tokens in the core memory.")
num_tokens_memory_filesystem: int = Field(0, description="The number of tokens in the memory filesystem section.")
num_tokens_summary_memory: int = Field(..., description="The number of tokens in the summary memory.")
num_tokens_functions_definitions: int = Field(..., description="The number of tokens in the functions definitions.")
这个 ContextWindowOverview 精确追踪上下文窗口中每个组成部分的 token 消耗,类似于操作系统的内存使用报告。
2. Agent 类型体系:多形态 Agent 设计
Letta 定义了丰富的 Agent 类型枚举,每种类型对应不同的运行时行为和工具集:
(更多…)