文章目录
阅读模式
已读 0%

扩展 Managed Agents:将大脑与双手解耦

Scaling Managed Agents: Decoupling the brain from the hands

阅读原文
段落导航
原文译文
原文

Get started with Claude Managed Agents by following our docs.

译文

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

原文

A running topic on the Engineering Blog is how to build effective agents and design harnesses for long-running work.

译文

工程博客上反复出现的一个话题是:如何构建有效的智能体,以及如何为长时间运行的工作设计框架(harness)。

原文

A common thread across this work is that harnesses encode assumptions about what Claude can’t do on its own.

译文

这项工作的一条共同主线是:框架会编码关于 Claude 自身无法完成哪些事情的假设。

原文

However, those assumptions need to be frequently questioned because they can go stale as models improve.

译文

然而,这些假设需要被频繁质疑,因为随着模型改进,它们可能会过时。

原文

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

译文

仅举一例,在先前的工作中,我们发现 Claude Sonnet 4.5 会在感觉到上下文限制临近时过早收尾任务——这种行为有时被称为“上下文焦虑”。

原文

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.

译文

但当我们把同一个框架用在 Claude Opus 4.5 上时,我们发现该行为消失了。

原文

The resets had become dead weight.

译文

这些重置已经变成了累赘。

原文

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:Claude Platform 中的一项托管服务,它通过一小组接口替你运行长时程智能体,这些接口的设计目标是比任何特定实现都更长久——包括我们今天运行的实现。

原文

Building Managed Agents meant solving an old problem in computing: how to design a system for “programs as yet unthought of.”

译文

构建 Managed Agents 意味着解决计算领域的一个老问题:如何为“尚未被想到的程序”设计系统。

原文

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 read() command is agnostic as to whether it’s accessing a disk pack from the 1970s or a modern SSD.

译文

read() 命令并不关心自己访问的是 1970 年代的磁盘组还是现代 SSD。

原文

The abstractions on top stayed stable while the implementations underneath changed freely.

译文

上层的抽象保持稳定,而下层的实现可以自由变化。

原文

Managed Agents follow the same pattern.

译文

Managed Agents 遵循同样的模式。

原文

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

译文

我们虚拟化了智能体的各个组件:会话(session,记录所发生一切的仅追加日志)、框架(调用 Claude 并将 Claude 的工具调用路由到相关基础设施的循环)以及沙箱(sandbox,Claude 可以在其中运行代码和编辑文件的执行环境)。

原文

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.

译文

我们对这些接口的形态有明确主张,但对其背后运行什么并不在意。

原文

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.

译文

在宠物 vs 牲畜的类比中,宠物是有名字、需要手工照料的个体,你不能承受失去它,而牲畜则是可互换的。

原文

In our case, the server became that pet; if a container failed, the session was lost.

译文

在我们的案例中,服务器变成了那只宠物;如果容器失败,session 就会丢失。

原文

If a container was unresponsive, we had to nurse it back to health.

译文

如果容器无响应,我们必须把它照料回健康状态。

原文

Nursing containers meant debugging unresponsive stuck sessions.

译文

照料容器意味着要调试无响应、卡住的 session。

原文

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.

译文

我们唯一的观察窗口是 WebSocket 事件流,但它无法告诉我们故障发生在哪里,这意味着框架中的 bug、事件流中的数据包丢失,或容器离线,看起来都完全一样。

原文

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.

译文

要弄清楚出了什么问题,工程师必须在容器内打开一个 shell,但由于那个容器通常也保存着用户数据,这种方法本质上意味着我们缺乏调试能力。

原文

A second issue was that the harness assumed that whatever Claude worked on lived in the container with it.

译文

第二个问题是,框架假设 Claude 处理的任何东西都与它一起存在于容器中。

原文

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.

译文

当客户要求我们把 Claude 连接到他们的虚拟私有云(virtual private cloud)时,他们要么必须将他们的网络与我们的网络做对等互联,要么在他们自己的环境中运行我们的框架。

原文

An assumption baked into the harness became a problem when we wanted to connect it to different infrastructure.

译文

当我想把它连接到不同的基础设施时,固化在框架中的一个假设就成了问题。

原文

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

译文

我们得出的解决方案是将我们视为“大脑”的部分(Claude 及其框架)与“手”(执行操作的沙箱和工具)以及“session”(session 事件的日志)解耦。

原文

Each became an interface that made few assumptions about the others, and each could fail or be replaced independently.

译文

每个都成为一个接口,对彼此几乎不做假设,并且每个都可以独立失败或被替换。

原文

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.

译文

它像调用任何其他工具一样调用容器: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.

译文

如果容器死了,框架会将失败捕获为工具调用错误,并将其传回给 Claude。

原文

If Claude decided to retry, a new container could be reinitialized with a standard recipe: provision({resources}).

译文

如果 Claude 决定重试,可以用标准配方重新初始化一个新容器:provision({resources})。

原文

We no longer had to nurse failed containers back to health.

