AIsaAIsaStudio English 打开 AIsa Studio

Anthropic 解析智能体记忆的组成部分与设计取舍

原标题:The components of agent memory \ Anthropic

Anthropic 发布关于智能体记忆组成部分的分析文章,探讨如何为 AI 智能体设计记忆。文中以 Claude 玩 Pokémon Red 的任务为测试,给每个模型一个可读写的记忆文件夹,评估其判断该保存什么的能力;并观察到 Sonnet 4.6 常不读取记忆目录中的文件,也未能验证答案出错的原因,引导对较老模型的帮助最大。

为什么值得看

原文结合 Pokémon Red 等实测说明智能体记忆的设计要点,读者可以借此了解记忆引导对不同代际模型的差异。

阅读原文 ↗11月7日 AI 日报

本页的摘要、推荐理由与解读出自 AIsa Studio 的 AI 风向智能体,原文版权归原作者所有。

深度解读

发生了什么

Anthropic 在官方博客发布长文,系统梳理了其构建智能体记忆的组件与设计取舍,涵盖记忆笔记、让 Claude 自主判断「什么值得记」、以及一种称为 dreaming(做梦)的离线整理机制——即利用会话之间的空闲算力,让模型回看会话记录,修正错误、生成新笔记与知识表示(如 wiki)。

关键细节

  • 博客以人类睡眠中的记忆重放类比:智能体在会话中记录日志,离线时通过 dreaming 反思日志、提炼规则。
  • 在 CL-Bench 1.0 上,各代模型形成「学习闭环」的能力差异明显:Sonnet 4.6 只留下未验证的猜测;Opus 4.7 开始整合笔记并标注已验证事实;Opus 5 首次闭环,写入带依据的规则与「陷阱」警告。
  • 在《宝可梦 红》测试中,Sonnet 3.7 无差别记录(413 个文件、225 个文件夹)反而拖慢进度,仅得 1 枚徽章;Fable 5 只写 9 个文件加一个 global.md 仪表盘,得 4 枚徽章。Opus 5.5 用类似精简策略通关。
  • 一个具体纠错案例:Claude 曾把宝可梦中心位置记错,导致在月见山反复掉落折返、最终未到达华蓝市;对含错误笔记的文件夹运行 dreaming 后,Claude 对照原始记录发现并改正错误,顺利抵达。
  • 在约 35 万个文件(约 4.2 亿 token)的 Stainless 语料上,dreaming 会话从 2 扩展到 128,25 个问题的得分从 13% 升至 48%;搜索加 wiki 将综合得分从 54% 提升到 61%,且每题节省约 2 万 token。但 wiki 并非万能:某 LAB 任务中 wiki 膨胀到超过原文档本身,抽象失效。
  • 指令注入层需保持精简:Claude Code 的 auto memory 只加载 MEMORY.md 前 200 行或 25 KB 作为索引。
  • 给模型「记什么」的具体规则可能适得其反:限定「只记失败」后,Opus 5 与 Opus 4.7 的记忆收益明显下降;而简单提示 Sonnet 4.6 先读记忆再测试理论,几乎使其基准分数翻倍。

为什么重要

这篇博客的核心论点是:记忆本质上是对未来需求的预测,模型对「显著性」的判断能力直接决定记忆系统的成败——更强模型应被赋予自由裁量,而非套用固定规则。dreaming 提供了会话内记录所缺的几项能力:对照原始记录纠错、跨会话发现模式并补全缺口(如修复九处指向缺失页面的链接)、以及围绕特定目标塑造记忆结构。同一 LAB 任务中,仅因让 Claude 反思失败并重写 wiki 构建指令(每份合同独立成页、逐字引用条款而非共享摘要表),评分就从 72% 提升至 100%。博客也坦承开放问题:何时创建记忆、如何以合理算力维持记忆更新、以及表示与搜索如何搭配,均有待探索。

对谁有影响

