跳转到内容

Agent Memory第 1 篇,共 2 篇

认识 agent memory

模型只读得到上下文窗口,agent 经历过的事一离开窗口,就影响不了后面的行为。各家都在做记忆,划的范围却不同,分歧集中在三个问题上:外部资料算不算,窗口里的内容算不算,模型里的知识算不算。三个问题分别牵涉 RAG、上下文和 LLM memory,把它们和 agent memory 分开,答案就清楚了:只有记录 agent 自己经历、存在模型和窗口之外、跨会话保留的那部分才是 agent memory。按这个划分去看一个记忆系统:来源是以往的经历,用途是保存事实和积累经验,形式是显式记录,操作分形成、演化、检索三步

更新于 阅读约 39 分钟

模型每次调用只读得到一段有限的输入,也就是上下文窗口(context window)。agent 经历过的事,包括用户说过的话、它做过的尝试、得到的结论,只要不在这一次的窗口里,就影响不了这一次的行为。MemGPT 把窗口里的内容叫 main context,窗口外的一切叫 external context,并指出后者必须被显式移进前者,模型推理时才用得到11 Packer 等 MemGPT: Towards LLMs as Operating Systems. 2023.原文:“MemGPT’s OS-inspired multi-level memory architecture delineates between two primary memory types: main context (analogous to main memory/physical memory/RAM) and external context (analogous to disk memory/disk storage).” “This out-of-context data must always be explicitly moved into main context in order for it to be passed to the LLM processor during inference.” 。

把信息带过窗口的东西,各家都叫记忆,指的范围却不一样:有的把公司文档也算进来,有的把常驻在窗口里的内容算进来,有的连模型权重里的知识也叫记忆。这篇先把各家的定义摆在一起找出分歧,再用一套形式化把几个相邻概念分开,给出一个能检验的划分,最后从来源、用途、形式和操作四个方面,看一个记忆系统由什么组成。

Zhang 等 (2024) 的综述把记忆的来源分成三类,外部知识是其中之一22 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“these sources can be classified into three categories, that is, the information inside a trial, the information across different trials, and the external knowledge. The former two are dynamically generated in the agent-environment interaction process” :

these sources can be classified into three categories, that is, the information inside a trial, the information across different trials, and the external knowledge.

一篇 LLM memory 综述(Zhang D. 等,2025)以模型为对象,权重里的知识和推理时留下的状态都算记忆33 Zhang, D. 等 Memory in Large Language Models: Mechanisms, Evaluation and Evolution. 2025.原文:“we define LLM memory as a persistent state that is written during pretraining, finetuning, or inference, and that can later be read to produce systematic effects on the model’s outputs.” :

we define LLM memory as a persistent state that is written during pretraining, finetuning, or inference, and that can later be read to produce systematic effects on the model’s outputs.

Hu 等 (2025) 的综述认为 agent memory 几乎完全包含 LLM memory,只把改动模型内部表示的那一类工作排除在外;它和 RAG 的界线画在存储会不会变:经典 RAG 查的是静态的知识源,agent memory 会随交互不断构建和更新自己的存储44 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Context engineering is a systematic design methodology that treats the context window as a constrained computational resource.” “From the perspective of context engineering, agent memory is merely one variable within the context assembly function that requires efficient scheduling to maximize inference efficacy.” “Conversely, from the perspective of an agent, context engineering serves as the implementation layer that ensures cognitive continuity remains within the physical limits of the underlying model.” “At a high level, agent memory almost fully subsumes what has traditionally been referred to as LLM memory.” “Classical RAG techniques primarily augment an LLM with access to static knowledge sources” “Unlike knowledge that is statically encoded in model parameters or fixed databases, an agentic memory system can dynamically construct and update its memory store and perform customized retrieval conditioned on different queries.” :

At a high level, agent memory almost fully subsumes what has traditionally been referred to as LLM memory.

Letta 的 core memory 是常驻在窗口里的记忆块,由 agent 自己维护55 Letta. Agent Memory: How to Build Agents That Learn and Remember. 2025.原文:“Core memory consists of in-context memory blocks that can be managed by the agent itself or by other agents.” “Agent memory is what and how your agent remembers information over time.” “designing an agent’s memory is essentially context engineering: determining which tokens enter the context window and how they’re organized” :

Core memory consists of in-context memory blocks that can be managed by the agent itself or by other agents.

Zep 说记忆不等于知识检索66 Zep. Stop Using RAG for Agent Memory. 2025.原文:“Memory ≠ Knowledge Retrieval” “Agent memory is not about knowledge retrieval.” :

Agent memory is not about knowledge retrieval.

Hindsight 把窗口叫作工作记忆,会话一结束就全部清空;真正的记忆是跨会话的持久存储77 Hindsight. Your 1M-Token Context Window Is Not Memory. 2026.原文:“It is working memory, and it has two properties that disqualify it from the job no matter how large it gets: it forgets everything when the session ends, and it gets worse at using what you give it long before it is full.” “Asking a context window to be your memory is like asking your RAM to be your hard drive because you bought a lot of RAM.” “memory is the durable, consolidated, cross-session store, and on each turn it recalls a small, relevant, high-signal slice and hands that to the context window to reason over.” :

memory is the durable, consolidated, cross-session store, and on each turn it recalls a small, relevant, high-signal slice and hands that to the context window to reason over.

Mem0 把记忆说成独立于窗口的持久存储层88 Mem0. State of AI Agent Memory 2026. 2026.原文:“AI agent memory is a persistent storage layer that lets an agent retain information across sessions.” “In 2026, memory is treated as a dedicated architectural component separate from the model’s context window, not just a longer prompt.” :

AI agent memory is a persistent storage layer that lets an agent retain information across sessions.

Cognee 把公司已有的数据也算进记忆99 Cognee. AI Agent Memory: The Definitive Guide. 2026.原文:“AI agent memory is a dedicated data layer that captures and organizes information accumulated across AI agent tasks and sessions — both coming from user interactions as well as external data sources, like pre-existing company data.” :

AI agent memory is a dedicated data layer that captures and organizes information accumulated across AI agent tasks and sessions — both coming from user interactions as well as external data sources, like pre-existing company data.

agent 产品文档里的定义最朴素,说的都是跨会话携带的文件或条目。Claude Code1010 Claude Code 文档,How Claude remembers your project,2026-09-29 访问。原文:“Each Claude Code session begins with a fresh context window. Two mechanisms carry knowledge across sessions” :

Each Claude Code session begins with a fresh context window. Two mechanisms carry knowledge across sessions

Codex1111 Codex 文档,Memories,2026-09-29 访问。原文:“Memories let ChatGPT and Codex carry useful context from earlier work into future work.” “Keep required team guidance in AGENTS.md or checked-in documentation. Treat memories as a helpful recall layer, not as the only source for rules that must always apply.” :

Memories let ChatGPT and Codex carry useful context from earlier work into future work.