译文

我们不再需要把失败的容器照料回健康状态。

原文

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.

译文

因为 session 日志位于框架之外,框架中没有任何东西需要在崩溃后存活。

原文

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.

译文

当其中一个失败时,可以用 wake(sessionId) 重启一个新的,使用 getSession(id) 取回事件日志,并从最后一个事件继续。

原文

During the agent loop, the harness writes to the session with emitEvent(id, event) in order to keep a durable record of events.

译文

在智能体循环期间,框架使用 emitEvent(id, event) 写入 session,以保留事件的持久记录。

原文

The security boundary.

译文

安全边界。

原文

In the coupled design, any untrusted code that Claude generated was run in the same container as credentials—so a prompt injection only had to convince Claude to read its own environment.

译文

在耦合式设计中,Claude 生成的任何不受信任代码都与凭证运行在同一个容器里——因此一次提示词注入只需说服 Claude 读取它自己的环境即可。

原文

Once an attacker has those tokens, they can spawn fresh, unrestricted sessions and delegate work to them.

译文

一旦攻击者拿到这些 token,他们就能启动全新的、不受限制的 session,并把工作委派给它们。

原文

Narrow scoping is an obvious mitigation, but this encodes an assumption about what Claude can't do with a limited token—and Claude is getting increasingly smart.

译文

收窄权限范围是一种显而易见的缓解措施,但这暗含了一个关于 Claude 用受限 token 做不了什么的假设——而 Claude 正变得越来越聪明。

原文

The structural fix was to make sure the tokens are never reachable from the sandbox where Claude’s generated code runs.

译文

结构性的修复办法,是确保从运行 Claude 生成代码的 sandbox 中永远无法触及这些 token。

原文

We used two patterns to ensure this.

译文

我们用两种模式来确保这一点。

原文

Auth can be bundled with a resource or held in a vault outside the sandbox.

译文

认证信息可以随资源一起打包,也可以存放在 sandbox 之外的保险库(vault)中。

原文

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,我们在 sandbox 初始化时用每个仓库的 access token 克隆仓库,并将其接入本地 git remote。

原文

Git push and pull work from inside the sandbox without the agent ever handling the token itself.

译文

Git push 和 pull 可以在 sandbox 内部完成,而智能体(agent)全程无需自己处理 token。

原文

For custom tools, we support MCP and store OAuth tokens in a secure vault.

译文

对于自定义工具,我们支持 MCP,并把 OAuth token 存放在安全的保险库中。

原文

Claude calls MCP tools via a dedicated proxy; this proxy takes in a token associated with the session.

译文

Claude 通过一个专用代理调用 MCP 工具;该代理接收与 session 关联的 token。

原文

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.

译文

harness 始终不会接触到任何凭证。

原文

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.

译文

长周期任务常常超出 Claude 上下文窗口的长度,而解决这一问题的标准做法,都涉及对保留什么内容做出不可逆的决定。

原文

We’ve explored these techniques in prior work on context engineering.

译文

