读见

智能体记忆的组成部分

原题The components of agent memory

约 17 分钟约 4,014 字原文英文已翻译

推荐理由Anthropic 拆解智能体记忆分层结构:会话记录、记忆笔记、记忆表征与预载上下文,外加「梦境反思」离线机制——回放经历、修正错误、沉淀已验证规则,并用自建基准逐项评估各组件贡献。把「经验变长期能力」讲成可复用工程方法,适合构建长期运行智能体的工程师。

读前速览

5 个要点

本文探讨 AI 系统中智能体记忆的架构,详细介绍记忆笔记、梦境反思和记忆表征等组成部分,并展示这些机制如何帮助 AI 智能体从经验中学习、纠正错误并提升跨任务表现。

  1. 智能体记忆可以采用分层结构,包括对话记录、记忆笔记、记忆表征和注入的上下文,借鉴人类记忆过程。

    这种分工使智能体能够实时记录经历(对话记录)、识别重要信息(记忆笔记)、将知识整理成便于访问的结构(维基),并在未来的会话中通过注入上下文利用这些整理好的知识。

  2. 梦境反思让智能体能够离线回顾经历、纠正错误并构建新的记忆表征。

    智能体可以将对话记录与已有的记忆笔记对照分析,从而发现并修正错误假设。比如在《宝可梦》的示例中,修正后的记忆笔记帮助智能体成功通过陷阱,而不是反复失败。

  3. 记忆系统能帮助智能体形成学习闭环,并提升复杂任务中的表现。

    在 CL-Bench 的数据库任务评估中,Claude Opus 5 首个成功形成学习闭环,利用记忆记录经过验证的规则和陷阱警告,因此得分显著高于无状态基线模型。

  4. 较新的 Claude 模型比旧模型更善于判断信息的重要性,因此能更高效地使用记忆。

    Claude Sonnet 3.7 在一轮《宝可梦》游戏中创建了 413 个记忆文件,而 Claude Fable 5 只创建了 10 个文件,却获得了 4 枚徽章,超过前者的 1 枚。这表明较新的模型更善于区分值得记住的信息和冗余数据。

  5. 关于记忆使用方式的指导可以提升表现,尤其对旧模型有帮助,但可能妨碍更强的模型。

    「只记录失败」等具体规则降低了 Opus 5 和 Opus 4.7 从记忆中获得的性能提升;而 Claude Sonnet 5.5 无需提示就会在 90% 的情况下自主读取记忆文件。这表明,更强的模型能更多地受益于自主判断信息重要性。

完整摘要

本文借鉴人类记忆过程,探讨 AI 智能体如何构建有效的记忆系统。文章介绍了一种分层记忆结构,包括对话记录、记忆笔记、维基等记忆表征,以及注入的上下文。研究提出「梦境反思」这一离线过程:智能体借此回顾经历、纠正错误、创建新笔记,并构建有组织的知识结构。通过持续学习基准测试和《宝可梦 红》等任务的评估,文章展示了设计良好的记忆系统如何帮助智能体形成学习闭环、更有效地判断信息显著性,并大幅提升表现。研究表明,Claude Opus 5.5 和 Claude Sonnet 5.5 等前沿模型能够自主利用记忆记录经过验证的规则,并随时间推移不断进步;而较旧的模型则能从明确指导中受益。

目录 · 10 节

查看原文

索伦·克尔凯郭尔写道,人生只有回顾时才能理解,但必须向前生活。在为 AI 智能体设计记忆时,我们也遇到了类似的两难困境。Søren Kierkegaard wrote that life can only be understood backward, but it must be lived forward. We’ve encountered a similar bind when designing memory for AI agents.

人类在日常生活中不断编码记忆。海马体在这一过程中发挥着核心作用,它会即时记录经历,使记忆迅速形成并能立即提取。但只有部分经历会被巩固为长期知识。As humans, we encode memory constantly as we go about our lives. The hippocampus plays a central role in this, capturing experiences in the moment so that memories form quickly and are immediately available. But only some experiences are consolidated into long-term knowledge.

这种整合大多似乎发生在大脑“离线”时。睡眠期间以及安静休息时,海马体会重放我们近期的经历。人们认为,这一过程会逐渐提炼这些经历,并将它们整合进新皮层——也就是大脑中储存我们通常所说的知识的大部分内容的区域。Much of that consolidation appears to happen when our brains are offline. As we sleep, and during quiet rest, the hippocampus replays our recent experiences. This is thought to gradually distill those experiences and integrate them into the neocortex—the part of our brains that stores most of what we think of as knowledge.

智能体记忆也可以采用类似的分工方式。智能体会将大量工作记录在日志或交互记录中。Letta 和加州大学伯克利分校的研究人员提出了“睡眠时计算”这一方法,让模型利用交互之间的空闲时间重新整理已有上下文。同样的思路也能帮助智能体整理记忆:通过回顾日志来纠正错误,或生成新的笔记和表征。这一过程通常称为“做梦”(图 1)。Agent memory can use a similar division of labor. Agents capture much of their work in logs or transcripts. Researchers at Letta and UC Berkeley proposed sleep-time compute as a way for models to use idle time between interactions to reorganize their existing context. The same idea can help agents organize their memory by reflecting on logs to fix mistakes or produce new notes and representations. This process is often called dreaming (Figure 1).

我们发现,梦境机制是一种有用的工具,可以帮助我们为 Claude 提供有效的记忆。在这篇文章中,我们将分享我们对智能体记忆的思考方式,并介绍我们用于探索智能体记忆的多项评估,包括梦境机制的运用,以及各个组成部分对记忆组织的贡献。We’ve found that dreaming has been a useful tool for helping us give Claude effective memory. In this post, we share how we’ve come to think about agent memory and walk through several evaluations we’ve used to explore agent memory, including the use of dreaming, and what each component contributes to memory organization.

