Agents need a computer, not a container: @cloudflare/computer
Cloudflare has released an early preview of @cloudflare/computer, an open-source agent runtime that pushes against the default assumption that every agent needs its own container. The package's core is a durable, SQLite-backed virtual filesystem called a workspace, which can be shared across execution backends behind one exec(string, options) interface. Two backends are included: an isolate-based backend that translates shell code into JavaScript via just-bash and runs it in a worker, and a container backend using a FUSE mount so file changes are synced back. The post includes code showing how to attach the workspace to an agent on a Durable Object with @cloudflare/think, and argues isolates are the only realistic path to scaling to billions of agents because they can spin up, tear down, and hibernate with state. Aimed at engineers building agent harnesses. The library is in early preview and ships without benchmarks.
The most capable agents have something simple in common: they are given their own computer to work with.
Coding agents work this way. You give them a filesystem, a shell, tools, packages, and the ability to run code. They inspect the environment, make changes, test their work, and keep going. The computer gives the model a familiar way to act on the world. At Cloudflare, we’re working hard to provide the right primitives on which to build the most capable agents.
Today we’re introducing an early preview of @cloudflare/computer. The @cloudflare/computer package provides an agent runtime where the details and mechanics of what code runs in an isolate, a container sandbox, or a web browser are handled by the platform. Each agent gets a computer, the runtime optimizes for efficiency, and scalability.
We believe that in order to meet the growing demand for compute required by agentic systems we need to look to solutions beyond traditional containerization.
能力最强的 Agent 有一个简单的共同点:它们都有一台属于自己的电脑可以用。
编码 Agent 就是如此工作的。给它们文件系统、shell、工具、软件包,以及运行代码的能力。它们检查环境、做修改、验证自己的工作,然后继续迭代。这台电脑给了模型一个熟悉的行动方式。在 Cloudflare,我们正努力提供正确的原语,让最强大的 Agent 得以构建。
今天,我们带来 @cloudflare/computer 的早期预览。@cloudflare/computer 包提供一个 Agent 运行时,由平台处理代码到底运行在 isolate、容器沙箱还是网页浏览器中的各种细节与机制。每个 Agent 都获得一台电脑,运行时则针对效率和可扩展性进行优化。
我们相信,要满足 Agent 系统对算力日益增长的需求,必须把目光投向传统容器化之外的解决方案。
Changing how agents are built
We’ve seen a subtle evolution of this story over the past six months. At the start of the year, spinning up a container and running an agent inside of it was the norm. In recent months, we’ve seen a rapid move for agent harnesses to provide sandboxed code execution via tools. This separates the hands (the sandbox where work is done) from the brain (the agent loop).

构建 Agent 的方式正在改变
过去六个月里,我们看到这条故事线发生了微妙的变化。年初时,启动一个容器并在其中运行 Agent 还是常态。最近几个月,Agent harness 迅速转向通过工具提供沙箱化的代码执行。这把手(实际完成工作的沙箱)和大脑(Agent 循环)分开了。

No matter where the harness runs, giving every agent a container presents a challenge — across all the clouds, all the hyperscalers, there’s nowhere near enough compute in the world for every company to give each of their users’ agents their own containerized compute environment. This will not scale to hundreds of millions, then billions, of concurrent agents. This is why there is desperate, panicked industry demand for CPU compute, not just GPU compute.
无论 harness 运行在哪里,给每个 Agent 一个容器都会带来挑战——纵观所有云、所有超大规模云厂商,全世界的算力都远不足以让每家公司给自己每位用户的 Agent 分配一个独立的容器化计算环境。这无法扩展到数亿、乃至数十亿个并发 Agent。这正是整个行业对 CPU 算力、而不仅仅是 GPU 算力产生绝望而恐慌的需求的原因。
We’ve been working on this problem for a long time at Cloudflare, creating a more efficient compute primitive: isolates. We made that out-of-consensus bet almost 10 years ago when we introduced Cloudflare Workers. We made it again when we introduced Durable Objects almost six years ago. We made this bet because isolates are infinitely horizontally scalable. They spin up and tear down incredibly quickly. They can hibernate when the agent is idle, store the agent’s own state, and even spin up their own isolates to run untrusted code. Isolates are the best way to scale horizontally, and horizontal scale is what agents demand.

Cloudflare 长期致力于解决这个问题,我们创造了更高效的计算原语:isolate。大约十年前发布 Cloudflare Workers 时,我们下了这个逆共识的赌注;大约六年前推出 Durable Objects 时,我们又下了一次。我们押注 isolate,因为它可以无限水平扩展。它们启动和销毁极其迅速;Agent 空闲时可以休眠,保存 Agent 自己的状态,甚至能启动自己的 isolate 来运行不可信代码。isolate 是水平扩展的最佳方式,而水平扩展正是 Agent 所需要的。