OpenClaw1212 OpenClaw 文档,Memory architecture,2026-09-29 访问。原文:“OpenClaw memory is a set of plain files and one SQLite index, organized into tiers with different trust levels, write rules, and injection behavior.” :

OpenClaw memory is a set of plain files and one SQLite index, organized into tiers with different trust levels, write rules, and injection behavior.

把这些定义排在一起,分歧集中在三个问题上:

  1. 外部资料算不算。Zhang 等 (2024) 和 Cognee 算;Zep 不算;Hu 等看存储是静态的,还是随交互不断更新。
  2. 窗口里的算不算。Letta 的 core memory 算;Hindsight 只把窗口算作工作记忆;Mem0 和 agent 产品不算。
  3. 模型里的算不算。研究 LLM memory 的人算;Hu 等认为 agent memory 几乎完全包含它;agent 产品不算。

先用几个符号把 agent 和记忆写下来,后面比较概念时,就能指着符号说清各自是哪一块。这套写法来自 Hu 等 (2025)。

agent 在第 tt 步拿到一个观察 oto_t,它由环境状态、agent 能看到的交互历史和任务描述 Q\mathcal{Q} 决定。agent 按策略选出动作:

at=πθ(ot, mt, Q)a_t=\pi_\theta(o_t,\ m_t,\ \mathcal{Q})

θ\theta 是模型参数,mtm_t 是这一步从记忆里取出的内容;这一步不取记忆时,mtm_t 为空1313 Hu 等 Memory in the Age of AI Agents. 2025.原文:“These actions, though diverse in semantics, are unified by the fact that they are produced through an autoregressive LLM backbone conditioned on a contextual input.” “When retrieval is disabled at a given step, … can be treated as a distinguished null input.” 。

记忆是一个随时间变化的状态 StS_t,内部结构不限,可以是文本、键值库、向量库、图,或它们的组合1414 Hu 等 Memory in the Age of AI Agents. 2025.原文:“No specific internal structure is imposed on … it may take the form of a text buffer, key–value store, vector database, graph structure, or any hybrid representation.” “At the beginning of a task, … may already contain information distilled from prior trajectories (cross-trial memory).” “Both roles are supported within a single memory container, with temporal distinctions emerging from usage patterns rather than architectural separation.” 。三个操作推动它变化:

St+1form=F(St, ϕt),St+1=E(St+1form),mt=R(St, ot, Q)S_{t+1}^{\mathrm{form}}=F(S_t,\ \phi_t),\qquad S_{t+1}=E(S_{t+1}^{\mathrm{form}}),\qquad m_t=R(S_t,\ o_t,\ \mathcal{Q})

形成 FF 从这一步产生的东西 ϕt\phi_t(工具输出、推理过程、环境反馈)里挑出值得留的候选;演化 EE 把候选并进已有的记忆;检索 RR 按当前的观察和任务取出一段1515 Hu 等 Memory in the Age of AI Agents. 2025.原文:“selectively transforms these artifacts into memory candidates, extracting information with potential future utility rather than storing the entire interaction history verbatim.” 1616 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Formed memory candidates are integrated into the existing memory base through an evolution operator” “denotes a retrieval operator that constructs a task-aware query and returns relevant memory content.” 。

StS_t 在任务开始时可能已经装着以前任务留下的东西,任务进行中又不断积累新的。短期和长期记忆用的是同一个容器,区别只在三个操作什么时候被调用14。

用这几个符号,四个概念各指哪一块就清楚了:

  • 上下文:这一步模型读到的全部输入,也就是 oto_t、mtm_t、Q\mathcal{Q} 拼起来的那段文本。
  • LLM memory:参数 θ\theta,以及推理时模型内部的 KV cache 和激活。
  • RAG:一种检索 RR,它查的库 D\mathcal{D} 是静态的,不随交互变化:mt=R(D, ot, Q)m_t=R(\mathcal{D},\ o_t,\ \mathcal{Q})。
  • agent memory:StS_t 本身,由 FF 和 EE 按 agent 自己的经历不断更新,跨任务保留。

三个分歧,都出在把不同层面的概念放在一起比。外部资料算不算,牵涉的是 RAG;窗口里的算不算,牵涉的是上下文;模型里的算不算,牵涉的是 LLM memory。它们和 agent memory 有重叠,也有区别。

上下文、LLM memory、RAG 和 agent memory 各在哪里

LLM memory 指模型内部的记忆:θ\theta 里的知识,推理时的激活和 KV cache。

重叠。2023 年以来,不少自称 LLM memory 的工作,比如 MemoryBank 和 MemGPT,解决的其实是 agent 的问题:跟踪用户偏好、维护对话状态、在多轮交互里积累经验1717 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Yet what they fundamentally addressed were classical agentic challenges, for example enabling an LLM-based conversational agent to track user preferences, maintain dialogue-state information, and accumulate experience across multi-turn interactions.” “Techniques such as few-shot prompting … can be viewed as a form of long-term memory” “Even KV compression and context-window management …, when used to preserve salient information across the course of a single task, function as short-term memory mechanisms in an agentic sense.” 。few-shot 示例可以看作长期记忆;单个任务里为保留关键信息而做的 KV 压缩,也起着短期记忆的作用。所以 Hu 等认为 agent memory 几乎完全包含 LLM memory4。

区别。直接改动模型内部状态的工作,比如为了更长的上下文改架构、改写 cache、让循环状态一直延续,目标是扩大模型本身的表示能力,不是给 agent 一个会演化的外部记忆库;它们通常也不支持跨任务保留,不做形成、演化、检索这类操作1818 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Their goal is to expand or reorganize the representational capacity of the underlying model, not to furnish a decision-making agent with an evolving external memory base.” “They do not typically support cross-task persistence, environment-driven adaptation, or deliberate memory operations” 。按本文的划分,分界在位置:LLM memory 在模型里,agent memory 在模型外,按条存储、能单独查看和修改。用一个用户的对话微调出来的权重,确实记录了 agent 的经历,但它属于 LLM memory 的做法,不在本文讨论范围内。

RAG(retrieval-augmented generation,检索增强生成)是一种把窗口外的内容取进来的方法:按当前的问题检索,把命中的结果放进窗口。

重叠。两边都在模型之外建一个信息库,再按需取用,向量索引、语义搜索这些部件两边通用1919 Hu 等 Memory in the Age of AI Agents. 2025.原文:“both systems construct, organize, and leverage auxiliary information stores to extend the capabilities of LLM/agents beyond their native parametric knowledge.” “Indeed, the engineering stacks underlying many RAG and agent memory systems share common building blocks, including vector indices, semantic search, and context expansion modules.” 。

区别。经典 RAG 查的是静态的知识源,一般不保存过往的交互;agent memory 则在 agent 和环境的交互中,把 agent 自己的动作和环境反馈不断并进持久的记忆库2020 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Classical RAG techniques primarily augment an LLM with access to static knowledge sources” “but they generally do not maintain an internal, evolving memory of past interactions.” “In contrast, agent memory systems are instantiated within an agent’s ongoing interaction with an environment, continuously incorporating new information generated by the agent’s own actions and environmental feedback into a persistent memory base” 。用上面的符号说,RAG 的 D\mathcal{D} 不变,agent memory 的 StS_t 由 FF 和 EE 更新。