Diagram of a memory hierarchy between one session and the next. From bottom to top: transcripts (a searchable event log), memory notes written by Claude, memory representations such as wikis, and injected context loaded into every session. Inside a box labeled “Dreaming,” arrows run from transcripts up to each layer, and in both directions between neighboring upper layers.
Claude can use dreaming to organize memory. This can correct mistakes, create notes, build new memory representations, or shape what’s preemptively loaded into future sessions.

记忆笔记Memory notes

“智能体记忆”指的是 Claude 从经验中获得的知识,包括与用户的互动以及被分配的任务,并将其保留到后续会话中,保存为日后可读取的上下文。它不包括模型学习或管理上下文的其他方式,例如权重变化(训练期间设定的内部参数)、上下文学习(在单次对话中获得的知识),以及压缩(Claude 编写摘要来替代较早的对话轮次,从而能在新的上下文窗口中继续工作)。By “agent memory,” we mean knowledge that Claude gains from experience—including interactions with users and tasks it’s been assigned—and that it retains between sessions, saved as context it can read later. It excludes other ways models can learn or manage context, such as changes to their weights (the internal parameters set during training), in-context learning (knowledge gained within a single conversation), and compaction (summaries written by Claude that replace its older turns so it can continue working in a new context window).

在人脑中,在某段经历之前、期间或之后释放的化学信号,可以将一段记忆标记为重要记忆。与未标记的记忆相比,被标记的记忆在离线期间往往会被更频繁地重放。这一过程称为重放,有助于稳定这些记忆,并将其整合到长期记忆中。In the human brain, chemical signals released before, during, or after an experience can mark a memory as important. Marked memories tend to be replayed more often than unmarked ones during offline periods. This process, called replay, helps stabilize and integrate them into long-term memory.

同样,Claude 可以在会话日志中实时标记重要事件,方便日后查找;也可以将这些事件写入记忆存储,例如存放记忆笔记的文件夹(图 2)。但在还不知道接下来会发生什么之前,Claude 如何判断当下哪些内容值得关注?Similarly, Claude can tag salient events in a session log as they happen, so they’re easier to find later, or it can write them to a memory store, such as a folder of memory notes (Figure 2). But how can Claude tell what’s salient in the moment, before it knows what’s coming next?

The same memory hierarchy, with the memory notes layer highlighted. An arrow runs from the session directly to the memory notes, described as salient observations written by Claude.
Claude can write notes to memory.

记忆可以是对未来所需内容的预测。Memory can be a prediction about what the future will need

记忆有时也是一种预测。通过记下一条规则,智能体是在预测它所描述的模式今后还会再次派上用场。比如,记下一条经核实的事实,意味着预测未来某次会话中的智能体会想依赖这条事实,而不再重复核查。随着时间推移,Claude 已经越来越擅长做出这类预测。Memory is, occasionally, a prediction. By writing down a rule, an agent predicts that the pattern it’s describing will be relevant again. For instance, writing down a verified fact is a prediction that an agent in a future session will want to rely on that fact without double-checking it. Over time, Claude has become much better at making these kinds of predictions.

考虑一道来自 Continual Learning Bench(CL-Bench)1.0 的任务。该基准用于衡量智能体利用记忆完成长期任务的能力。其中一项任务要求 Claude 通过查询数据库来回答一系列问题。Claude 给出答案后,会获知正确答案,并可以写入记忆,以帮助回答后续问题。Consider a task from Continual Learning Bench (CL-Bench) 1.0, a benchmark that measures an agent’s ability to use memory in order to tackle long-horizon tasks. One particular task asks Claude to answer a series of questions by looking up information in a database. After Claude gives an answer, it’s told the correct solution and can write a memory to help answer future questions.

记忆可以在这里支持一个学习循环。如果 Claude 答错了问题,它可以记录这次失误,推测出错原因,验证这些推测,并将发现总结成一条规则,以指导今后的回答。Memory can support a learning loop here. If Claude gets a question wrong, it can record the failure, come up with theories about what went wrong, test those theories, and turn what it finds into a rule about how to answer in the future.

我们使用 Claude Managed Agents 运行了 CL-Bench 1.0 任务。Claude 每次都会在一个全新的会话中开始回答问题,但有一个例外:它可以从一个记忆目录中检索文件,而该目录会在不同会话之间持续保留。We ran the CL-Bench 1.0 task using Claude Managed Agents. Claude started each question in a fresh session, with one exception: it could retrieve files from a memory directory that persisted from one session to the next.

不同模型在构建自己的学习循环方面取得了不同程度的成功。Claude Sonnet 4.6 已经能够进一步推测答案出错的原因。它的记忆目录中零散地存放着一些文件,每个文件都列出了若干未经验证的猜测。Different models achieved different levels of success at creating their own learning loops. Claude Sonnet 4.6 got as far as generating theories about why an answer was wrong. Its memory directory contained a scattering of files, each listing several untested guesses.

Left: bar chart of mean reward on the CL-Bench database task, stateless baseline versus memory store. Opus 5.5: 0.655, 0.838. Sonnet 5.5: 0.644, 0.833. Opus 5: 0.564, 0.828. Opus 4.7: 0.383, 0.700. Sonnet 5: 0.306, 0.610. Sonnet 4.6: 0.330, 0.364. Right: line chart of running-mean reward over 30 questions for the same models, with and without memory.
CL-Bench database task, comparing memory with a stateless baseline across models.

Claude Opus 4.7 将笔记整合成一份参考文档,并开始标注哪些事实已经核实,哪些仍未确认。Claude Sonnet 5 在评分器检查每个答案后将其标记为已确认,并在答错时写下更正。Claude Opus 4.7 consolidated its notes into a single reference document and began marking which facts it had checked and which were still unconfirmed. Claude Sonnet 5 marked each answer as confirmed after the grader had checked it, and wrote a correction when it had answered wrong.

