Why run a personal AI agent on Workers?

Moltbot has driven a wave of people buying dedicated hardware to run a self-hosted AI assistant. The project is an open-source agent that lives on your own machine, integrates with messaging apps, and can be steered remotely to handle everything from finances to scheduling. It works well — but it assumes you want to run your own hardware around the clock.

Moltworker takes the same agent and shifts it onto Cloudflare's Developer Platform, using the Sandbox SDK for isolated execution and platform APIs for the surrounding infrastructure. The result: a Moltbot instance that runs without new hardware, reachable through your messaging app of choice, with Cloudflare's network handling scalability and security underneath.

BLOG-3162 1

Enough Node.js compatibility to matter

The feasibility of this port rests on how far Workers Runtime has come in native Node.js support. Early experiments like Playwright on Browser Rendering required memfs as a hack for filesystem access, forcing a fork from the upstream codebase. That constraint has loosened: node:fs works natively now, meaning fewer external dependencies and simpler upgrades to latest package versions.

The compatibility gains are measurable. In an internal test, Cloudflare took the 1,000 most popular npm packages and tried to run each in Workers. Excluding build tools, CLI tools, and browser-only packages that were never applicable, only 15 packages genuinely failed — 1.5%. That result, plus a detailed breakdown of Node.js API support over time, is available publicly.

BLOG-3162 image 1

The portability matters for an agent like Moltbot because most of its execution happens inside a container anyway. But the native API support means new agent logic can live directly in Workers, closer to the user and easier to scale.

The building blocks of Moltworker

Moltworker pairs an entrypoint Worker with the Sandbox container where the standard Moltbot Gateway runtime runs. The Worker acts as an API router and proxy between external clients and the isolated environment, and it hosts an admin UI. Cloudflare Access sits in front of both. R2 provides persistent storage. Browser Rendering handles web automation tasks. AI Gateway proxies model requests.

BLOG-3162 image 2

Model access through AI Gateway

Moltbot normally talks directly to an AI provider using an API key. With AI Gateway, the base URL changes to a Cloudflare-managed endpoint, and the provider key never has to appear in the agent's configuration. The setup path is: create a gateway instance, enable the Anthropic provider, add a Claude key — or purchase credits for Unified Billing and skip key management entirely — and set the ANTHROPIC_BASE_URL environment variable so Moltbot points at the gateway. No code changes needed.

BLOG-3162 image 3

The gateway gives you usage analytics and per-request logs, which is helpful for understanding what a personal AI agent is actually doing on your behalf. Since Moltbot supports multiple AI providers and AI Gateway does too, you can swap models without touching the agent's deployment. Fallback rules let you route around provider failures automatically.

Sandboxes for the runtime

The Sandbox SDK runs on top of Containers and offers a high-level API for shelling out commands, managing files, spawning background processes, and exposing services. You get a TypeScript-friendly interface that handles container lifecycle and networking, so the code to start a disposable environment stays brief.

import { getSandbox } from '@cloudflare/sandbox';
export { Sandbox } from '@cloudflare/sandbox';

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    const sandbox = getSandbox(env.Sandbox, 'user-123');

    // Create a project structure
    await sandbox.mkdir('/workspace/project/src', { recursive: true });

    // Check node version
    const version = await sandbox.exec('node -v');

    // Run some python code
    const ctx = await sandbox.createCodeContext({ language: 'python' });
    await sandbox.runCode('import math; radius = 5', { context: ctx });
    const result = await sandbox.runCode('math.pi * radius ** 2', { context: ctx });

    return Response.json({ version, result });
  }
};

Instead of Docker on a Mac mini, Moltworker runs Docker on Containers. The Sandbox SDK issues commands into that environment, and callbacks to the entrypoint Worker create a two-way channel between the container and the Worker.

R2 for state that survives

Containers are ephemeral, so anything written to their local filesystem vanishes on shutdown. The sandbox.mountBucket() API fixes that by mounting an R2 bucket as a filesystem partition when the container boots. Session memory, conversations, and other state required for continuity live there and survive container restarts.

Browser Rendering instead of a local Chromium

Moltbot depends on a real browser for navigating unstructured web pages, filling forms, and taking snapshots. Running Chromium inside the Sandbox is possible but wasteful; Browser Rendering serves headless browsers from Cloudflare's edge network and speaks Puppeteer, Playwright, Stagehand, and MCP.

Two pieces make this work: a thin CDP proxy that connects the Sandbox container to Browser Rendering through Puppeteer APIs, and a Browser Rendering skill injected into the Moltbot runtime at Sandbox startup. To the agent, it still looks like a local CDP port.

BLOG-3162 image 5

Access control for the control plane

Admin endpoints and the management UI need to be protected without rolling custom auth. Zero Trust Access handles that with application-level policies and login methods. Every request to a protected endpoint arrives with a JWT that the Worker can validate in code for defense beyond HTTP headers.

BLOG-3162 image 6

Access also returns request logs, so an operator sees who talked to their agent and when.

Shared plumbing for the agent age

Moltworker is one example, but the middleware holds up for the broader class of self-hosted AI agents arriving now. Gateway-side model proxying, isolated execution, object storage for state, managed browsers, and Access policies are exactly the primitives an autonomous agent needs. Moltbot happened to fit readily; the pattern is what matters.

Moltbot in the field

To see what the architecture can actually do, we stood up a Slack workspace and pointed our own Moltbot instance at it. The results show an agent handling multi-step tasks, remembering context between turns, and producing structured output beyond plain text.

Bad news is best delivered quickly.

BLOG-3162 image 7

In one session, we asked Moltbot to compute the shortest route between Cloudflare offices in London and Lisbon using Google Maps, and to drop a screenshot of the result into Slack. It worked through the sequence of browser steps on its own. When we asked again later, its memory of the earlier run removed the need to start over from scratch.

BLOG-3162 image 8

Food queries exercise the tool-use loop too. We asked for help choosing Asian takeout.

BLOG-3162 image 8

Presentation matters, so Moltbot can also pull together visual comparisons.

BLOG-3162 image 9

For a more involved job, we had it assemble a video from a walk-through of our developer documentation. It downloaded and executed ffmpeg locally, turning captured browser frames into a playable clip.

Deploying your own instance

The whole implementation is up on GitHub at https://github.com/cloudflare/moltworker. The README walks through the setup steps for running your own Moltbot on Workers.

You’ll need a Cloudflare account and a Workers Paid plan, since Sandbox Containers require it. Everything else in the stack either stays entirely free—like AI Gateway—or includes generous free tiers that are enough to get started and scale within reasonable limits.

Keep expectations in check: Moltworker is a proof of concept, not a Cloudflare product. Its purpose is to show what the Developer Platform can do for running AI agents and unsupervised code with strong security, isolation, and observability across the global network.

You’re welcome to fork or contribute to the GitHub repository, and we’ll be monitoring it for support for a while. In parallel, we’re looking at submitting Cloudflare skills upstream to the official project.

Why this fits the platform

The experiment points to a broader story about where Cloudflare is taking AI development. The Agents SDK lets you put together a first agent in minutes. Sandboxes is a tool for executing arbitrary code in an isolated environment without managing container lifecycles. And AI Search is Cloudflare’s managed vector-search service.

Collectively, the pieces amount to a full toolkit for AI development: inference, storage APIs, databases, durable execution for stateful workflows, and built-in AI features. Moltbot is one assembly of those building blocks, and it runs on the edge network like any other workload. If you’re keen to build the next wave of products and APIs on top of that, we’re hiring.