Last year, we gave isolates the ability to spin up their own container sandboxes. From day one, Cloudflare’s architecture has been designed to run the agent harness in the isolate (in a Durable Object) and call an attached container on-demand as a tool. This allows you to utilize heavier compute primitives only when required, optimizing performance and cost. Durable Objects scale infinitely horizontally, and the attached container lets it scale vertically to perform any task. This is how we build agents ourselves, and we’re seeing customers build incredible things this way too.

But when we look at this need to have multiple underlying compute primitives to build agents (isolates and containers) and the need for our customers and developers to combine them themselves in userspace, we think we can do better. We think that we can provide a simpler abstraction.
That’s why we’re starting this experiment by shipping @cloudflare/computer as an open-source library, to learn with our customers who are pushing the bounds of running agents at scale.
去年,我们让 isolate 具备了启动自己的容器沙箱的能力。从第一天起,Cloudflare 的架构就设计为在 isolate(Durable Object)中运行 Agent harness,并将按需挂载的容器作为工具来调用。这样,你只在必要时使用更重的计算原语,从而优化性能和成本。Durable Object 无限水平扩展,而附加容器让它进行垂直扩展以执行任何任务。我们自己就是这样构建 Agent 的,也看到客户用这种方式做出了惊人的东西。

但当我们看到,构建 Agent 需要多种底层计算原语(isolate 和容器),而且客户和开发者需要在用户空间自行将它们组合起来时,我们认为可以做得更好,可以提供一种更简单的抽象。
因此,我们以开源库的形式发布 @cloudflare/computer 来开启这项实验,与那些正在突破 Agent 规模化边界的客户一起学习。
A shared filesystem across isolates and containers
The @cloudflare/computer package starts with a simple premise: what if we give an agent a primed filesystem, declaratively defined, containing everything required for the task at hand and a selection of execution environments to operate on those files, each with their own pros and cons regarding speed, capability and cost?
It turns out that agents today are surprisingly capable of selecting the right environment for the task at hand. A job that only needs to manipulate files, process data, or manage a git repository can run inside an isolate. A command that needs Linux, npm, or a native binary can run inside a container. Both work against the same files that are kept in sync with the source filesystem.

跨 isolate 与容器的共享文件系统
@cloudflare/computer 包从一个简单的设想出发:如果我们给 Agent 一个预先准备好、以声明式定义的文件系统,里面包含完成当前任务所需的一切,并提供一组执行环境来操作这些文件,每种环境在速度、能力和成本上各有优劣,会怎样?
事实证明,今天的 Agent 在选择合适环境方面相当出色。只需要操作文件、处理数据或管理 git 仓库的任务,可以在 isolate 中运行;需要 Linux、npm 或原生二进制文件的命令,则可以在容器中运行。两者都作用于同一套文件,并与源文件系统保持同步。