Claude Opus 5 是这些模型中第一个形成闭环的。它的大多数记录条目都包含一条规则(以及它如何确认该规则成立)、对先前问题的回答,以及对它在过程中发现的陷阱发出的明确警告(图 3)。Claude Opus 5 was the first of these models to close the loop. Most of its entries included a rule (and also how it knew the rule was true), answers to earlier questions, and clear warnings about traps it had discovered along the way (Figure 3).

与 Opus 5 一样,Claude Opus 5.5 和 Claude Sonnet 5.5 都实现了闭环,利用记忆记录经过验证的规则,以便更好地回答未来的问题。启用记忆后,两者的得分与 Opus 5 大致相同,不过它们在不使用记忆时的基准表现略高。Like Opus 5, Claude Opus 5.5 and Claude Sonnet 5.5 both closed the loop, using memory to capture validated rules about how to best answer future questions. With memory, both scored about the same as Opus 5, though their baseline performance without memory was slightly higher.

Claude 已学会判断显著性Claude has learned to judge salience

我们还评估了 Claude 玩《宝可梦红》的能力。这款游戏要求 Claude 应对复杂的长期任务,我们以此测试 Claude 判断哪些信息值得保存到记忆中的能力。每次运行开始时,我们都会为每个模型提供一个记忆文件夹,模型在游戏过程中可以读取和写入这些文件(图 4)。We also evaluated Claude’s ability to play Pokémon Red, a game that challenges Claude to navigate complex long-horizon tasks, as a test of Claude’s judgment about what to save to memory. At the start of each run, we gave each model a folder of memory files that it could read from and write to while it played (Figure 4).

我们比较了 Claude Sonnet 3.7 和 Claude Fable 5 各自运行一局、游戏进度约为 10,000 步时的记忆文件夹。我们注意到,两种模型对于哪些内容值得记住,想法截然不同。Sonnet 3.7 认为任何事情都可能有用,于是不加甄别地将所有内容写入记忆。它的记忆文件夹里保存着一份遭遇记录,通常每场战斗、每件发现的物品,以及每个遇到的非玩家角色都有单独的文件。最终,Sonnet 3.7 在 225 个文件夹中写入了 413 个记忆文件,并获得了一枚徽章(徽章代表玩家在游戏中的进度)。We compared the memory folders from one run each of Claude Sonnet 3.7 and Claude Fable 5, when each was about 10,000 steps into the game. A key difference we noticed was what each model thought was worth remembering. Sonnet 3.7 assumed everything might matter and wrote to memory indiscriminately. Its memory folder contained an archive of encounters, often with a separate file for each battle it fought, each item it found, and each non-player character it met. Ultimately, Sonnet 3.7 wrote 413 memory files across 225 folders and earned one badge (badges mark a player’s progress through the game).

相比之下,Fable 5 在两个文件夹中写入了九个文件,此外还创建了一个名为 global.md 的顶层文件,并获得了四枚徽章。Fable 5, by comparison, wrote nine files in two folders, plus a single top-level file called global.md, and earned four badges.

Two treemaps of Pokémon memory directories at the same scale, where area shows characters of memory. Claude Sonnet 3.7’s is large and crowded, with 413 files and 977,930 characters across folders such as locations, main, battles, and several “consolidated” folders. Claude Fable 5’s is small, with 10 files and 43,406 characters in locations, gameplay, and global.md.
Claude’s memory directories for Sonnet 3.7 versus Fable 5 while playing Pokémon.

Sonnet 3.7 的做法之所以成问题,主要是因为 Pokémon 的游戏状态不断变化——Sonnet 3.7 详细记录的内容持续过时。因此,随着 Claude 不断推进,它不得不花费更多时间和资源翻查记忆,而不是玩游戏。例如,在大约第 10,000 步时,Sonnet 3.7 开始建立第四个“主记忆”文件夹。在接下来的 17 步里,它创建了六个文件,删除了另外九个文件,却没有在游戏中采取任何行动。Sonnet 3.7’s approach was a problem mainly because the game state of Pokémon changes constantly—Sonnet 3.7’s detailed record was continuously going out of date. As a result, as Claude progressed, it had to spend more time and resources combing through its memories rather than playing the game. Around step 10,000, for example, Sonnet 3.7 started its fourth folder of “master” memory files. Over the next 17 steps, it created six files, deleted nine others, and took no actions in the game itself.

《神鬼寓言5》的做法是利用记忆来保存游戏没有明确告知它的信息。Sonnet 3.7 写入记忆的一些信息——例如玩家有多少钱,或玩家在地图上的位置——每回合都能从屏幕上读取,因此存储这些信息是多余的。相比之下,有关策略、计划和经过测试的规则的记忆文件,只有在 Claude 自己推导出这些内容后才会存在;除非 Claude 把它们写下来,否则这些内容就会消失。Fable 5’s approach used memory for things the game didn’t explicitly tell it. Some of the kinds of information Sonnet 3.7 wrote to memory—such as how much money the player has or where the player is on the map—can be read off the screen every turn, so storing it is redundant. By contrast, memory files about strategy, plans, and tested rules exist only if Claude works them out, and they disappear unless Claude writes them down.

Fable 5 相应地组织了自己的记忆。它的 global.md 文件充当仪表盘,记录当前目标、预先写好的道馆攻略计划(道馆是赢得徽章的挑战),以及模型使用记忆时应遵循的规则。locations 文件夹存放着如何穿越特定路线的计划,gameplay 文件夹则保存着基于它对游戏机制的了解而制定的策略。例如,在连续七个精灵球都没能抓住鲤鱼王(最容易捕捉的宝可梦之一)后,Claude 写道:“如果连续有 3 个或更多精灵球没能成功,就要改变时机(在菜单步骤之间多按几次 ‘wait’)——照做后紧接着就抓到了。”Fable 5 organized its memory accordingly. Its global.md file acted as a dashboard, holding the current goal, a prewritten plan for tackling gyms (the challenges where badges are won), and the model’s own rules for using memory. A locations folder held plans for navigating particular routes, and a gameplay folder held strategies based on what it had learned about how the game works. For example, after seven Poké Balls in a row failed to catch a Magikarp (one of the easiest Pokémon to catch), Claude wrote, “If 3+ balls fail in a row, VARY the timing (insert extra ‘wait’ presses between menu steps) - the catch landed right after doing this.”