这条界线正在变模糊。按 RAG 的三条谱系对照2121 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Within the agent memory perspective, the corresponding techniques typically appear in the retrieval stage” “Consequently, graph-based retrieval forms the structural backbone for both paradigms, but only agent memory treats the graph as a living, evolving representation of experience.” “The key distinction is that classical agentic RAG typically operates over an external and often task-specific database, whereas agent memory maintains an internal, persistent, and self-evolving memory base that accumulates knowledge across tasks” :

  1. 模块化 RAG:索引、召回、重排、过滤、组装上下文排成一条固定的流水线。在 agent memory 里,这些技术出现在检索这一步。
  2. 图 RAG:把知识库组织成图,靠图遍历做多跳推理。两边都用图检索,但只有 agent memory 把图当作随经历不断生长的结构。
  3. agentic RAG:由 agent 自己决定何时查、怎样查、查什么,和 agent memory 最接近。区别是它查的通常是外部的、针对某个任务的库,agent memory 维护的是跨任务积累、自己演化的库。

HippoRAG 这样的系统,RAG 和记忆两边的人都认为它在解决长期记忆的问题。所以 Hu 等认为更实用的分法是看任务:agent memory 用在需要长期多轮交互、依赖时间顺序或环境反馈的场景2222 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Interestingly, systems such as HippoRAG/HippoRAG2 … have been interpreted by both RAG and memory communities as addressing long-term memory challenges for LLMs.” “Consequently, a more practical (though not perfectly separable) distinction lies in the task domain.” “By contrast, agent memory systems are typically evaluated in settings requiring sustained multi-turn interaction, temporal dependency, or environment-driven adaptation.” 。按本文的划分,看的是查什么:用 RAG 查产品文档,取到的是外部资料;用 RAG 查 agent 以前的对话,取到的就是记忆,只是读取方式用了检索。

上下文(context)是模型生成回应时能看到的全部文本2323 Claude 平台文档,Context windows,2026-09-29 访问。原文:“refers to all the text a language model can reference when generating a response, including the response itself.” 。窗口里的内容有四个来源:

  1. 固定指令:系统提示词、用户手写的 CLAUDE.md;
  2. 当前对话:这次会话里的消息、读过的文件、命令输出;
  3. 外部资料:产品文档、知识库、网页;
  4. 从记忆里取进来的内容,也就是 mtm_t:agent 以前会话里说过、做过、学到的东西。

四种在窗口里都是上下文,只有第 4 种的源头是记忆。放哪些内容、按什么顺序和形式放,是管理上下文(context engineering)要决定的事。Hu 等把它看作把窗口当作受限的计算资源来调度:从这个角度看,记忆只是装配上下文时要调度的一个变量;从 agent 的角度看,管理上下文是让记忆在模型的物理限制内起作用的实现层4。

重叠。在长任务里,两边都要在有限的窗口里保持连续,用的是同样的手段:压缩、组织、挑选。滚动摘要既是管理窗口的办法,也是一种临时的情景记忆;在这种场景下,管理上下文和维护短期记忆几乎分不开2424 Hu 等 Memory in the Age of AI Agents. 2025.原文:“The two fields converge significantly in the technical realization of working memory during long-horizon interactions” “Similarly, the rolling summary technique serves as a shared foundational primitive, functioning simultaneously as a buffer management strategy and a transient episodic memory mechanism” “In practice, the boundary between engineering the context and maintaining an agent’s short-term memory effectively dissolves in these scenarios” 。会话内的压缩就属于这一块。

区别。管理上下文关心资源分配和接口是否正确:指令、工具调用、中间状态的格式对不对、窗口里排不排得下。agent memory 管的是 agent 知道什么、经历过什么,以及这些怎样随时间变化。前者优化 agent 和模型之间那一刻的接口,后者维持一个超出任何单个窗口的持久状态2525 Hu 等 Memory in the Age of AI Agents. 2025.原文:“As such, context engineering operates at the level of resource allocation and interface correctness” “Rather than managing how information is presented to the model at inference time, agent memory governs what the agent knows, what it has experienced, and how these elements evolve over time.” “The former optimizes the momentary interface between the agent and the model, while the latter sustains a persistent cognitive state that extends beyond any single context window.” 。Letta 说设计记忆本质上就是管理上下文,是站在实现层上看记忆。

这个检验借自 Chen 等 (2026) 的视频生成记忆综述:原始证据已经不在当前上下文里时,删掉或改掉某份状态会影响之后的输出,这份状态就在起记忆的作用;初始提示词这类静态条件本身不算记忆2626 Chen 等 The Past Frames the Future: Memory for Autoregressive Video Generation — A Survey. 2026.原文:“Operationally, a state functions as memory when its removal or modification can affect later outputs after the corresponding evidence is no longer directly available in the immediate context.” “Static conditions, such as an initial text prompt, are not memory by themselves unless the system derives and maintains evolving states, interactions, or action-induced changes from them during rollout.” 。agent memory 不一定靠检索读进来。Claude Code 在每次会话开始时,把 MEMORY.md 的前 200 行整份放进窗口,更细的笔记放在单独的主题文件里2727 Claude Code 文档,How Claude remembers your project,2026-09-29 访问。原文:“The first 200 lines of MEMORY.md, or the first 25KB, whichever comes first, are loaded at the start of every conversation.” “Claude keeps MEMORY.md concise by moving detailed notes into separate topic files.” ;Letta 的 core memory 则一直常驻在窗口里5。

回到三个问题:

  1. 外部资料算不算:不算,不管它是用 RAG 取进来的,还是整份读进来的。用 RAG 查 agent 自己以前的对话,取到的才是记忆。
  2. 窗口里的算不算:窗口里的那一份是上下文。Letta 的 core memory 算记忆,是因为这些记忆块存在窗口之外、跨会话保留,每次会话再整块放进窗口;长会话里的压缩摘要只放在这次会话的窗口里,会话结束就消失,它属于上下文。
  3. 模型里的算不算:权重和 KV cache 是 LLM memory,不在本文讨论范围内。

agent 为完成一个任务和环境进行的一次完整交互,叫一次 trial,其中每一轮交互叫一步(step);一个任务可以有多次 trial2828 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“The complete agent-environment interaction process is called a trial, and each interaction turn is called a step.” “For each task, the agent can explore multiple trials to accomplish the task” 。agent 做决定时用到的信息有三个来源2929 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“In a broad sense, the memory of the agent can come from much wider sources, for example, the information across different trials and the external knowledge beyond the agent-environment interactions.” “For each task, there can be multiple trials for exploring the final solution, and all of them can be incorporated into the memory.” :

  1. inside-trial information:同一次 trial 里此前各步的动作和环境反馈3030 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“In a narrow sense, the memory of the agent is only relevant to the historical information within the same trial.” 。
  2. cross-trial information:以往 trial 留下的东西,包括同一个任务以前的 trial 和别的任务的 trial。
  3. 外部知识(external knowledge):交互之外取来的信息,比如文档、网页、知识库。