The @cloudflare/computer package provides a durable filesystem that you can use with git repositories, storage buckets or any files you choose. It provides tools that let you read, write and edit files using Code Mode or bash commands. All operations are gated, audited and observed, giving you fine-grained control over changes the agent is allowed to perform as well as a clear paper trail showing what the agent did.
@cloudflare/computer 包提供一个持久化的文件系统,可与 git 仓库、存储桶或你选择的任意文件一起使用。它提供的工具让你能用 Code Mode 或 bash 命令读取、写入和编辑文件。所有操作都经过门控、审计和观测,让你能细粒度地控制 Agent 可以执行的更改,并留下清晰的操作留痕,展示 Agent 做了什么。
How you use it
An instance of a @cloudflare/computer workspace can be instantiated on any Durable Object to provide a virtual filesystem and execution runtime.
It is installed via npm:
npm install @cloudflare/computer
The primary use case is to provide that filesystem and tooling to an agent. For example, here’s how to instantiate the workspace on an agent powered by @cloudflare/think intended to triage bug reports.
import { Think } from "@cloudflare/think";
import { Workspace, type DurableObjectStorageLike } from "@cloudflare/computer";
import { createWorkersAI } from "workers-ai-provider";
export class Agent extends Think {
override workspaceBash = false;
override workspace = new Workspace({
storage: this.ctx.storage,
useThink: true, // soon will not be needed
});
override getModel() {
return createWorkersAI({ binding: this.env.AI })("@cf/zai-org/glm-5.2");
}
override getSystemPrompt() {
return `
You are a bug triage agent.
Use the project in /workspace/repo to reproduce the bug, inspect the
code, make a focused fix when it is safe, and run verification. In your
final answer, include what you changed, which commands you ran, and
whether verification passed.`;
}
}
如何使用
@cloudflare/computer workspace 的实例可以在任意 Durable Object 上创建,以提供虚拟文件系统与执行运行时。
通过 npm 安装:
npm install @cloudflare/computer
主要用途是为 Agent 提供文件系统和工具。例如,下面演示如何在由 @cloudflare/think 驱动、用于分类 bug 报告的 Agent 上实例化 workspace。
import { Think } from "@cloudflare/think";
import { Workspace, type DurableObjectStorageLike } from "@cloudflare/computer";
import { createWorkersAI } from "workers-ai-provider";
export class Agent extends Think {
override workspaceBash = false;
override workspace = new Workspace({
storage: this.ctx.storage,
useThink: true, // soon will not be needed
});
override getModel() {
return createWorkersAI({ binding: this.env.AI })("@cf/zai-org/glm-5.2");
}
override getSystemPrompt() {
return `
You are a bug triage agent.
Use the project in /workspace/repo to reproduce the bug, inspect the
code, make a focused fix when it is safe, and run verification. In your
final answer, include what you changed, which commands you ran, and
whether verification passed.`;
}
}
Several execution backends are provided as part of the @cloudflare/computer package, or you can write your own. Here we wire up a Cloudflare Container.
import { Think } from "@cloudflare/think";
import { Workspace, WorkspaceProxy } from "@cloudflare/computer";
import {
CloudflareContainerBackend,
withWorkspaceContainer,
} from "@cloudflare/computer/backends/container";
export { WorkspaceProxy };
export class Agent extends withWorkspaceContainer(Think) {
override workspaceBash = false;
override workspace = new Workspace({
storage: this.ctx.storage,
useThink: true, // soon will not be needed
backends: [
new CloudflareContainerBackend({
container: () => this,
workspace: {
binding: "Agent",
id: this.ctx.id.toString(),
},
}),
],
});
/* Example code truncated for readability... */
}
Expose the file, git, and shell tools alongside product specific tools to reply to reported issues.
import { createAITools } from "@cloudflare/computer/tools";
import type { ToolSet } from "ai";
import { replyToIssue } from "./tools/github";
export class Agent extends withWorkspaceContainer(Think) {
override workspaceBash = false;
/* Example code truncated for readability... */
override getTools(): ToolSet {
return {
...createAITools({
workspace: this.workspace,
shell: {
defaultBackend: "container",
backends: {
container: {
description:
"Cloudflare Container with a full Linux userland: " +
"npm, node, package managers, test runners, and real " +
"binaries on $PATH. Use it when a task needs more than " +
"file manipulation.",
},
},
},
}),
replyToIssue,
};
}
}
The model can use tools during the agent loop, but you can also use the workspace API directly, for example, to prepare the environment before prompting the agent.
export class Agent extends withWorkspaceContainer(Think) {
override workspaceBash = false;
/* Example code truncated for readability... */
async startTriage(report: { title: string; body: string; repoUrl: string }) {
await this.workspace.fs.mkdir("/workspace", { recursive: true });
await this.workspace.fs.writeFile(
"/workspace/BUG_REPORT.md",
`# ${report.title}\n\n${report.body}\n`,
);
await this.workspace.git.clone({
url: report.repoUrl,
dir: "/workspace/repo",
});
return this.submitMessages([
{
id: crypto.randomUUID(),
role: "user",
parts: [
{
type: "text",
text: [
`Triage this bug: ${report.title}`,
"The bug report is in /workspace/BUG_REPORT.md.",
"The repository is checked out at /workspace/repo.",
].join("\n"),
},
],
},
]);
}
}
Check out the workspace repository for more examples of how to use the different backends and tools including a step-by-step tutorial walking through building an agent from scratch.
包内提供了几个执行后端,你也可以编写自己的后端。下面接上一个 Cloudflare Container。
import { Think } from "@cloudflare/think";
import { Workspace, WorkspaceProxy } from "@cloudflare/computer";
import {
CloudflareContainerBackend,
withWorkspaceContainer,
} from "@cloudflare/computer/backends/container";
export { WorkspaceProxy };
export class Agent extends withWorkspaceContainer(Think) {
override workspaceBash = false;
override workspace = new Workspace({
storage: this.ctx.storage,
useThink: true, // soon will not be needed
backends: [
new CloudflareContainerBackend({
container: () => this,
workspace: {
binding: "Agent",
id: this.ctx.id.toString(),
},
}),
],
});
/* Example code truncated for readability... */
}
将文件、git 和 shell 工具与产品特有的工具一起暴露出来,用于回复报告的 issue。
import { createAITools } from "@cloudflare/computer/tools";
import type { ToolSet } from "ai";
import { replyToIssue } from "./tools/github";
export class Agent extends withWorkspaceContainer(Think) {
override workspaceBash = false;
/* Example code truncated for readability... */
override getTools(): ToolSet {
return {
...createAITools({
workspace: this.workspace,
shell: {
defaultBackend: "container",
backends: {
container: {
description:
"Cloudflare Container with a full Linux userland: " +
"npm, node, package managers, test runners, and real " +
"binaries on $PATH. Use it when a task needs more than " +
"file manipulation.",
},
},
},
}),
replyToIssue,
};
}
}
在 Agent 循环中模型可以使用工具,但你也可以直接使用 workspace API,例如在提示 Agent 之前准备环境。
export class Agent extends withWorkspaceContainer(Think) {
override workspaceBash = false;
/* Example code truncated for readability... */
async startTriage(report: { title: string; body: string; repoUrl: string }) {
await this.workspace.fs.mkdir("/workspace", { recursive: true });
await this.workspace.fs.writeFile(
"/workspace/BUG_REPORT.md",
`# ${report.title}\n\n${report.body}\n`,
);
await this.workspace.git.clone({
url: report.repoUrl,
dir: "/workspace/repo",
});
return this.submitMessages([
{
id: crypto.randomUUID(),
role: "user",
parts: [
{
type: "text",
text: [
`Triage this bug: ${report.title}`,
"The bug report is in /workspace/BUG_REPORT.md.",
"The repository is checked out at /workspace/repo.",
].join("\n"),
},
],
},
]);
}
}
可以查看 workspace 仓库,了解如何使用不同后端和工具的更多示例,其中还有一份逐步教程,带你从零构建一个 Agent。
How it works
The central piece of @cloudflare/computer is the workspace. A virtual filesystem backed by SQLite that can be populated from various sources including cloud storage and source control.