在内存文件夹小得多的情况下,Fable 5 在游戏中的进展远超 Sonnet 3.7。Opus 5.5 采用了类似的方法:它保留了一个小型记忆笔记文件夹,用来记录当前目标和后续步骤,并在游戏过程中不断改写这些笔记,最终通关。With a much smaller memory folder, Fable 5 progressed much further in the game than Sonnet 3.7. Opus 5.5 took a similar approach: it kept a small folder of memory notes that tracked its current goal and next steps, rewrote them as it played, and beat the game.

引导 Claude 编写记忆Steering Claude to write memory

我们发现,告诉 Claude 记忆的用途很有帮助,但不必告诉它如何使用记忆。在 CL-Bench 上,我们只是告诉 Claude 有一个可用的记忆文件夹。这种概括性的指导足以让 Opus 4.7 和 Opus 5 有效地使用记忆,并显著提升了两者的表现(图 3)。We’ve found that it helps to tell Claude what memory is for, but not how to use it. On CL-Bench, we simply told Claude that a memory folder was available. That general guidance was enough for Opus 4.7 and Opus 5 to use memory effectively, and it gave both a noticeable boost in performance (Figure 3).

我们还测试了为模型设置关于应将哪些内容写入记忆的具体规则,每次测试设置一条规则。我们比较了在每条规则下各模型从记忆中获得的提升,与不设置规则时获得的提升。当我们设定“只记录失败”这条规则时,Opus 5 和 Opus 4.7 从记忆中获得的性能提升都大幅减弱(图 5 右图)。对于更强的模型,让它们自行判断哪些内容值得记录,比预先设定固定规则更有效;这些规则甚至可能削弱模型的表现。We also tested giving the models specific rules about what they should write to memory, with one rule per test. We compared how much each model gained from memory with each rule against how much it gained without it. When we set a rule to “record only failures,” both Opus 5 and Opus 4.7 lost much of the performance boost that memory gave them (Figure 5, right). For stronger models, giving them freedom to judge salience was more effective than setting fixed rules in advance, and those rules could end up weakening performance.

Left: bar chart of Sonnet 4.6’s mean reward on the CL-Bench database task: 0.330 at baseline, 0.364 with memory, and 0.641 with memory and refined instruction. Reference lines mark Opus 4.7 with memory at 0.700 and Opus 5 with memory at 0.828. Right: change in memory gain when told to record only failures: Opus 5, −0.234; Opus 4.7, −0.150; Sonnet 4.6, −0.020.
Left: Sonnet 4.6 on the CL-Bench database task with and without prompting to guide memory usage. Right: how much each model’s gain from memory changed when it was told to record only failures.

我们还注意到,引导对较旧模型的帮助最大。例如,Sonnet 4.6 经常不会读取其记忆目录中的文件,也不会验证自己对答案出错原因的猜测。We also noticed that steering helped older models the most. For instance, Sonnet 4.6 often didn’t read files from its memory directory and failed to test its theories about why an answer was wrong.

在这个案例中,提示 Claude 在回答前读取其记忆文件,并明确验证自己的推测,几乎使其基准测试得分翻了一番(图 5 左)。Sonnet 5 会主动这样做。即使没有收到提示,它也会在 10 次中有 9 次于回答前读取记忆。相比之下,Sonnet 4.6 这样做的次数不到一半。In this case, prompting Claude to read its memory files before answering—and then to explicitly test its theories—nearly doubled its benchmark score (Figure 5, left). Sonnet 5 does this on its own. Without being prompted to, it read its memory before answering 9 out of 10 times. By comparison, Sonnet 4.6 did this less than half of the time.

对于前沿的 Claude 模型,我们通常会给出简单的指导,让它们在人们提出要求或某些内容显然值得记住时创建记忆笔记,并将是否创建的判断交由 Claude 决定。With frontier Claude models, we typically give simple guidance to create memory notes when a person asks them to or when something is clearly worth remembering, and we leave that judgment up to Claude.

做梦可以纠正记忆。Dreaming can correct memory

由于 Claude 会根据其判断在会话中哪些内容值得关注而写入记忆,因此,一条从一开始就不正确、或随着环境变化而逐渐偏离事实的笔记,可能会在之后的会话中被 Claude 读取并信以为真。Since Claude writes to memory based on what it judges to be salient in-session, a note that’s wrong from the start or that drifts as the environment changes can be read, and trusted, by Claude in a later session.

梦境功能为 Claude 提供了一种将笔记与原始对话记录进行对照验证的方法(图 6)。我们观察到一个积极案例:Claude 使用 Managed Agents 玩 Pokémon,并挂载了一个目录来存储记忆。Dreaming gives Claude a way to test its notes against the original transcripts (Figure 6). We saw a positive example of this when Claude played Pokémon using Managed Agents with a mounted directory for its memories.

The memory hierarchy with dreaming, highlighting an arrow from the transcripts layer up to the memory notes layer, which shows dreaming correcting notes against transcripts.
Dreaming can correct mistakes in memory.