构建长时程智能体的工程团队是直接受众:文中的记忆分层、上下文注入的 token 开销、指令文件过长降低遵从度等结论可直接指导 harness 设计。使用 Claude Code、Managed Agents、Claude Duet 等产品的用户也会间接受益于其记忆机制;文中提到配套 cookbook 已可用于上手 dreaming 与知识 wiki。

全文翻译

以下翻译只覆盖原文的前一部分,其余内容请看下方原文。

索伦·克尔凯郭尔曾写道,生活只能 向后 理解,但必须 向前 生活。在设计 AI 代理的记忆时,我们也遇到了类似的困境。

作为人类,我们在日常生活中不断编码记忆。海马体在其中起着核心作用,它在当下捕捉经历,以便快速形成记忆并立即可用。但只有 部分经历 会被巩固为长期知识。

大部分巩固似乎发生在大脑离线的时候。当我们睡觉以及处于安静的 休息 状态时,海马体会重播我们最近的经历。人们认为,这逐渐将 这些经历提炼并整合 到新皮层——即大脑中存储我们大多数所谓知识的区域。

代理记忆可以采用类似的工作分工。代理将其大部分工作记录在日志或转录文本中。Letta 和加州大学伯克利分校的研究人员提出了 睡眠时计算,作为一种让模型利用交互之间的空闲时间来重新组织其现有上下文的方法。同样的想法可以帮助代理通过反思日志来纠正错误或生成新的笔记和表示,从而组织其记忆。这个过程通常被称为 做梦(图 1)。

我们发现,“做梦”是帮助 Claude 获得有效记忆的有力工具。在这篇文章中,我们将分享我们对代理记忆的思考方式,并回顾我们用于探索代理记忆的几项评估,包括“做梦”的使用,以及每个组件对记忆组织的贡献。

记忆笔记

所谓“代理记忆”,是指 Claude 从经验中获得的知識——包括与用户的交互以及它被分配的任务——并在会话之间保留的知识,保存为它可以稍后读取的上下文。它不包括模型学习或管理上下文的其他方式,例如对其 权重(训练期间设置的内部参数)的更改、上下文内学习(在单个对话中获得的知識)和 压缩(由 Claude 编写的摘要,用于替换其较早的轮次,以便它可以在新的上下文窗口中继续工作)。

在人脑中,在经历之前、期间或之后释放的化学信号可以 标记一个记忆 为重要。被标记的记忆在离线期间往往比未标记的记忆重播得更频繁。这个过程称为 重播,有助于稳定它们并将其整合到长期记忆中。

同样,Claude 可以在会话日志发生时标记显著事件,以便以后更容易找到,或者可以将它们 写入 到记忆存储库,例如记忆笔记文件夹(图 2)。但是,在不知道接下来会发生什么的情况下,Claude 如何判断当下什么是显著的?

记忆是对未来需求的预测

记忆有时是一种预测。通过写下一条规则,代理预测它所描述的模式将来会再次相关。例如,写下一个经过验证的事实是一种预测,即未来会话中的代理将希望依赖该事实而无需双重检查。随着时间的推移,Claude 在这些类型的预测方面变得更好了。

考虑来自 持续学习基准 (CL-Bench) 1.0 的一项任务,这是一个衡量代理使用記憶以应对长程任务能力的基准。其中一项特定任务要求 Claude 通过查找数据库中的信息来回答一系列问题。在 Claude 给出答案后,它会被告知正确的解决方案,并且可以编写一条记忆来帮助回答未来的问题。

记忆可以在此处支持一个学习循环。如果 Claude 答错了一个问题,它可以记录失败,提出关于出错的理论,测试这些理论,并将发现的内容转化为关于未来如何回答的规则。

我们使用 Claude Managed Agents 运行了 CL-Bench 1.0 任务。Claude 在每个问题的开始时都启动一个新的会话,只有一个例外:它可以从一个 记忆目录 中检索文件,该目录从一个会话持久化到下一个会话。