The workspace supports optional execution runtimes that allow code to be run against the file system. All runtimes support the same interface exec(string, options) and currently two are provided out of the box (but you can write your own):
- An isolate-based runtime environment that uses just-bash to translate shell code into JavaScript runs in a dynamic worker. Here, the filesystem is available directly via worker bindings.
- A container runtime that uses Cloudflare Containers to provide a full Linux environment. Here, the filesystem is provided via a Filesystem in Userspace (FUSE) mount, which ensures files are available to the container and changes are synced back.
The Workspace class provides an API interface for manipulating the filesystem directly as well as a node:fs compatible wrapper so that it can be used easily with third-party JavaScript libraries.

工作原理
@cloudflare/computer 的核心是 workspace——一个由 SQLite 支撑的虚拟文件系统,可以从云存储和源代码管理等来源载入数据。

workspace 支持可选的执行运行时,允许针对文件系统运行代码。所有运行时都支持同一个接口 exec(string, options),目前内置两种(你也可以自己编写):
- 基于 isolate 的运行时环境,使用 just-bash 将 shell 代码翻译成 JavaScript,并运行在一个动态 worker 中。这里,文件系统通过 worker bindings 直接可用。
- 基于容器的运行时,使用 Cloudflare Containers 提供完整的 Linux 环境。这里,文件系统通过 FUSE(用户空间文件系统)挂载提供,确保容器可以使用这些文件,并且更改会同步回去。
Workspace 类提供了直接操作文件系统的 API 接口,以及一个与 node:fs 兼容的包装器,方便与第三方 JavaScript 库一起使用。

For use with agents, we provide an AI SDK compatible toolkit that provides the most common tools: read, write, edit, ls and exec. The exec tool is a little special as it works across the runtimes taking a backend argument. The tool description guides the agent into choosing the correct runtime for the task at hand: either a fast, cheap worker backend or the fully featured container. In our testing, the frontier models are very good at making the correct decision and falling back to using containers only when needed.
为了与 Agent 配合使用,我们提供了一个兼容 AI SDK 的工具包,包含最常用的工具:read、write、edit、ls 和 exec。exec 工具有点特殊,因为它跨运行时工作,接收一个 backend 参数。工具描述会引导 Agent 为当前任务选择正确的运行时:要么是快速、廉价的 worker 后端,要么是功能完整的容器。在我们的测试中,前沿模型非常擅长做出正确选择,只在必要时才退回使用容器。
What’s next
Here at Cloudflare we’re already seeing agents exclusively using isolates to build, test, and deploy JavaScript applications with modern tooling, generate tailored documentation for each of our customers, and use web browsers to perform complex tasks.
Our goal with @cloudflare/computer is to provide an agent with a runtime where a container is required for less than 10% of its work, and coding tasks, audio/video manipulation, and document creation can all be handled by isolates.
Try out the early preview today - we can’t wait to hear your thoughts.
下一步
在 Cloudflare,我们已经看到 Agent 完全使用 isolate 来构建、测试和部署使用现代工具链的 JavaScript 应用、为每位客户生成定制文档,并使用网页浏览器执行复杂任务。
@cloudflare/computer 的目标是为 Agent 提供这样一个运行时:其中只有不到 10% 的工作需要容器,而编码任务、音视频处理和文档创建都可以由 isolate 处理。
现在就试试这个早期预览吧——我们期待听到你的想法。