在游戏的某一部分,玩家必须穿过月见山——一片洞穴群,入口位于地图西侧,出口位于东侧。入口附近有个陷阱:一处单向落差,玩家一旦跳下去就会落回原路,而且没有明显的方法爬回去。Claude 把位于山脚入口处的一栋建筑——宝可梦中心——当作地标,因此它会不会走下落差,取决于它认为宝可梦中心位于山的哪一侧。In one part of the game, the player has to get through Mt. Moon, a cave system with its entrance on the west side of the map and its exit on the east. Near the entrance is a trap: a one-way ledge that drops the player onto the route they came from, with no clear way to climb back up. Claude was using the PokéCenter, a building at the mountain’s entrance, as a landmark, so whether it walked off the ledge depended on which side of the mountain it thought the PokéCenter was on.

有一次,Claude(错误地)记下宝可梦中心在东侧。它走出宝可梦中心时,宣称:“月见山在我身后”,并更新了笔记:“月见山 DONE”。但月见山并不在它身后。几步操作后,Claude 跨过悬崖边缘,落回了它之前走过的那条路线(图 7)。它的导航工具没有显示这个落差,于是 Claude 得出结论:“我向西走过头了”,并认为自己一直就在正确的一侧。事实并非如此。At one point, Claude wrote down (incorrectly) that the PokéCenter was on the east side. When it walked out of the PokéCenter, it announced, “Mt Moon is behind me,” and updated its notes: “Mt Moon DONE.” But Mt. Moon was not behind it. A few actions later, Claude went over the ledge and landed back on the route it had come from (Figure 7). Its navigation tool didn’t show the drop, so Claude concluded, “I overshot far west,” and that it had been on the correct side all along. It hadn’t.

Two Pokémon map panels with the agent next to a ledge. Left, “Raw memory,” where the stored note is wrong: an arrow shows the agent heading for the next city. Right, “Memory + dreaming,” where an offline pass corrected the note: an arrow shows the agent heading back to the cave entrance.
A corrected memory note changed the outcome in Pokémon. With the uncorrected note, Claude says, “Mt Moon is behind me,” heads for the next city, and ends up back on the route it came from. With the note corrected by dreaming, it says, “Now I need to find the Mt Moon cave entrance to re-enter,” and goes back into the cave.

随后,我们测试了做梦能否帮助 Claude 避开这个陷阱。我们对记忆文件夹运行了做梦流程,其中记录着错误的宝可梦中心位置:Claude 将笔记与会话记录进行了核对,发现了错误并重写了笔记。会话记录为 Claude 提供了一个可用于验证记忆的真实依据。修正记忆笔记后,Claude 直接返回月见山,最终抵达了华蓝市。We then tested whether dreaming could help Claude avoid this trap. We ran dreaming on the memory folder that contained the wrong location for the PokéCenter: Claude checked the note against the session transcript, caught its error, and rewrote it. The transcript gave Claude a ground truth to validate its memory against. With the corrected memory note, Claude went straight back into Mt. Moon and eventually reached Cerulean City.

在那次没有修正提示的运行中,Claude 三次退回了之前走过的路线。第三次失败后,Claude 似乎放弃了,并写道:“我不想再这样循环下去了,还是停下来吧。”我们的设置自动回复,指示它继续。于是它照做了,一路退回到山前的小镇 Pewter City,希望在那里恢复状态并补充物资。这次运行结束时,Claude 始终没能抵达 Cerulean City。In the run with the uncorrected note, Claude dropped back onto that earlier route three times. After the third failure, Claude seemed to give up, writing, “I’m going to stop rather than keep looping.” Our setup’s automatic reply instructed it to continue. So it did, all the way back to Pewter City, the town before the mountain, where it hoped to heal and restock. The run ended without Claude ever reaching Cerulean City.

Line chart of progress toward Cerulean over 3,000 cumulative actions. The memory plus dreaming run reaches Cerulean at action 1,935. The raw memory run falls off the ledge and backtracks to Pewter. The run with no memory never reaches Cerulean.
Dreaming corrects the memory, and Claude goes back into the cave and reaches the next city. The run with the uncorrected note (“Raw memory”) never gets past the mountain, and neither does the run with no memory.

做梦可以构建新的记忆表征。Dreaming can build new memory representations

借助梦境机制,Claude 可以构建表征来帮助浏览记忆(图 9)。它使用的一种记忆表征称为 wiki,是一组由 Claude 编写并维护的页面,汇集了 Claude 对某个主题的了解,并将其链接到其他笔记。这些链接实际上为 Claude 提供了一张地图,可用于梳理记忆,并在需要时高效定位相关记忆。With dreaming, Claude can build representations to help navigate memory (Figure 9). One type of memory representation it uses is called a wiki, a collection of pages written and maintained by Claude that gathers what Claude knows about one subject and links it to other notes. These links effectively provide Claude with a map it can use to sift through its memory and efficiently locate memories when they’re needed.

The memory hierarchy with dreaming, highlighting arrows from transcripts and from memory notes up to the memory representations layer, such as wikis.
Dreaming can build memory representations.

维基等表示方式可以帮助 Claude 遍历其不断扩大的知识库。我们使用一套内部文档语料库,探索了维基作为记忆表示方式的优势。这套语料库包含约 35 万个文件,约 4.2 亿个 token,来自我们在 5 月收购的软件公司 Stainless。我们围绕这套语料库创建了一个包含 25 个问题的评测集,并为 Claude 提供了搜索工具,让它探索其中的内容。我们还指示 Claude 通过梦境机制,根据这些文件构建一个维基。在 128 次会话中,我们提示 Opus 5 智能体探索文件、编写或修正相互链接的维基页面、合并重复内容,并根据来源核实各项说法。Representations like wikis can help Claude traverse its ever-growing knowledge base. We explored the benefit of wikis as a memory representation using a corpus of internal documents—about 350,000 files, roughly 420M tokens—from Stainless, a software company we acquired in May. We created an evaluation set of 25 questions about this corpus and gave Claude a search tool to explore it. We also instructed Claude to build a wiki based on these files using dreaming. Over 128 sessions, we prompted Opus 5 agents to explore the files, write or correct linked wiki pages, merge duplicates, and check claims against the sources.