我们在之前关于上下文工程(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.

译文

例如,压缩(compaction)让 Claude 保存其上下文窗口的摘要,记忆工具则让 Claude 把上下文写入文件,从而实现跨 session 的学习。

原文

This can be paired with context trimming, which selectively removes tokens such as old tool results or thinking blocks.

译文

这可以与上下文裁剪(context trimming)配合使用,后者有选择地移除旧工具结果或思考块等 token。

原文

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.

译文

很难知道未来的轮次会需要哪些 token。

原文

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.

译文

如果消息经过压缩步骤的转换,harness 会把被压缩的消息从 Claude 的上下文窗口中移除,而这些消息只有被存储起来才能恢复。

原文

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.

译文

例如,上下文可以是 REPL 中的一个对象,LLM 通过编写代码以编程方式访问它,对它进行过滤或切片。

原文

In Managed Agents, the session provides this same benefit, serving as a context object that lives outside Claude’s context window.

译文

在 Managed Agents 中,session 提供了同样的好处,充当一个位于 Claude 上下文窗口之外的上下文对象。

原文

But rather than be stored within the sandbox or REPL, context is durably stored in the session log.

译文

但上下文不是存放在 sandbox 或 REPL 中,而是持久地存储在 session 日志里。

原文

The interface, getEvents(), allows the brain to interrogate context by selecting positional slices of the event stream.

译文

接口 getEvents() 允许大脑(brain)通过选取事件流中的位置切片来查询上下文。

原文

The interface can be used flexibly, allowing the brain to pick up from wherever it last stopped reading, rewinding a few events before a specific moment to see the lead up, or rereading context before a specific action.

译文

该接口可以灵活使用,让大脑从上次停止读取的位置继续读取,回退到某个特定时刻之前的几个事件以查看其前因,或在某个特定动作之前重读上下文。

原文

Any fetched events can also be transformed in the harness before being passed to Claude’s context window.

译文

任何取回的事件也可以在 harness 中先做转换,再传入 Claude 的上下文窗口。

原文

These transformations can be whatever the harness encodes, including context organization to achieve a high prompt cache hit rate and context engineering.

译文

这些转换可以是 harness 所编码的任何内容,包括为实现高提示词缓存命中率而做的上下文组织,以及上下文工程。

原文

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.

译文

我们把可恢复的上下文存储(在 session 中)与任意的上下文管理(在 harness 中)这两个关注点分离开来,因为我们无法预测未来的模型需要什么样的具体上下文工程。

原文

The interfaces push that context management into the harness, and only guarantee that the session is durable and available for interrogation.

译文

这些接口把上下文管理推给 harness,只保证 session 是持久的、可供查询的。

原文

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.

译文

当团队希望 Claude 针对其自有 VPC 中的资源工作时,唯一的路径是将其网络与我们的网络对等互联,因为承载框架的容器假定所有资源都紧邻它。

原文

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.

译文

对每个大脑而言,在容器完成配置之前无法进行任何推理;每个 session 都要预先支付完整的容器启动成本。

原文

Every session, even ones that would never touch the sandbox, had to clone the repo, boot the process, fetch pending events from our servers.

译文

每个 session——即便是那些永远不会接触沙箱的——都必须克隆 repo、启动进程、从我们的服务器拉取待处理事件。

原文

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.

译文

这段空耗时间体现为首 token 时延(time-to-first-token,TTFT),它衡量的是一个 session 从接受任务到产出第一个响应 token 之间等待的时间。

原文

TTFT is the latency the user most acutely feels.

译文

TTFT 是用户感受最强烈的延迟。

原文

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.

译文

将大脑与手解耦意味着,容器只会在需要时由大脑通过工具调用 (execute(name, input) → string) 进行配置。

原文

So a session that didn't need a container right away didn't wait for one.

译文

因此,不需要立刻用到容器的 session 就不必等待容器。

原文

Inference could start as soon as the orchestration layer pulled pending events from the session log.

译文

只要编排层从 session 日志中拉取到待处理事件,推理就可以开始。

原文

Using this architecture, our p50 TTFT dropped roughly 60% and p95 dropped over 90%.

译文

采用这一架构后,我们的 p50 TTFT 下降了约 60%,p95 下降了超过 90%。

原文

Scaling to many brains just meant starting many stateless harnesses, and connecting them to hands only if needed.

译文

扩展到多个大脑只意味着启动多个无状态的框架,并且仅在需要时将它们连接到手。

原文

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.

译文

在实践中,这意味着 Claude 必须对多个执行环境进行推理,并决定把工作派发到哪里——这比在单一 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.

译文

随着智能水平提升,单个容器反而成了限制:当该容器发生故障时,大脑所触及的每一只手的状态都会丢失。

原文

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.

译文

将大脑与手解耦,使每只手都成为一个工具 execute(name, input) → string:输入一个名称和输入,返回一个字符串。

原文

That interface supports any custom tool, any MCP server, and our own tools.

译文

该接口支持任何自定义工具、任何 MCP server,以及我们自己的工具。

原文

The harness doesn’t know whether the sandbox is a container, a phone, or a Pokémon emulator.

译文

框架并不知道沙箱是一个容器、一部手机,还是一个 Pokémon 模拟器。

原文

And because no hand is coupled to any brain, brains can pass hands to one another.

译文

而且由于任何手都不与任何大脑耦合,大脑之间可以互相传递手。

原文

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,我们的目标是设计一个能够容纳未来围绕 Claude 的框架、沙箱或其他组件的系统。

原文

Managed Agents is a meta-harness in the same spirit, unopinionated about the specific harness that Claude will need in the future.

译文

Managed Agents 是同样理念下的一个元框架,它不对 Claude 未来需要哪种具体框架预设立场。

原文

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.

译文

例如,Claude Code 就是一个出色的框架,我们在各类任务中广泛使用它。

原文

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.

译文

Managed Agents 可以容纳上述任何一种,并随时间推移与 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).

译文

元框架设计意味着对 Claude 周边的接口持有明确主张:我们预期 Claude 会需要操作状态(session)和执行计算(sandbox)的能力。

原文

We also expect that Claude will require the ability to scale to many brains and many hands.

译文

我们还预期 Claude 会需要扩展到许多大脑和许多只手的能力。

原文

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.

译文

但我们不对 Claude 需要的大脑或手的数量与位置做任何假设。

原文

Written by Lance Martin, Gabe Cemaj, and Michael Cohen.

译文

作者:Lance Martin、Gabe Cemaj 和 Michael Cohen。

原文

Thanks to Nodir Turakulov and Jeremy Fox for helpful conversations on these topics.

译文

感谢 Nodir Turakulov 和 Jeremy Fox 就这些话题进行的有益讨论。

原文

Special thanks to the Agents API team and Jake Eaton for their contributions.

译文

特别感谢 Agents API 团队和 Jake Eaton 的贡献。