扩展托管智能体:将大脑与双手解耦

Scaling Managed Agents: Decoupling the brain from the hands

Anthropic · 2026-04-08 · Anthropic Engineering ↗

打开互动全文版(逐段中英对照 + 针对本篇提问)→

摘要 · Abstract

Anthropic 的托管智能体(Managed Agents)是 Claude 平台中的一项托管服务,通过一小组稳定的接口运行长时程智能体,这些接口的设计目标是比任何具体实现都更持久。其核心论点是:智能体执行框架(harness)编码了关于 Claude 自身无法完成哪些任务的假设,而这些假设会随着模型能力的提升而过时,因此系统应当将“大脑”(Claude 及其执行框架)与“双手”(沙箱与工具)以及“会话”(仅追加的事件日志)解耦。这种分离使容器和执行框架成为可替换的“牲口”而非需要精心照料的“宠物”,能够通过从持久化的会话日志恢复来应对执行框架故障,并建立起一道安全边界,使凭证不进入运行生成代码的沙箱。它还带来了性能提升:容器仅在需要时才被配置,使 p50 首 token 时间缩短约 60%、p95 缩短逾 90%,同时允许多个“大脑”连接多个“双手”。结论是:托管智能体充当一种元执行框架(meta-harness),它对围绕 Claude 的接口有明确主张,而不针对具体实现,因此随着模型智能的扩展,未来的执行框架和沙箱都能被容纳。

Anthropic's Managed Agents is a hosted service in the Claude Platform that runs long-horizon agents through a small set of stable interfaces designed to outlast any particular implementation. The core argument is that agent harnesses encode assumptions about what Claude cannot do on its own, and these assumptions go stale as models improve, so the system should decouple the brain (Claude and its harness) from the hands (sandboxes and tools) and the session (an append-only event log). This separation turns containers and harnesses into replaceable cattle rather than hand-tended pets, enables recovery from harness failure by resuming from the durable session log, and creates a security boundary that keeps credentials out of the sandbox where generated code runs. It also improves performance: containers are provisioned only when needed, cutting p50 time-to-first-token by roughly 60% and p95 by over 90%, while allowing many brains to connect to many hands. The conclusion is that Managed Agents functions as a meta-harness, opinionated about interfaces around Claude rather than about specific implementations, so future harnesses and sandboxes can be accommodated as model intelligence scales.

核心贡献 · Key contributions

局限 · Limitations

章节 · Sections(共 6)

全文 · Full text(逐段中英对照)

扩展托管智能体:将大脑与双手解耦 Scaling Managed Agents:Decoupling the brain from the hands

* 03 会话不是 Claude 的上下文窗口

* 03 The session is not Claude's context window

2026 年 5 月 18 日 Anthropic 收购 Stainless

May 18, 2026 Anthropic acquires Stainless

_按照我们的文档开始使用 Claude Managed Agents。_

_Get started with Claude Managed Agents by following our docs._

工程博客上的一个持续话题是如何构建有效的智能体以及为长时间运行的工作设计 harness。这项工作中的一个共同点是,harness 编码了关于 Claude 自身无法完成什么的假设。然而,这些假设需要经常被质疑,因为随着模型改进,它们可能会过时。

A running topic on the Engineering Blog is how to build effective agents and design harnesses for long-running work. A common thread across this work is that harnesses encode assumptions about what Claude can't do on its own. However, those assumptions need to be frequently questioned because they can go stale as models improve.

仅举一个例子,在之前的工作中,我们发现 Claude Sonnet 4.5 在感觉到其上下文限制临近时会过早地结束任务——这种行为有时被称为“上下文焦虑”。我们通过向 harness 添加上下文重置来解决这个问题。但是当我们在 Claude Opus 4.5 上使用相同的 harness 时,我们发现这种行为消失了。重置已成为累赘。

As just one example, in prior work we found that Claude Sonnet 4.5 would wrap up tasks prematurely as it sensed its context limit approaching—a behavior sometimes called “context anxiety.” We addressed this by adding context resets to the harness. But when we used the same harness on Claude Opus 4.5, we found that the behavior was gone. The resets had become dead weight.

我们预计 harness 会持续演进。因此我们构建了 Managed Agents:这是 Claude Platform 中的一项托管服务,通过一小组旨在比任何特定实现(包括我们今天所运行的实现)更持久的接口,代表你运行长时程智能体。