每个会话都基于智能体在此前会话中取得的进展,并通过共享日志协调工作。随着我们将 dreaming 的规模从两个会话扩大到 128 个会话,智能体在 25 个问题上的表现也从达到 13% 的评分标准提升至 48%(图 10)。Each session built on the progress that agents made in prior sessions, using a shared log to coordinate work. As we scaled dreaming from two sessions to 128, performance on the 25 questions grew from 13% to 48% of graded criteria (Figure 10).

Claude 会逐步构建自己的 wiki。创建初始 wiki 后,它会在后续几轮“梦境整理”中对其进行补充、编辑或删减。在早期的梦境整理阶段,Claude 的知识水平就像一名新员工,仅凭 wiki 回答问题的能力有限。随着梦境整理次数增加,它的知识图谱会不断丰富,就像一名经验丰富的员工。在我们的测试中,我们发现,如果同时提供搜索工具,wiki 对 Claude 的帮助最大。Claude 同时使用搜索和 wiki 时,随着 wiki 不断完善,其综合得分从 54% 提高到了 61%;而仅能使用搜索工具时,得分为 53%。Claude 仅使用 wiki 回答问题时,最高得分为 48%。同时使用搜索和 wiki,每个问题还可节省约 20,000 个 token。Claude builds its wikis incrementally. After creating an initial wiki, it uses subsequent rounds of dreaming to add to, edit, or prune it. In the early rounds of dreaming, Claude’s knowledge is like that of a new employee, and its ability to answer questions based on the wiki alone is limited. The more it dreams, the richer its knowledge map grows, like that of a seasoned employee. In our tests, we found that the wiki helped Claude the most when we also gave it access to a search tool. When it used both search and the wiki, Claude’s aggregate score rose from 54% to 61% as that wiki grew, compared with 53% when it had access to the search tool alone. Claude’s best score was 48% when it used only the wiki to answer questions. Using search and the wiki also saved about 20,000 tokens per question.

Center: line chart of graded criteria met as wiki generation grows from 2M to 128M dreaming tokens. Wiki plus search tool rises from 54% to 61%, wiki alone rises from 13% to 48%, and the search tool with no wiki is flat at 53%. Left and right: network graphs of an example wiki, with 103 pages and 766 links after 2 sessions and 222 pages and 12,893 links after 128 sessions.
Center: scores on 25 questions about a corpus of documents from a company as Claude built wikis over sequential sessions. Left and right: an example wiki after two and 128 sessions; each dot is a page, and lines join linked pages.

我们想测试哪些类型的任务能从 Claude 拥有一个 wiki 中获益。为此,我们使用了 Harvey LAB 基准测试,以及一组关于某项合并的文件。该基准测试向 Claude 提供一组文件,并要求 Claude 根据文件内容撰写一份法律文书。随后,基准测试会依据一系列标准对这份文书进行评分。也许这些评估没有宝可梦挑战那么吸引人,但它们为我们提供了各种各样的文件集合,可用于构建 wiki。We wanted to test which kinds of tasks benefited from Claude having a wiki. To do this, we used the Harvey LAB benchmark along with a collection of documents about a merger. The benchmark gives Claude a set of documents and asks Claude to generate a legal brief based on their content. The benchmark then grades the brief against a list of criteria. While a tad less engaging, perhaps, than a Pokémon run, these evaluations give us diverse collections of documents to build wikis from.

我们指示 Claude 根据这些文档构建一个 wiki。随后,我们让 Claude 基于 wiki 或直接搜索文件来回答有关合并的问题,或生成法律意见书(LAB 基准测试)。其中一项测试围绕这次合并提出了 24 个问题(图 11 左图);其中半数以上需要 Claude 从多份文档中查找信息,许多问题还需要 Claude 运用判断力或进行计算。在这些题目上(红线和橙线),Claude 查阅 wiki 时的得分为 87%,而仅使用搜索时为 73%。We instructed Claude to build a wiki from the documents. We then asked Claude to answer questions (about the merger) or generate legal briefs (the LAB benchmark) both from the wiki and from a direct file search. One test asked 24 questions about the merger (Figure 11, left), more than half of which needed Claude to find information across several documents, and many of which also needed Claude to use judgment or do math. On those items (red and orange lines), Claude scored 87% when it consulted the wiki, compared with 73% when it used search alone.

Two diagrams linking graded criteria to source documents. Left, the task where the wiki showed more benefit: most of the 24 criteria connect to two or more of 10 documents, and nine need judgment or arithmetic. Right, the task where the wiki showed less benefit: most of the 57 criteria can be found by text search in a single document, usually the deal overview memo.
Each panel lists what was graded (left) and the source documents needed to meet each one (right). Left: 24 questions about a merger, which can be answered by looking at mostly public filings. More than half of the criteria required combining information from several documents. Right: a LAB task where the wiki showed no clear gain. Most criteria could be met from a single document.

在其他情况下,wiki 的用处就没那么大了。在一项 LAB 任务中(图 11 右侧),简短的评判标准通常可以通过文本搜索从单个文档中找到;与搜索相比,wiki 在性能上没有明显优势。在另一项 LAB 任务中,wiki 的篇幅甚至超过了文档本身(图 12)。这就像博尔赫斯那篇只有一段的短篇小说《论科学中的精确性》里的制图师:他们绘制了一张细致到与所代表的帝国一般大的地图。Claude 制作了一份极其详尽的 wiki,实际上却什么也没有抽象出来。In other cases, the wiki was less useful. On one LAB task (Figure 11, right), brief criteria often could be retrieved with a text search from a single document, and the wiki showed no clear gain in performance relative to search. On another LAB task, the wiki grew larger than the documents themselves (Figure 12). Like the mapmakers in Borges’s one-paragraph short story “On Exactitude in Science,” who drafted a map so detailed it was as large as the empire it represented, Claude had made an extremely detailed wiki that effectively abstracted nothing.