不同的模型在创建自己的学习循环方面取得了不同程度的成功。Claude Sonnet 4.6 进展到了生成关于答案为何错误的理论。它的记忆目录包含了一些分散的文件,每个文件列出了几个未经测试的猜测。

Claude Opus 4.7 将其笔记整理成一份单一的参考文档,并开始标记哪些事实已经过检查,哪些仍未确认。Claude Sonnet 5 在评分者检查后将每个答案标记为已确认,并在答错时编写更正。

Claude Opus 5 是这些模型中第一个闭合循环的。它的大多数条目都包含一条规则(以及它是如何知道该规则为真的)、对早期问题的回答,以及关于沿途发现的陷阱的明确警告(图 3)。

与 Opus 5 一样,Claude Opus 5.5 和 Claude Sonnet 5.5 都闭合了循环,使用记忆来捕获关于如何最好地回答未来问题的已验证规则。有了记忆,它们的得分都与 Opus 5 大致相同,尽管它们在无记忆情况下的基线性能略高一些。

Claude 学会了判断显著性

我们还评估了 Claude 玩 Pokémon Red 的能力,这是一款 挑战 Claude 导航 复杂长程任务的游戏,以此测试 Claude 关于 什么 值得保存到记忆的判斷力。在每次运行的开始,我们给每个模型提供了一个记忆文件文件夹,它在玩游戏时可以从中读取和写入(图 4)。

我们比较了 Claude Sonnet 3.7 和 Claude Fable 5 各一次运行后的记忆文件夹,当时它们各自在游戏中大约进行了 10,000 步。我们注意到的一个关键区别是每个模型认为值得记住的内容。Sonnet 3.7 假设一切可能都很重要,并不加选择地向记忆写入内容。它的记忆文件夹包含了一系列遭遇的存档,通常为其进行的每一场战斗、找到的每一件物品以及遇到的每一个非玩家角色都有一个单独的文件。最终,Sonnet 3.7 在 225 个文件夹中写了 413 个记忆文件,并获得了一枚徽章(徽章标记玩家在游戏中的进度)。

相比之下,Fable 5 在两个文件夹中写了九个文件,加上一个名为 global.md 的顶层文件,并获得了四枚徽章。

Sonnet 3.7 的方法主要是一个问题,因为 Pokémon 的游戏状态不断变化——Sonnet 3.7 的详细记录不断过时。因此,随着 Claude 的进展,它不得不花费更多的时间和资源来梳理其记忆,而不是玩游戏。例如,在第 10,000 步左右,Sonnet 3.7 开始了第四个“主”记忆文件文件夹。在接下来的 17 步中,它创建了六个文件,删除了另外九个文件,并且在游戏本身中没有采取任何行动。

Fable 5 的方法使用记忆来记录游戏没有明确告诉它的东西。Sonnet 3.7 写入记忆的一些类型的信息——例如玩家有多少钱或玩家在地图上的位置——每回合都可以从屏幕上读取,因此存储它们是多余的。相比之下,关于策略、计划和经过测试的规则的记忆文件只有在 Claude 自己推导出来时才存在,除非 Claude 将它们写下来,否则它们就会消失。

Fable 5 相应地组织了其记忆。其 global.md 文件充当仪表板,持有当前目标、解决道馆(赢得徽章的挑战)的预写计划以及模型自身使用记忆的规则。locations 文件夹持有导航特定路线的计划,gameplay 文件夹持有基于它对游戏运作方式的了解而制定的策略。例如,在连续七个精灵球未能抓住一只鲤鱼王(最容易捕捉的 Pokémon 之一)后,Claude 写道:“如果连续 3+ 个球失败,改变时机(在菜单步骤之间插入额外的‘等待’按键)- 这样做后捕捉成功了。”

凭借更小的记忆文件夹,Fable 5 在游戏中取得了比 Sonnet 3.7 更大的进展。Opus 5.5 采取了类似的方法:它保持一个小文件夹的记忆笔记,跟踪其当前目标和下一步,并在游戏过程中重写它们,最终击败了游戏。