We expect harnesses to continue evolving. So we built Managed Agents: a hosted service in the Claude Platform that runs long-horizon agents on your behalf through a small set of interfaces meant to outlast any particular implementation—including the ones we run today.

构建 Managed Agents 意味着要解决计算领域的一个老问题:如何为“尚未被想到的程序”设计系统。几十年前,操作系统通过将硬件虚拟化为抽象——_进程、文件_——来解决这个问题,这些抽象足够通用,能够容纳当时尚不存在的程序。这些抽象比硬件更持久。\(\text{read}()\) 命令并不关心它访问的是 1970 年代的磁盘组还是现代 SSD。上层的抽象保持稳定,而下层的实现则可以自由变化。

Building Managed Agents meant solving an old problem in computing: how to design a system for "programs as yet unthought of." Decades ago, operating systems solved this problem by virtualizing hardware into abstractions—_process, file_—general enough for programs that didn't exist yet. The abstractions outlasted the hardware. The \(\text{read}()\) command is agnostic as to whether it's accessing a disk pack from the 1970s or a modern SSD. The abstractions on top stayed stable while the implementations underneath changed freely.

Managed Agents 遵循同样的模式。我们对智能体的各个组件进行了虚拟化:会话(session,记录所发生一切事情的仅追加日志)、harness(调用 Claude 并将 Claude 的工具调用路由到相关基础设施的循环)以及沙箱(sandbox,Claude 可以在其中运行代码和编辑文件的执行环境)。这使得每个组件的实现都可以在不干扰其他组件的情况下被替换。我们对这些接口的形态有明确主张,但对它们背后运行什么并不在意。