三个来源里,只有 cross-trial information 是 agent memory。inside-trial information 只在这次 trial 里有用,trial 一结束就清空3131 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“For the narrow memory definition, the iteration only happens within the same trial, and the memory is emptied when the trial is ended.” ,它待在这次会话的上下文里;外部知识不是 agent 自己的经历,属于外部资料。有的综述把三者都算作记忆的来源2,差别只在”记忆”这个词划得多宽。cross-trial information 也正是 agent 能积累经验、越做越好的那部分:只靠 inside-trial information,agent 积累不了跨任务的知识3232 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“However, relying solely on inside-trial information may prevent the agent from accumulating valuable knowledge from various tasks and learning more generalizable information.” “In contrast to the inside-trial observations, which serve as short-term memory, the trial experiences can be considered as long-term memory.” “However, the limitation lies in the fact that both inside-trial and cross-trial information require the agents to personally engage in agent-environment interactions, where external experiences and knowledge are not included.” 。

跨会话留下来的记忆,按用途分两种3333 Hu 等 Memory in the Age of AI Agents. 2025.原文:“At the highest level, we distinguish between two temporal categories: long-term memory, which serves as the persistent, cross-session store for accumulated knowledge, and short-term memory, which functions as the transient, in-session workspace for active reasoning.” “This system answers the question: “What does the agent know?"" “The agent’s procedural and strategic knowledge, accumulated to enable continual learning and self-evolution by abstracting from past trajectories, failures, and successes.” “This system answers: “How does the agent improve?"" “The agent’s capacity-limited, dynamically controlled scratchpad for active context management during a single task or session.” “This system answers: “What is the agent thinking about now?"" 。

事实记忆(factual memory)回答”agent 知道什么”。它又分两类3434 Hu 等 Memory in the Age of AI Agents. 2025.原文:“User factual memory … denotes facts that sustain the consistency of interactions between humans and agents, including identities, stable preferences, task constraints, and historical commitments.” “Environment factual memory … denotes facts that sustain consistency with respect to the external world, such as document states, resource availability, and the capabilities of other agents.” :

  • 关于用户的:身份、稳定的偏好、任务约束、以前的承诺。
  • 关于环境的:文档的状态、资源是否可用、其他 agent 的能力。

经验记忆(experiential memory)回答”agent 怎样变得更好”:从过去的轨迹、失败和成功里提炼出来的做事方法33。按抽象程度分三类3535 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Case-based Memory … stores minimally processed records of historical episodes, prioritizing high informational fidelity to support direct replay and imitation.” “Strategy-based Memory … distills transferable reasoning patterns, workflows, and high-level insights from past trajectories to guide planning across diverse scenarios.” “Skill-based Memory distills procedural knowledge into executable functions and APIs” :

  1. 案例(case-based):几乎不加工的历史记录,供直接照做或模仿。
  2. 策略(strategy-based):从轨迹里提炼出的可迁移的推理模式、工作流程和洞见。
  3. 技能(skill-based):编译成可执行的函数、脚本或 API 的做事方法。

还有一种常被叫作工作记忆(working memory)的东西,回答”agent 现在在想什么”:一次任务里主动挑选、压缩、改写窗口内容的那套机制3636 Hu 等 Memory in the Age of AI Agents. 2025.原文:“When transposed to LLMs, the standard context window functions primarily as a passive, read-only buffer.” “Although the model can consume the window’s contents during inference, it lacks explicit mechanisms to select, sustain, or transform the current workspace dynamically.” “Throughout this section, we define working memory as the set of mechanisms for the active management and manipulation of context within a single episode” 。它管的是窗口里的内容,属于上下文,不是 agent memory。

记忆可以存成三种形式:显式的记录、模型参数、模型的内部状态3737 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Based on where memory resides and in what form it is represented, we organize these memories into three categories” “Token-level Memory …: Memory organized as explicit and discrete units that can be individually accessed, modified, and reconstructed.” 。

最常见的形式是一条条显式的记录,可以单独查看、修改和重组;记录不限于文字,也可以是图像或音频片段3838 Hu 等 Memory in the Age of AI Agents. 2025.原文:“The token here is a broad representational notion: beyond text tokens, it includes visual tokens, audio frames—any discrete element that can be written, retrieved, reorganized, and revised outside model parameters.” “Token-level memory is also the most common memory form and the one with the largest body of existing work.” 。存哪些内容,有四种做法3939 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“In general, previous studies use the textual form memory to store four types of information including (1) complete agent-environment interactions, (2) recent agent-environment interactions, (3) retrieved agent-environment interactions, and (4) external knowledge.” “In the former three types, they record the information inside the agent-environment interaction loop, while the last type leverages natural languages to store information outside that loop.” :

  1. 全存:把此前的所有交互拼成一整段4040 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“This method stores all the information of the agent-environment interaction history based on long-context strategies” 。代价是计算量随长度增长,超出模型能处理的长度时只好截断,而且长上下文里不同位置的内容被利用的程度不一样4141 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“While storing all the agent-environment interactions can maintain comprehensive information, obvious limitations exist in terms of computational cost, inference time, and inference robustness.” “the memory length can easily exceed the upper bound of the sequence length during LLM’s pretraining, which makes a truncation of memory necessary.” “the positions of text segments in a long context can greatly affect their utilization” 。
  2. 只存最近的:只留最近一段,更早的截掉4242 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“This method stores and maintains the most recently acquired memories using natural languages” 。代价是更早但关键的信息会丢掉4343 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“In other words, emphasizing on recency can inherently neglect earlier, yet critical information, thus posing challenges in scenarios requiring a comprehensive understanding of past events.” 。
  3. 按需检索:按相关性、重要性或主题挑出需要的记录4444 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“Unlike the above method which truncates memories based on time, this method typically selects memory contents based on their relevance, importance, and topics.” 。
  4. 外部知识:通过 API 或工具把外部信息取进来存下4545 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“To obtain more information, some agents acquire external knowledge by invoking tools, with the aim of transforming additional relevant knowledge into their own memories for decision-making.” 。按本文的划分,它属于外部资料,不是 agent memory。

记录之间怎么组织,又分三种4646 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Flat Memory stores information as accumulations of discrete units, without explicitly modeling semantic or relational dependencies among them.” “Planar Memory introduces an explicit organizational topology among memory units, but only within a single structural layer” “Hierarchical memory organizes information across layers, using inter-level connections to shape the memories into a volumetric structured space.” “Such hierarchies support representations at different degrees of abstraction—from raw observations, to compact event summaries, to higher-level thematic patterns.” :

  1. 平铺(1D):记录一条条堆着,不显式记录它们之间的关系,比如文本块、用户画像、经验轨迹。
  2. 平面(2D):记录之间有显式的结构,比如图、树、表,但只有一层,所有记录的抽象程度相同。查找时只能顺着关系在这一层里走。
  3. 层级(3D):多层结构,上下层的抽象程度不同,从原始观察到事件摘要,再到更高层的主题;层与层之间相连。查找时既能在同一层里走,也能上下走,先在高层找到相关的主题,再往下找到具体的记录4747 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Cross-layer connections further yield a volumetric memory space through which the system can navigate not only laterally among units but also vertically across abstraction levels.” “Pyramid This category constructs memory as multi-level pyramids, where information is progressively organized into higher layers of abstraction and queried in a coarse-to-fine manner.” 。