Diagram of a wiki build and second pass. On the left, a circle holds the corpus: 10 documents, 115 KB of text. An arrow leads to a larger circle holding the wiki built from it: 68 pages, 255 links, and 203 KB, or 1.77 times the corpus. Some of the wiki’s pages have no links.
The wiki grew to be larger than the raw files.

做梦可以将记忆中的笔记提升到更高层级Dreaming can promote notes up the memory hierarchy

梦境也可以将笔记浮到记忆层级的顶端,而智能体框架可以在每次会话开始时,预先将它们加载到 Claude 的上下文中(图 13)。这意味着 Claude 无需搜索这些笔记,甚至不必知道有东西可供搜索。Dreaming can also float notes to the top of the memory hierarchy, and the agent harness can preemptively load them into Claude’s context at the start of every session (Figure 13). This means Claude doesn’t need to search for them, or even to know there’s something to search for.

将记忆提升到新会话中(这是一种上下文注入)必须谨慎进行。注入的记忆会占用宝贵的 token,而错误的笔记可能会被带入每个会话。加载笔记也不保证 Claude 会按其行事:我们关于 Claude Code 的文档提醒,指令文件越长,遵循程度就越低。因此,记忆层级的顶层必须保持相对精简,而「梦境」功能在这方面的大部分工作,就是通过将一些细节下移到层级更深处并留下链接来维持这一点。Promoting memories into a new session (a form of context injection) must be done carefully. Injected memories use up valuable tokens, and an incorrect note can be carried into every session. Loading a note also doesn’t guarantee that Claude acts on it: our documentation on Claude Code warns that longer instruction files reduce adherence. So the top layer of the memory hierarchy has to stay relatively small, and much of dreaming’s work here is keeping it that way—by moving some details down the hierarchy and leaving links behind.

Claude Code 的自动记忆也以同样的方式保持其注入层精简,并由 Claude 在会话期间维护。Claude 不会在每个会话中都将所有自动记忆加载到上下文窗口中。它只会加载 MEMORY.md 的前 200 行或 25 KB。这个头部充当索引,向 Claude 展示它知道什么,以及可以在哪里找到相关内容。Claude Code’s auto memory keeps its injected layer small in the same way, with Claude maintaining it during the session. Claude doesn’t load all of its auto memory into every session’s context window. It loads only the first 200 lines or 25 KB of MEMORY.md. This header serves as an index, which shows Claude what it knows and where to find it.

The memory hierarchy with dreaming, highlighting arrows from transcripts and from memory representations up to the injected context layer at the top, which feeds into the next session.
Dreaming can write to the top of the memory hierarchy. Injected context is loaded into every session, and the layers below it are read or searched when Claude needs them.

做梦可以让记忆聚焦于某个特定目标。Dreaming can focus memory on a specific goal

梦境也能影响记忆的形成。例如,像 Claude Duet 这样的助手,往往能从围绕它所帮助的人来组织记忆中受益;而梦境也可以经过调整,以构建服务于特定目标的记忆。Dreaming can also shape how memory grows. An assistant like Claude Duet, for example, often benefits from having memories that are organized around the person it’s helping, and dreaming can be tuned to build memory in service of a particular goal.

指导记忆增长的指令因任务而异,它们会告诉 Claude 哪些信息真正重要。例如,LAB 基准测试中的一项任务模拟了公司收购,并提供了一系列合同。评估会根据任务简介是否准确描述合同条款来打分。The instructions that guide how memory grows differ by task and tell Claude what information actually matters. For example, one task in the LAB benchmark simulates a company acquisition and provides a set of contracts. The brief is graded on whether it correctly describes the contract terms.

我们最初使用的维基生成基础指令并未告诉 Claude 如何使用维基。这项任务高度依赖合同条款。在构建维基的过程中,多个智能体同时向合同条款共享表写入内容(图 14,左侧)。We started with basic instructions for generating the wiki that didn’t tell Claude how to use the wiki. This task relied heavily on contract terms. While the wiki was being built, several agents wrote to a shared table of contract terms at the same time (Figure 14, left).

Two diagrams. Before: four agents write to the same shared page, provisions.md, and one agent’s save erases another’s lines; 41 of 57 graded facts survived. After: four agents each write their own contract’s page, with terms copied word for word; all 57 of 57 graded facts survived.
How many graded contract facts made it into the wiki, before and after instructions changed. Left: several agents writing to one shared page; 41 of 57 facts survived. Right: one agent per contract, each writing its own page and quoting terms word for word; 57 of 57 facts survived.

最终得到的是一个缺少关键信息的 wiki。我们根据该 wiki 对生成的简报进行评分时发现,Claude 只纳入了 57 条事实中的 41 条(72%)。查明问题所在后,我们发现共享表格对合同条款的概括很差,有些条款甚至完全缺失,因为各个智能体互相覆盖了彼此的工作。The result was a wiki that was missing key facts. When we graded a brief generated from the wiki, Claude had included only 41 of the 57 facts (72%). When we looked at what had gone wrong, we found that the shared table summarized the contract terms poorly and was missing some of them altogether, because agents had overwritten one another’s work.

合同条款是维基中最重要的部分,但说明中并未提到这一点。为了找到更好的说明,我们运行了一个循环:Claude 对自身的失败进行反思,提出修改说明的建议,然后重建维基。通过这个循环,Claude 发现遵循合同条款有多么重要,并据此重写了构建维基的说明。The contract terms were the most important part of the wiki, but the instructions didn’t say that. To find better instructions, we ran a loop in which Claude reflected on its failures, proposed a change to the instructions, and rebuilt the wiki. This loop allowed Claude to discover how important it was to follow the contract terms, and it rewrote the instructions for building the wiki accordingly.