Managed Agents follow the same pattern. We virtualized the components of an agent: a session (the append-only log of everything that happened), a harness (the loop that calls Claude and routes Claude's tool calls to the relevant infrastructure), and a sandbox (an execution environment where Claude can run code and edit files). This allows the implementation of each to be swapped without disturbing the others. We're opinionated about the shape of these interfaces, not about what runs behind them.

不要采用宠物式管理 Don’t adopt a pet

我们一开始将所有智能体组件放入单个容器中,这意味着会话、智能体运行框架和沙箱共享同一环境。这种做法有其好处,包括文件编辑是直接的系统调用,而且无需设计服务边界。

We started by placing all agent components into a single container, which meant the session, agent harness, and sandbox all shared an environment. There were benefits to this approach, including that file edits are direct syscalls, and there were no service boundaries to design.

但将所有内容耦合进一个容器后,我们遇到了一个老旧的基建设施问题:我们养了一只**宠物**。在“宠物与牲畜”的类比中,宠物是有名字、需亲手照料、不能失去的个体,而牲畜则是可互换的。在我们的情形中,服务器就成了那只宠物;如果容器故障,会话就会丢失。如果容器无响应,我们就得把它“护理”回健康状态。

But by coupling everything into one container, we ran into an old infrastructure problem: we'd adopted a _pet_. In the pets-vs-cattle analogy, a pet is a named, hand-tended individual you can't afford to lose, while cattle are interchangeable. In our case, the server became that pet; if a container failed, the session was lost. If a container was unresponsive, we had to nurse it back to health.

护理容器意味着要调试无响应的卡死会话。我们唯一的观察窗口是 WebSocket 事件流,但它无法告诉我们故障**发生在哪里**,这意味着运行框架中的 bug、事件流中的丢包,或容器离线,表现全都一样。要弄清楚出了什么问题,工程师必须在容器内打开一个 shell,但由于该容器通常还存有用户数据,这种做法实质上意味着我们缺乏调试能力。

Nursing containers meant debugging unresponsive stuck sessions. Our only window in was the WebSocket event stream, but that couldn't tell us _where_ failures arose, which meant that a bug in the harness, a packet drop in the event stream, or a container going offline all presented the same. To figure out what went wrong, an engineer had to open a shell inside the container, but because that container often also held user data, that approach essentially meant we lacked the ability to debug.

第二个问题是,运行框架假定 Claude 所处理的一切都与其同处一个容器中。当客户要求我们将 Claude 连接到他们的虚拟私有云时,他们要么必须将其网络与我们的网络对等互联,要么在他们自己的环境中运行我们的运行框架。当我们要将运行框架连接到不同的基础设施时,这一深植于运行框架中的假设就成了问题。

A second issue was that the harness assumed that whatever Claude worked on lived in the container with it. When customers asked us to connect Claude to their virtual private cloud, they had to either peer their network with ours, or run our harness in their own environment. An assumption baked into the harness became a problem when we wanted to connect it to different infrastructure.

将大脑与双手解耦 Decouple the brain from the hands

我们得出的解决方案是将我们视为“大脑”的部分(Claude 及其运行框架)与“双手”(执行操作的沙箱和工具)以及“会话”(会话事件日志)解耦。每个部分都成为一个接口,对其他部分的假设很少,并且每个部分都可以独立失败或被替换。

The solution we arrived at was to decouple what we thought of as the “brain” (Claude and its harness) from both the “hands” (sandboxes and tools that perform actions) and the “session” (the log of session events). Each became an interface that made few assumptions about the others, and each could fail or be replaced independently.

**运行框架离开容器。** 将大脑与双手解耦意味着运行框架不再位于容器内。它像调用任何其他工具一样调用容器:execute(name, input) → string。容器变成了“牲畜”。如果容器死亡,运行框架将故障捕获为工具调用错误并将其传回给 Claude。如果 Claude 决定重试,可以使用标准配方重新初始化一个新容器:provision({resources})。我们不再需要将失败的容器护理回健康状态。

**The harness leaves the container.** Decoupling the brain from the hands meant the harness no longer lived inside the container. It called the container the way it called any other tool: execute(name, input) → string. The container became cattle. If the container died, the harness caught the failure as a tool-call error and passed it back to Claude. If Claude decided to retry, a new container could be reinitialized with a standard recipe: provision({resources}). We no longer had to nurse failed containers back to health.

**从运行框架故障中恢复。** 运行框架也变成了“牲畜”。由于会话日志位于运行框架之外,运行框架中没有任何内容需要在崩溃后存活。当其中一个失败时,可以使用 wake(sessionId)重新启动一个新的运行框架,使用 getSession(id)获取事件日志,并从最后一个事件恢复。在智能体循环期间,运行框架使用 emitEvent(id, event)写入会话,以保持事件的持久记录。

**Recovering from harness failure.** The harness also became cattle. Because the session log sits outside the harness, nothing in the harness needs to survive a crash. When one fails, a new one can be rebooted with wake(sessionId), use getSession(id) to get back the event log, and resume from the last event. During the agent loop, the harness writes to the session with emitEvent(id, event) in order to keep a durable record of events.

我们使用两种模式来确保这一点。认证可以与资源捆绑在一起,或者存放在沙箱外部的保险库中。对于 Git,我们在沙箱初始化期间使用每个仓库的访问令牌克隆仓库,并将其连接到本地 git 远程。Git push 和 pull 从沙箱内部工作,而智能体从不处理令牌本身。对于自定义工具,我们支持 MCP 并将 OAuth 令牌存储在安全的保险库中。Claude 通过专用代理调用 MCP 工具;该代理接收与会话关联的令牌。然后代理可以从保险库中获取相应的凭证并调用外部服务。运行框架永远不会知道任何凭证。

We used two patterns to ensure this. Auth can be bundled with a resource or held in a vault outside the sandbox. For Git, we use each repository’s access token to clone the repo during sandbox initialization and wire it into the local git remote. Git push and pull work from inside the sandbox without the agent ever handling the token itself. For custom tools, we support MCP and store OAuth tokens in a secure vault. Claude calls MCP tools via a dedicated proxy; this proxy takes in a token associated with the session. The proxy can then fetch the corresponding credentials from the vault and make the call to the external service. The harness is never made aware of any credentials.

会话并非 Claude 的上下文窗口 The session is not Claude’s context window

长程任务常常超出 Claude 上下文窗口的长度,而应对这一问题的标准做法都涉及关于保留哪些内容的不可逆决策。我们在先前关于上下文工程的工作中已探索过这些技术。例如,压缩(compaction)让 Claude 保存其上下文窗口的摘要,记忆工具则让 Claude 将上下文写入文件,从而实现跨会话的学习。这可以与上下文裁剪(context trimming)配合使用,后者选择性地移除诸如旧的工具结果或思考块之类的 token。

Long-horizon tasks often exceed the length of Claude's context window, and the standard ways to address this all involve irreversible decisions about what to keep. We've explored these techniques in prior work on context engineering. For example, compaction lets Claude save a summary of its context window and the memory tool lets Claude write context to files, enabling learning across sessions. This can be paired with context trimming, which selectively removes tokens such as old tool results or thinking blocks.

但是,选择性地保留或丢弃上下文的不可逆决策可能导致失败。很难预知未来的轮次会需要哪些 token。如果消息经过压缩步骤的转换,harness 会将已压缩的消息从 Claude 的上下文窗口中移除,而这些消息只有在被存储的情况下才可恢复。先前的工作已探索过应对这一问题的方法,即把上下文存储为一个存在于上下文窗口_之外_的对象。例如,上下文可以是 REPL 中的一个对象,LLM 通过编写代码对其进行过滤或切片,以编程方式访问它。

But irreversible decisions to selectively retain or discard context can lead to failures. It is difficult to know which tokens the future turns will need. If messages are transformed by a compaction step, the harness removes compacted messages from Claude's context window, and these are recoverable only if they are stored. Prior work has explored ways to address this by storing context as an object that lives _outside_ the context window. For example, context can be an object in a REPL that the LLM programmatically accesses by writing code to filter or slice it.

任何获取到的事件也可以在 harness 中经过转换,然后再传入 Claude 的上下文窗口。这些转换可以是 harness 所编码的任何内容,包括为实现高提示缓存命中率而进行的上下文组织,以及上下文工程。我们将会话中可恢复的上下文存储与 harness 中任意的上下文管理这两个关注点分离开来,因为我们无法预测未来的模型将需要何种具体的上下文工程。这些接口将上下文管理推给 harness,并且只保证会话是持久的且可供查询。

Any fetched events can also be transformed in the harness before being passed to Claude's context window. These transformations can be whatever the harness encodes, including context organization to achieve a high prompt cache hit rate and context engineering. We separated the concerns of recoverable context storage in the session and arbitrary context management in the harness because we can't predict what specific context engineering will be required in future models. The interfaces push that context management into the harness, and only guarantee that the session is durable and available for interrogation.

多脑多手 Many brains, many hands

**多脑。** 将大脑与手解耦,解决了我们最早的一批客户投诉之一。当团队希望 Claude 针对其自有 VPC 中的资源工作时,唯一的路径是将其网络与我们的网络对等互联,因为承载 harness 的容器假定所有资源都紧邻其旁。一旦 harness 不再位于容器内,这一假定便不复存在。同样的改动还带来了性能收益。最初我们把大脑放进容器时,这意味着多个大脑就需要同样多的容器。对每个大脑而言,在容器完成配置之前无法进行任何推理;每个会话都要预先支付完整的容器启动成本。每个会话,即便是永远不会触及沙箱的会话,都必须克隆仓库、启动进程、从我们的服务器拉取待处理事件。

**Many brains.** Decoupling the brain from the hands solved one of our earliest customer complaints. When teams wanted Claude to work against resources in their own VPC, the only path was to peer their network with ours, because the container holding the harness assumed every resource sat next to it. Once the harness was no longer in the container, that assumption went away. The same change had a performance payoff. When we initially put the brain in a container, it meant that many brains required as many containers. For each brain, no inference could happen until that container was provisioned; every session paid the full container setup cost up front. Every session, even ones that would never touch the sandbox, had to clone the repo, boot the process, fetch pending events from our servers.

这段空转时间以首词元时延(time-to-first-token,TTFT)来衡量,它度量的是一个会话从接受工作到产出首个响应词元之间的等待时长。TTFT 是用户感受最强烈的延迟。

That dead time is expressed in time-to-first-token (TTFT), which measures how long a session waits between accepting work and producing its first response token. TTFT is the latency the user most acutely _feels_.

将大脑与手解耦意味着,容器由大脑通过工具调用 \(execute(name, input) → string\) 仅在需要时才进行配置。因此,不需要立即使用容器的会话就不必等待容器。只要编排层从会话日志中拉取到待处理事件,推理便可开始。采用这一架构后,我们的 p50 TTFT 下降了约 60%,p95 下降了 90% 以上。扩展到多个大脑只需启动多个无状态 harness,并仅在需要时将它们与手连接。

Decoupling the brain from the hands means that containers are provisioned by the brain via a tool call \(execute(name, input) → string\) only if they are needed. So a session that didn't need a container right away didn't wait for one. Inference could start as soon as the orchestration layer pulled pending events from the session log. Using this architecture, our p50 TTFT dropped roughly 60% and p95 dropped over 90%. Scaling to many brains just meant starting many stateless harnesses, and connecting them to hands only if needed.

**多手。** 我们还希望能够将每个大脑连接到多只手。在实践中,这意味着 Claude 必须对多个执行环境进行推理,并决定将工作发送到哪里——这比在单一 shell 中操作是更难的认知任务。我们最初把大脑放在单个容器中,是因为早期模型不具备这种能力。随着智能水平的规模扩张,单个容器反而成了限制:当该容器发生故障时,大脑所触及的每一只手的状态都会丢失。

**Many hands.** We also wanted the ability to connect each brain to many hands. In practice, this means Claude must reason about many execution environments and decide where to send work—a harder cognitive task than operating in a single shell. We started with the brain in a single container because earlier models weren't capable of this. As intelligence scaled, the single container became the limitation instead: when that container failed, we lost state for every hand that the brain was reaching into.

将大脑与手解耦使每只手都成为一个工具,\(execute(name, input) → string\):输入一个名称和输入,返回一个字符串。该接口支持任何自定义工具、任何 MCP 服务器以及我们自己的工具。harness 并不知道沙箱是一个容器、一部手机,还是一个 Pokémon 模拟器。而且由于没有任何一只手与任何大脑耦合,大脑之间可以互相传递手。

Decoupling the brain from the hands makes each hand a tool, \(execute(name, input) → string\): a name and input go in, and a string is returned. That interface supports any custom tool, any MCP server, and our own tools. The harness doesn't know whether the sandbox is a container, a phone, or a Pokémon emulator. And because no hand is coupled to any brain, brains can pass hands to one another.

结论 Conclusion

我们面临的挑战是一个由来已久的问题:如何为“尚未被想到的程序”设计系统。操作系统之所以能延续数十年,是因为它将硬件虚拟化为足够通用的抽象,从而能够容纳当时尚不存在的程序。借助 Managed Agents,我们旨在设计一个能够容纳未来围绕 Claude 的 harness、沙箱或其他组件的系统。

The challenge we faced is an old one: how to design a system for "programs as yet unthought of." Operating systems have lasted decades by virtualizing the hardware into abstractions general enough for programs that didn't exist yet. With Managed Agents, we aimed to design a system that accommodates future harnesses, sandboxes, or other components around Claude.

Managed Agents 是同一理念下的元 harness(meta-harness),对 Claude 未来所需的_具体_ harness 不作预设。相反,它是一个具有通用接口的系统,能够支持多种不同的 harness。例如,Claude Code 是一个出色的 harness,我们在各类任务中广泛使用它。我们还展示了任务专用的智能体 harness 在狭窄领域中表现优异。Managed Agents 可以容纳其中任何一种,并随时间推移与 Claude 的智能水平相匹配。

Managed Agents is a meta-harness in the same spirit, unopinionated about the _specific_ harness that Claude will need in the future. Rather, it is a system with general interfaces that allow many different harnesses. For example, Claude Code is an excellent harness that we use widely across tasks. We've also shown that task-specific agent harnesses excel in narrow domains. Managed Agents can accommodate any of these, matching Claude's intelligence over time.

元 harness 设计意味着要对围绕 Claude 的接口作出明确取舍:我们预期 Claude 将需要操作状态(会话)和执行计算(沙箱)的能力。我们还预期 Claude 将需要扩展到许多“大脑”和许多“手”的能力。我们设计这些接口,使其能够在长时间跨度内可靠且安全地运行。但我们不对 Claude 所需的大脑或手的数量与位置作任何假设。

Meta-harness design means being opinionated about the interfaces around Claude: we expect that Claude will need the ability to manipulate state (the session) and perform computation (the sandbox). We also expect that Claude will require the ability to scale to many brains and many hands. We designed the interfaces so that these can be run reliably and securely over long time horizons. But we make no assumptions about the number or location of brains or hands that Claude will need.

互动版:针对本篇提问 →

接着读 · Read next