引导 Claude 编写记忆

我们发现,告诉 Claude 记忆是做什么用的,但不告诉它 如何 使用它,会有所帮助。在 CL-Bench 上,我们只是告诉 Claude 有一个记忆文件夹可用。这种一般性的指导足以让 Opus 4.7 和 Opus 5 有效地使用记忆,并给两者带来了明显的性能提升(图 3)。

我们还测试了给模型提供关于它们应该向记忆写入什么的具体规则,每个测试一条规则。我们比较了每个模型在有每条规则的情况下从记忆中获得的增益与没有规则时的增益。当我们将规则设置为“仅记录失败”时,Opus 5 和 Opus 4.7 都失去了记忆赋予的大部分性能提升(图 5,右侧)。对于更强的模型,让它们自由判断显著性比预先设定固定规则更有效,而这些规则最终可能会削弱性能。

我们还注意到,引导对较旧的模型帮助最大。例如,Sonnet 4.6 经常不读取其记忆目录中的文件,并且未能测试其关于答案为何错误的理论。

在这种情况下,提示 Claude 在回答问题之前阅读其记忆文件——然后显式地测试其理论——几乎使其基准分数翻倍(图 5,左侧)。Sonnet 5 会自动这样做。在没有被提示的情况下,它在 10 次中有 9 次在回答问题前读取了其记忆。相比之下,Sonnet 4.6 这样做的时间不到一半。

对于前沿 Claude 模型,我们通常在有人要求他们时或当某事明显值得记住时,给予简单的指导以创建记忆笔记,并将这种判断留给 Claude。

“做梦”可以纠正记忆

由于 Claude 根据其在会话期间判断为显著的内容写入记忆,从一开始就错误或在环境变化后漂移的笔记可能在后续会话中被 Claude 读取并信任。

“做梦”给了 Claude 一种方法,让其笔记与原始转录文本进行对比测试(图 6)。当 Claude 使用带有挂载记忆目录的 Managed Agents 玩 Pokémon 时,我们看到这方面的一个正面例子。

在游戏的一部分中,玩家需要穿过月见山,这是一个洞穴系统,入口在地图西侧,出口在东侧。入口处附近有一个陷阱:一个单向悬崖,会将玩家掉落回他们来的路线,没有明显的攀爬回去的方法。Claude 使用宝可梦中心(位于山入口的一栋建筑)作为地标,因此它是否会走出悬崖取决于它认为宝可梦中心位于山的哪一侧。

有一次,Claude 错误地写下宝可梦中心在东边。当它走出宝可梦中心时,它宣布:“月见山在我身后”,并更新了其笔记:“月见山已完成。”但月见山实际上不在它身后。几步之后,Claude 走出了悬崖,落回了它来的路线上(图 7)。它的导航工具没有显示坠落,所以 Claude 得出结论:“我 overshoot 了很远的西边”,并且它之前在 th

查看原文

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.

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).

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.

Memory notes

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.

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?

Memory can be a prediction about what the future will need

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.

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.

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.

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.

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.

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 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).

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 has learned to judge salience

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).

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, by comparison, wrote nine files in two folders, plus a single top-level file called global.md, and earned four badges.

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.

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 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.”

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.

Steering Claude to write memory

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).

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.

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.

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.

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

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.

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.

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.

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.

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.

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.

Dreaming can build new memory representations

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.

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.

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 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.

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.

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.

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.

Dreaming can promote notes up the memory hierarchy

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.

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’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.

Dreaming can focus memory on a specific goal

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.

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.

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).

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.

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.

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

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.

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.

Thinking backward, looking forward

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.

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).

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.

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.

See our cookbooks for getting started with dreaming and knowledge wikis.

原文版权归 官方博客 · Anthropic / Meta / xAI 及原作者所有,本站转载仅供阅读。如需删除,请联系 support@aisa.one。