文本记录的三种组织方式

记忆也可以写进模型参数,推理时不占窗口4848 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“They do not take up the extra length of context in prompts, so they are not constrained by the length limitations of LLM context.” “we categorize previous works into two types: fine-tuning methods and memory editing methods.” 。一种做法直接改原模型的权重,另一种挂一组附加参数,比如 adapter 或 LoRA 模块,不动原权重4949 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Internal Parametric Memory: Memory encoded within the original parameters of the model (e.g., weights, biases).” “External Parametric Memory: Memory stored in additional or auxiliary parameter sets, such as adapters, LoRA modules, or lightweight proxy models.” “These methods introduce new parameters to carry memory without modifying the original model weights.” 。改权重又有两种写法:

  • 微调:用一批数据训练,把知识写进权重5050 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“To infuse the domain knowledge into LLMs, supervised fine-tuning is a common approach, which empowers agents with the memory of domain experts.” 。微调成本高,多用在离线场景,很难对每一步交互都做反向传播5151 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“Therefore, most fine-tuning approaches are applied to offline scenarios, and can seldom deal with online scenarios, such as fine-tuning with agent observations and trial experiences.” “Due to the frequent agent-environment interactions, it is unaffordable for the cost of backpropagation to fine-tune every step of the online and dynamic interactions.” 。
  • 知识编辑:只改需要改的那条事实,不动其他知识5252 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“Unlike fine-tuning methods that extract patterns from certain datasets, knowledge editing methods specifically target and adjust only the facts that need to be changed.” “It ensures that unrelated knowledge remains unaffected.” 。

记忆还可以留在模型的内部表示里,比如 KV cache、激活值、隐藏状态,研究里叫潜在记忆(latent memory)5353 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Latent memory refers to memory that is carried implicitly in the model’s internal representations (e.g., KV cache, activations, hidden states, latent embeddings), rather than being stored as explicit, human-readable tokens or dedicated parameter sets.” “Generate: latent memory is produced by an independent model or a module, and then supplied to the agent as reusable internal representations.” “Reuse: latent memory is directly carried over from prior computation, most prominently KV-cache reuse (within or across turns)” 。按它从哪来分三种:

  1. 生成(generate):由另一个模型或模块生成,再交给 agent 使用。
  2. 复用(reuse):直接沿用此前计算的结果,最典型的是复用 KV cache。
  3. 转换(transform):把已有的内部状态蒸馏、池化或压缩成新的表示5454 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Transform: existing latent state is transformed into new representations(e.g., distillation, pooling, or compression), so the agent can retain essentials while reducing latency and context footprint.” 。

参数和内部状态两种形式都在模型里,属于 LLM memory 的做法。agent memory 用的是显式记录:它写入快,可寻址、透明,适合频繁增删改、需要追溯来源的场景5555 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“In a nutshell, textual memory is more efficient in writing, while parametric memory is more efficient in reading.” 5656 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Token-level memory remains symbolic, addressable, and transparent, making it particularly well suited for scenarios where explicit reasoning, controllability, and accountability are essential.” “Its externalizability allows memory to be easily inspected, audited, transferred, or revised, making it especially suitable for domains requiring precise add/delete/update operations.” 。

记忆的操作分三步:形成把原始经历变成要存的内容,演化把新内容和已有记忆整合,检索取出和当前动作相关的部分5757 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Memory Lifecycle: Formation, Evolution, and Retrieval The dynamics of the memory system are characterized by three conceptual operators.” “Memory Formation … This process focuses on transforming raw experience into information-dense knowledge.” “It focuses on integrating newly formed memories with the existing memory base.” “Conditioned on the context, the system constructs a task-aware query and uses a carefully designed retrieval strategy to access the appropriate memory bank.” 。