每份合同在 wiki 中都有一个单独的页面,由一名代理编写,逐字引用条款,而不是将它们总结到共享表格中。对基于这个改进后的 wiki 生成的简报进行评分时,结果显示 100% 的评估标准都得到了满足,高于此前的 72%。Each contract got its own page in the wiki, written by a single agent, which quoted the terms word for word rather than summarizing them into a shared table. When we graded the brief generated from this improved wiki, 100% of the criteria could be met, up from 72%.

梦境可以填补一次心理咨询留下的空白。Dreaming can fill in gaps a session leaves behind

Claude 编写记忆笔记时,只能看到特定会话中的上下文。Dreaming 可以搜索多个会话,找出共同模式或纠正常见错误。When Claude writes memory notes, it sees only the context in that particular session. Dreaming can search across many sessions to find common patterns or correct common mistakes.

在构建 LAB 基准测试的 wiki 时(示例见图 14),Claude 有时会链接到尚未创建的页面。第二轮 dream 操作填补了其中许多空缺。在一项任务中(图 15),dream 操作发现 wiki 中有九个链接指向一个不存在的页面,便将它们改为指向同一文档的现有页面。它还新增了三个页面(包括一个索引页),以完善 wiki。When building the wikis for the LAB benchmark (as an example, see Figure 14), sometimes Claude would link to pages that hadn’t yet been created. A second dreaming pass closed many of these gaps. On one task (Figure 15), dreaming found nine links to a missing page in the wiki and repointed them to an existing page for the same document. It also added three new pages, including an index, to improve the wiki.

Two network graphs of a wiki. Before the second pass: 38 entries and 225 links, with nine links from six pages pointing to “escrow-agreement,” a page that doesn’t exist. After: 41 entries and 278 links, with all nine links pointing to “buyer-form-escrow-agreement” and three new pages: index, instructions email, and escalations.
The wiki before and after a second dreaming pass.

回望过去,展望未来Thinking backward, looking forward

关于如何为智能体设计记忆系统,还有许多未解的问题。其中一个问题是 Claude 应该何时创建记忆。Claude 处理任务时,可以将内容写入记忆存储(例如文件夹、文件或数据库),在信息源头捕捉重要性,让重要细节在后续轮次或会话中立即可用。但即时记录笔记不可避免地会分散 Claude 对主要任务的注意力。相比之下,梦境机制可以将记忆创建放到后台进行,但梦境产生的任何内容可能无法立即供 Claude 使用。There are many open questions about how to design memory systems for agents. One is when Claude should create memory. When Claude works on a task, it can write to a memory store (e.g., a folder, file, or database), capturing salience at the source and making important details immediately available for future turns or sessions. But logging notes in the moment inevitably draws Claude’s attention away from its main task. In contrast, dreaming can push memory creation to the background, but any outputs from dreaming may not be immediately accessible to Claude.

另一个问题是如何确保记忆可靠地保持最新。Claude 可能会做出错误的预测,或将一开始就有误的规则写入记忆。随着环境变化,记忆也可能逐渐偏离实际,变得无关紧要。做梦是纠正这些错误的一种方式(图 8),但这需要计算资源。指示 Claude 持续检查所有记忆可能并不实际。更重要的或许是让做梦过程聚焦于可能发生变化的信息,或者谨慎调整做梦的频率(例如,根据记忆被访问的频率来确定)。Another question is how to keep memory reliably up to date. Claude can make incorrect predictions or write rules to memory that are wrong from the start. Memory can also drift and become irrelevant as the environment changes. Dreaming is one way to fix these mistakes (Figure 8), but it requires compute. Directing Claude to continuously check all its memories might not be practical. It may be important instead to focus dreaming on information that’s likely to change or to carefully tune the cadence of dreaming (e.g., based on how often memories are accessed).

将转录内容搜索视为 Claude 记忆的基础,也是合理的做法。将表示形式(例如 wiki)与搜索结合起来(图 10),有时会很有效。但 Claude 需要投入计算资源来维护这些记忆表示,并确保其中不会累积错误或幻觉。It’s also reasonable to consider transcript search as the foundation of Claude’s memory. Combining representations (e.g., wikis) with search (Figure 10) can sometimes be effective. But Claude needs to use compute to maintain memory representations and make sure they don’t accumulate errors or hallucinations.

尽管 Claude 对重要性的判断能力有所提升,但没有任何模型能够真正预知后续轮次会发生什么。Dreaming 为 Claude 提供了回顾过去的机会,使其能够利用计算资源整理记忆、纠正错误,并维护相关表征,让未来的会话能够更轻松地访问记忆。随着 Claude 的能力不断增强,记忆系统也会随之演进,而在设计 Claude 的记忆系统方面,我们仍有许多东西需要学习。Even though Claude’s judgment about salience has improved, no model can really know what will happen in future turns. Dreaming gives Claude an opportunity to look backward and use compute to organize its memory, correct mistakes, and maintain representations that allow future sessions to access memory more readily. Memory systems will evolve as Claude gets more capable, and we still have a lot to learn about designing Claude’s memory systems.

请参阅我们的操作指南,了解如何开始使用 Dreaming 和知识维基。See our cookbooks for getting started with dreaming and knowledge wikis.

值得记下

  1. 智能体记忆也可以采用类似的分工方式。智能体会将大量工作记录在日志或对话记录中。Letta 和加州大学伯克利分校的研究人员提出了「睡眠时计算」,让模型利用交互间的空闲时间重新整理已有上下文。
  2. 梦境反思让 Claude 能够将笔记与原始对话记录进行对照检验。
  3. Fable 5 的记忆文件夹小得多,却比 Sonnet 3.7 在游戏中推进得更远。
  4. Claude Opus 5 是这些模型中首个形成学习闭环的模型。
  5. 我们发现,告诉 Claude 记忆的用途会有所帮助,但不必告诉它该如何使用记忆。

← 回到本期 · 第 6 条