三步不必每一步交互都执行,有的系统只在任务开始时检索一次5858 Hu 等 Memory in the Age of AI Agents. 2025.原文:“the three lifecycle operators (formation … need not be invoked at every time step.” “For instance, some systems perform retrieval only once at task initialization” 。

形成不是把交互历史全部记下来,而是挑出将来可能有用的信息,压成紧凑的知识155959 Hu 等 Memory in the Age of AI Agents. 2025.原文:“We define memory formation as the process of encoding raw contexts (e.g., dialogues or images) into compact knowledge.” 。原始信息又长又杂,怎么抽是关键6060 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“Previous research indicates that designing the strategy of information extraction during the memory writing operation is vital” “This is because the original information is commonly lengthy and noisy.” 。按压缩的粒度和编码方式,有五种做法6161 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Based on the granularity of information compression and the logic of encoding, we categorize the memory formation process into five distinct types.” “Semantic Summarization … transforms lengthy raw data into compact summaries” “Knowledge Distillation … extracts specific cognitive assets, ranging from factual details to experiential planning strategies.” “Structured Construction … organizes amorphous source data into explicit topological representations, such as knowledge graphs or hierarchical trees” “Latent Representation … encodes raw experiences directly into machine-native formats (e.g., vector embeddings or KV states)” “Parametric Internalization … consolidates external memories directly into the model’s weight space through parameter updates” :

  1. 语义摘要:把冗长的原始数据压成摘要,保留整体语义。
  2. 知识蒸馏:抽出具体的知识,从事实细节到规划策略。
  3. 结构化构建:把零散的数据组织成知识图谱、层级树这类显式结构。
  4. 潜在表征:直接把经历编码成向量或 KV 状态。
  5. 参数内化:通过参数更新,把外部记忆写进模型权重。

新记忆如果只是追加到库里,会忽略条目之间的依赖和矛盾,也不管信息是否过时6262 Hu 等 Memory in the Age of AI Agents. 2025.原文:“A naive strategy is simply appending new entries to the existing memory bank.” “However, it overlooks the semantic dependencies and potential contradictions between memory entries and neglects the temporal validity of information.” “Memory Consolidation … merges new and existing memories and performs reflective integration, forming more generalized insights.” “Memory Updating … resolves conflicts between new and existing memories, correcting and supplementing the repository to maintain accuracy and relevance.” “Memory Forgetting … removes outdated or redundant information, freeing capacity and improving efficiency.” 。演化有三种:

  1. 巩固(consolidation):把新旧记忆合并,反思出更一般的洞见6363 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“The memory in the agent can also be managed by reflecting to generate higher-level memories, merging redundant memory entries, and forgetting unimportant, early memories.” 。
  2. 更新(updating):解决新旧记忆之间的冲突,修正和补充。
  3. 遗忘(forgetting):删掉过时或冗余的信息。

检索按执行顺序分四步6464 Hu 等 Memory in the Age of AI Agents. 2025.原文:“Retrieval Timing and Intent … determines the specific moments and objectives for memory retrieval, shifting from passive, instruction-driven triggers to autonomous, self-regulated decisions.” “Query Construction … bridges the semantic gap between the user’s raw input and the stored memory index by decomposing or rewriting queries into effective retrieval signals.” “Retrieval Strategies … executes the search over the memory repository, employing paradigms ranging from sparse lexical matching to dense semantic embedding and structure-aware graph traversal.” “Post-Retrieval Processing … refines the retrieved raw fragments through re-ranking, filtering, and aggregation, ensuring that the final context provided to the model is concise and coherent.” :

  1. 时机与意图:决定什么时候检索、查哪个库。做法从每次都查,到由模型自己决定。
  2. 查询构建:把用户的原话分解或改写成适合检索的查询。
  3. 检索策略:执行搜索,有词法匹配、语义向量、图遍历和几种的混合。
  4. 后处理:对取回的片段重排、过滤、聚合,让最后放进上下文的内容简洁、连贯。

显式记录大多按文本相似度检索;参数记忆没有单独的检索步骤,推理时直接用更新过的参数6565 Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024.原文:“For the forms of textual memory, most previous works use the text similarity and other auxiliary information for reading.” “For the forms of parametric memory, existing models may just utilize the updated parameters for inference, which can be seen as an implicit reading process.” 。

各家对记忆的分歧在三处:外部资料、窗口里的内容、模型里的知识算不算。把上下文、LLM memory、RAG 和 agent memory 分到四个不同的问题上,三个分歧就有了答案:agent memory 按内容划分,记录的是 agent 自己的经历,存在模型和窗口之外,跨会话保留;它用什么方式读进来、读进来后放在窗口的哪里,是另外的问题。

按这个划分去看一个记忆系统:来源上只有 cross-trial information 算记忆;用途上是事实记忆和经验记忆,工作记忆属于上下文;形式上是显式记录,参数和内部状态属于 LLM memory;操作上是形成、演化、检索三步。这些描述的是一个记忆系统能有哪些选择,没有回答在什么场景下该选哪种组合。

把信息带过窗口,还留下两个问题:带回来的信息可能已经过时,比如用户搬了家;也可能本来就不该信,比如网页里的一句话被当成了用户的要求。

Footnotes
  1. Packer 等 MemGPT: Towards LLMs as Operating Systems. 2023. 原文:“MemGPT’s OS-inspired multi-level memory architecture delineates between two primary memory types: main context (analogous to main memory/physical memory/RAM) and external context (analogous to disk memory/disk storage).” “This out-of-context data must always be explicitly moved into main context in order for it to be passed to the LLM processor during inference.” ↩

  2. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“these sources can be classified into three categories, that is, the information inside a trial, the information across different trials, and the external knowledge. The former two are dynamically generated in the agent-environment interaction process” ↩ ↩2

  3. Zhang, D. 等 Memory in Large Language Models: Mechanisms, Evaluation and Evolution. 2025. 原文:“we define LLM memory as a persistent state that is written during pretraining, finetuning, or inference, and that can later be read to produce systematic effects on the model’s outputs.” ↩

  4. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Context engineering is a systematic design methodology that treats the context window as a constrained computational resource.” “From the perspective of context engineering, agent memory is merely one variable within the context assembly function that requires efficient scheduling to maximize inference efficacy.” “Conversely, from the perspective of an agent, context engineering serves as the implementation layer that ensures cognitive continuity remains within the physical limits of the underlying model.” “At a high level, agent memory almost fully subsumes what has traditionally been referred to as LLM memory.” “Classical RAG techniques primarily augment an LLM with access to static knowledge sources” “Unlike knowledge that is statically encoded in model parameters or fixed databases, an agentic memory system can dynamically construct and update its memory store and perform customized retrieval conditioned on different queries.” ↩ ↩2 ↩3

  5. Letta. Agent Memory: How to Build Agents That Learn and Remember. 2025. 原文:“Core memory consists of in-context memory blocks that can be managed by the agent itself or by other agents.” “Agent memory is what and how your agent remembers information over time.” “designing an agent’s memory is essentially context engineering: determining which tokens enter the context window and how they’re organized” ↩ ↩2

  6. Zep. Stop Using RAG for Agent Memory. 2025. 原文:“Memory ≠ Knowledge Retrieval” “Agent memory is not about knowledge retrieval.” ↩

  7. Hindsight. Your 1M-Token Context Window Is Not Memory. 2026. 原文:“It is working memory, and it has two properties that disqualify it from the job no matter how large it gets: it forgets everything when the session ends, and it gets worse at using what you give it long before it is full.” “Asking a context window to be your memory is like asking your RAM to be your hard drive because you bought a lot of RAM.” “memory is the durable, consolidated, cross-session store, and on each turn it recalls a small, relevant, high-signal slice and hands that to the context window to reason over.” ↩

  8. Mem0. State of AI Agent Memory 2026. 2026. 原文:“AI agent memory is a persistent storage layer that lets an agent retain information across sessions.” “In 2026, memory is treated as a dedicated architectural component separate from the model’s context window, not just a longer prompt.” ↩

  9. Cognee. AI Agent Memory: The Definitive Guide. 2026. 原文:“AI agent memory is a dedicated data layer that captures and organizes information accumulated across AI agent tasks and sessions — both coming from user interactions as well as external data sources, like pre-existing company data.” ↩

  10. Claude Code 文档,How Claude remembers your project,2026-09-29 访问。原文:“Each Claude Code session begins with a fresh context window. Two mechanisms carry knowledge across sessions” ↩

  11. Codex 文档,Memories,2026-09-29 访问。原文:“Memories let ChatGPT and Codex carry useful context from earlier work into future work.” “Keep required team guidance in AGENTS.md or checked-in documentation. Treat memories as a helpful recall layer, not as the only source for rules that must always apply.” ↩

  12. OpenClaw 文档,Memory architecture,2026-09-29 访问。原文:“OpenClaw memory is a set of plain files and one SQLite index, organized into tiers with different trust levels, write rules, and injection behavior.” ↩

  13. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“These actions, though diverse in semantics, are unified by the fact that they are produced through an autoregressive LLM backbone conditioned on a contextual input.” “When retrieval is disabled at a given step, … can be treated as a distinguished null input.” ↩

  14. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“No specific internal structure is imposed on … it may take the form of a text buffer, key–value store, vector database, graph structure, or any hybrid representation.” “At the beginning of a task, … may already contain information distilled from prior trajectories (cross-trial memory).” “Both roles are supported within a single memory container, with temporal distinctions emerging from usage patterns rather than architectural separation.” ↩ ↩2

  15. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“selectively transforms these artifacts into memory candidates, extracting information with potential future utility rather than storing the entire interaction history verbatim.” ↩ ↩2

  16. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Formed memory candidates are integrated into the existing memory base through an evolution operator” “denotes a retrieval operator that constructs a task-aware query and returns relevant memory content.” ↩

  17. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Yet what they fundamentally addressed were classical agentic challenges, for example enabling an LLM-based conversational agent to track user preferences, maintain dialogue-state information, and accumulate experience across multi-turn interactions.” “Techniques such as few-shot prompting … can be viewed as a form of long-term memory” “Even KV compression and context-window management …, when used to preserve salient information across the course of a single task, function as short-term memory mechanisms in an agentic sense.” ↩

  18. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Their goal is to expand or reorganize the representational capacity of the underlying model, not to furnish a decision-making agent with an evolving external memory base.” “They do not typically support cross-task persistence, environment-driven adaptation, or deliberate memory operations” ↩

  19. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“both systems construct, organize, and leverage auxiliary information stores to extend the capabilities of LLM/agents beyond their native parametric knowledge.” “Indeed, the engineering stacks underlying many RAG and agent memory systems share common building blocks, including vector indices, semantic search, and context expansion modules.” ↩

  20. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Classical RAG techniques primarily augment an LLM with access to static knowledge sources” “but they generally do not maintain an internal, evolving memory of past interactions.” “In contrast, agent memory systems are instantiated within an agent’s ongoing interaction with an environment, continuously incorporating new information generated by the agent’s own actions and environmental feedback into a persistent memory base” ↩

  21. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Within the agent memory perspective, the corresponding techniques typically appear in the retrieval stage” “Consequently, graph-based retrieval forms the structural backbone for both paradigms, but only agent memory treats the graph as a living, evolving representation of experience.” “The key distinction is that classical agentic RAG typically operates over an external and often task-specific database, whereas agent memory maintains an internal, persistent, and self-evolving memory base that accumulates knowledge across tasks” ↩

  22. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Interestingly, systems such as HippoRAG/HippoRAG2 … have been interpreted by both RAG and memory communities as addressing long-term memory challenges for LLMs.” “Consequently, a more practical (though not perfectly separable) distinction lies in the task domain.” “By contrast, agent memory systems are typically evaluated in settings requiring sustained multi-turn interaction, temporal dependency, or environment-driven adaptation.” ↩

  23. Claude 平台文档,Context windows,2026-09-29 访问。原文:“refers to all the text a language model can reference when generating a response, including the response itself.” ↩

  24. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“The two fields converge significantly in the technical realization of working memory during long-horizon interactions” “Similarly, the rolling summary technique serves as a shared foundational primitive, functioning simultaneously as a buffer management strategy and a transient episodic memory mechanism” “In practice, the boundary between engineering the context and maintaining an agent’s short-term memory effectively dissolves in these scenarios” ↩

  25. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“As such, context engineering operates at the level of resource allocation and interface correctness” “Rather than managing how information is presented to the model at inference time, agent memory governs what the agent knows, what it has experienced, and how these elements evolve over time.” “The former optimizes the momentary interface between the agent and the model, while the latter sustains a persistent cognitive state that extends beyond any single context window.” ↩

  26. Chen 等 The Past Frames the Future: Memory for Autoregressive Video Generation — A Survey. 2026. 原文:“Operationally, a state functions as memory when its removal or modification can affect later outputs after the corresponding evidence is no longer directly available in the immediate context.” “Static conditions, such as an initial text prompt, are not memory by themselves unless the system derives and maintains evolving states, interactions, or action-induced changes from them during rollout.” ↩

  27. Claude Code 文档,How Claude remembers your project,2026-09-29 访问。原文:“The first 200 lines of MEMORY.md, or the first 25KB, whichever comes first, are loaded at the start of every conversation.” “Claude keeps MEMORY.md concise by moving detailed notes into separate topic files.” ↩

  28. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“The complete agent-environment interaction process is called a trial, and each interaction turn is called a step.” “For each task, the agent can explore multiple trials to accomplish the task” ↩

  29. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“In a broad sense, the memory of the agent can come from much wider sources, for example, the information across different trials and the external knowledge beyond the agent-environment interactions.” “For each task, there can be multiple trials for exploring the final solution, and all of them can be incorporated into the memory.” ↩

  30. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“In a narrow sense, the memory of the agent is only relevant to the historical information within the same trial.” ↩

  31. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“For the narrow memory definition, the iteration only happens within the same trial, and the memory is emptied when the trial is ended.” ↩

  32. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“However, relying solely on inside-trial information may prevent the agent from accumulating valuable knowledge from various tasks and learning more generalizable information.” “In contrast to the inside-trial observations, which serve as short-term memory, the trial experiences can be considered as long-term memory.” “However, the limitation lies in the fact that both inside-trial and cross-trial information require the agents to personally engage in agent-environment interactions, where external experiences and knowledge are not included.” ↩

  33. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“At the highest level, we distinguish between two temporal categories: long-term memory, which serves as the persistent, cross-session store for accumulated knowledge, and short-term memory, which functions as the transient, in-session workspace for active reasoning.” “This system answers the question: “What does the agent know?"" “The agent’s procedural and strategic knowledge, accumulated to enable continual learning and self-evolution by abstracting from past trajectories, failures, and successes.” “This system answers: “How does the agent improve?"" “The agent’s capacity-limited, dynamically controlled scratchpad for active context management during a single task or session.” “This system answers: “What is the agent thinking about now?"" ↩ ↩2

  34. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“User factual memory … denotes facts that sustain the consistency of interactions between humans and agents, including identities, stable preferences, task constraints, and historical commitments.” “Environment factual memory … denotes facts that sustain consistency with respect to the external world, such as document states, resource availability, and the capabilities of other agents.” ↩

  35. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Case-based Memory … stores minimally processed records of historical episodes, prioritizing high informational fidelity to support direct replay and imitation.” “Strategy-based Memory … distills transferable reasoning patterns, workflows, and high-level insights from past trajectories to guide planning across diverse scenarios.” “Skill-based Memory distills procedural knowledge into executable functions and APIs” ↩

  36. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“When transposed to LLMs, the standard context window functions primarily as a passive, read-only buffer.” “Although the model can consume the window’s contents during inference, it lacks explicit mechanisms to select, sustain, or transform the current workspace dynamically.” “Throughout this section, we define working memory as the set of mechanisms for the active management and manipulation of context within a single episode” ↩

  37. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Based on where memory resides and in what form it is represented, we organize these memories into three categories” “Token-level Memory …: Memory organized as explicit and discrete units that can be individually accessed, modified, and reconstructed.” ↩

  38. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“The token here is a broad representational notion: beyond text tokens, it includes visual tokens, audio frames—any discrete element that can be written, retrieved, reorganized, and revised outside model parameters.” “Token-level memory is also the most common memory form and the one with the largest body of existing work.” ↩

  39. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“In general, previous studies use the textual form memory to store four types of information including (1) complete agent-environment interactions, (2) recent agent-environment interactions, (3) retrieved agent-environment interactions, and (4) external knowledge.” “In the former three types, they record the information inside the agent-environment interaction loop, while the last type leverages natural languages to store information outside that loop.” ↩

  40. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“This method stores all the information of the agent-environment interaction history based on long-context strategies” ↩

  41. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“While storing all the agent-environment interactions can maintain comprehensive information, obvious limitations exist in terms of computational cost, inference time, and inference robustness.” “the memory length can easily exceed the upper bound of the sequence length during LLM’s pretraining, which makes a truncation of memory necessary.” “the positions of text segments in a long context can greatly affect their utilization” ↩

  42. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“This method stores and maintains the most recently acquired memories using natural languages” ↩

  43. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“In other words, emphasizing on recency can inherently neglect earlier, yet critical information, thus posing challenges in scenarios requiring a comprehensive understanding of past events.” ↩

  44. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“Unlike the above method which truncates memories based on time, this method typically selects memory contents based on their relevance, importance, and topics.” ↩

  45. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“To obtain more information, some agents acquire external knowledge by invoking tools, with the aim of transforming additional relevant knowledge into their own memories for decision-making.” ↩

  46. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Flat Memory stores information as accumulations of discrete units, without explicitly modeling semantic or relational dependencies among them.” “Planar Memory introduces an explicit organizational topology among memory units, but only within a single structural layer” “Hierarchical memory organizes information across layers, using inter-level connections to shape the memories into a volumetric structured space.” “Such hierarchies support representations at different degrees of abstraction—from raw observations, to compact event summaries, to higher-level thematic patterns.” ↩

  47. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Cross-layer connections further yield a volumetric memory space through which the system can navigate not only laterally among units but also vertically across abstraction levels.” “Pyramid This category constructs memory as multi-level pyramids, where information is progressively organized into higher layers of abstraction and queried in a coarse-to-fine manner.” ↩

  48. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“They do not take up the extra length of context in prompts, so they are not constrained by the length limitations of LLM context.” “we categorize previous works into two types: fine-tuning methods and memory editing methods.” ↩

  49. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Internal Parametric Memory: Memory encoded within the original parameters of the model (e.g., weights, biases).” “External Parametric Memory: Memory stored in additional or auxiliary parameter sets, such as adapters, LoRA modules, or lightweight proxy models.” “These methods introduce new parameters to carry memory without modifying the original model weights.” ↩

  50. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“To infuse the domain knowledge into LLMs, supervised fine-tuning is a common approach, which empowers agents with the memory of domain experts.” ↩

  51. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“Therefore, most fine-tuning approaches are applied to offline scenarios, and can seldom deal with online scenarios, such as fine-tuning with agent observations and trial experiences.” “Due to the frequent agent-environment interactions, it is unaffordable for the cost of backpropagation to fine-tune every step of the online and dynamic interactions.” ↩

  52. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“Unlike fine-tuning methods that extract patterns from certain datasets, knowledge editing methods specifically target and adjust only the facts that need to be changed.” “It ensures that unrelated knowledge remains unaffected.” ↩

  53. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Latent memory refers to memory that is carried implicitly in the model’s internal representations (e.g., KV cache, activations, hidden states, latent embeddings), rather than being stored as explicit, human-readable tokens or dedicated parameter sets.” “Generate: latent memory is produced by an independent model or a module, and then supplied to the agent as reusable internal representations.” “Reuse: latent memory is directly carried over from prior computation, most prominently KV-cache reuse (within or across turns)” ↩

  54. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Transform: existing latent state is transformed into new representations(e.g., distillation, pooling, or compression), so the agent can retain essentials while reducing latency and context footprint.” ↩

  55. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“In a nutshell, textual memory is more efficient in writing, while parametric memory is more efficient in reading.” ↩

  56. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Token-level memory remains symbolic, addressable, and transparent, making it particularly well suited for scenarios where explicit reasoning, controllability, and accountability are essential.” “Its externalizability allows memory to be easily inspected, audited, transferred, or revised, making it especially suitable for domains requiring precise add/delete/update operations.” ↩

  57. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Memory Lifecycle: Formation, Evolution, and Retrieval The dynamics of the memory system are characterized by three conceptual operators.” “Memory Formation … This process focuses on transforming raw experience into information-dense knowledge.” “It focuses on integrating newly formed memories with the existing memory base.” “Conditioned on the context, the system constructs a task-aware query and uses a carefully designed retrieval strategy to access the appropriate memory bank.” ↩

  58. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“the three lifecycle operators (formation … need not be invoked at every time step.” “For instance, some systems perform retrieval only once at task initialization” ↩

  59. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“We define memory formation as the process of encoding raw contexts (e.g., dialogues or images) into compact knowledge.” ↩

  60. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“Previous research indicates that designing the strategy of information extraction during the memory writing operation is vital” “This is because the original information is commonly lengthy and noisy.” ↩

  61. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Based on the granularity of information compression and the logic of encoding, we categorize the memory formation process into five distinct types.” “Semantic Summarization … transforms lengthy raw data into compact summaries” “Knowledge Distillation … extracts specific cognitive assets, ranging from factual details to experiential planning strategies.” “Structured Construction … organizes amorphous source data into explicit topological representations, such as knowledge graphs or hierarchical trees” “Latent Representation … encodes raw experiences directly into machine-native formats (e.g., vector embeddings or KV states)” “Parametric Internalization … consolidates external memories directly into the model’s weight space through parameter updates” ↩

  62. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“A naive strategy is simply appending new entries to the existing memory bank.” “However, it overlooks the semantic dependencies and potential contradictions between memory entries and neglects the temporal validity of information.” “Memory Consolidation … merges new and existing memories and performs reflective integration, forming more generalized insights.” “Memory Updating … resolves conflicts between new and existing memories, correcting and supplementing the repository to maintain accuracy and relevance.” “Memory Forgetting … removes outdated or redundant information, freeing capacity and improving efficiency.” ↩

  63. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“The memory in the agent can also be managed by reflecting to generate higher-level memories, merging redundant memory entries, and forgetting unimportant, early memories.” ↩

  64. Hu 等 Memory in the Age of AI Agents. 2025. 原文:“Retrieval Timing and Intent … determines the specific moments and objectives for memory retrieval, shifting from passive, instruction-driven triggers to autonomous, self-regulated decisions.” “Query Construction … bridges the semantic gap between the user’s raw input and the stored memory index by decomposing or rewriting queries into effective retrieval signals.” “Retrieval Strategies … executes the search over the memory repository, employing paradigms ranging from sparse lexical matching to dense semantic embedding and structure-aware graph traversal.” “Post-Retrieval Processing … refines the retrieved raw fragments through re-ranking, filtering, and aggregation, ensuring that the final context provided to the model is concise and coherent.” ↩

  65. Zhang 等 A Survey on the Memory Mechanism of Large Language Model based Agents. 2024. 原文:“For the forms of textual memory, most previous works use the text similarity and other auxiliary information for reading.” “For the forms of parametric memory, existing models may just utilize the updated parameters for inference, which can be seen as an implicit reading process.” ↩