Moltworker: A Self-Hosted Personal AI Agent on Cloudflare

Summary

Moltworker is a proof-of-concept for running the Moltbot personal AI agent on Cloudflare's serverless platform rather than dedicated local hardware. It combines Cloudflare Workers (entrypoint and admin UI), the Sandbox SDK (isolated code execution), R2 mounted as persistent storage, Browser Rendering (headless web automation via a CDP proxy), AI Gateway (model routing, observability, cost control), and Zero Trust Access (auth). The result is a stateful cloud agent that can be controlled remotely and integrated with messaging apps.

Running a personal agent full-time usually means a machine that never sleeps — a Mac mini in a closet. Moltworker removes that requirement. It’s an open-source proof of concept that takes the Moltbot personal agent, designed for local hardware, and runs it on Cloudflare’s serverless platform instead. The result is a stateful agent you can control remotely and wire into messaging apps for tasks like finance tracking, social media, and daily organization — with no server to maintain.

How the pieces map

Moltworker is a thin layer of middleware and adapted scripts that reconstructs a local server environment out of managed Cloudflare services:

  • Workers — the entrypoint. Routes the API, proxies between Cloudflare’s services and the agent, and serves the admin UI.
  • Sandbox SDK — a secure, isolated container to run Moltbot’s untrusted code. Its API executes commands, manages files, and runs background processes without you managing the container lifecycle.
  • R2 — solves ephemeral container storage. An R2 bucket is mounted as a filesystem partition inside the sandbox, so session memory, conversation history, and assets persist across restarts.
  • Browser Rendering — replaces a local Chromium instance. A thin CDP (Chrome DevTools Protocol) proxy connects the agent to Cloudflare’s headless browsers, so it can navigate, fill forms, and screenshot pages over an API.
  • AI Gateway — sits between the agent and its model provider (e.g. Anthropic), adding observability, logging, and cost control, and letting you switch models or add fallbacks without touching agent code.
  • Zero Trust Access — locks down the agent’s APIs and admin UI behind authentication.

The two moves that make serverless viable here are worth noting: mounting R2 as a filesystem gives a stateless container durable memory, and proxying CDP to a hosted browser removes the last piece that normally forces a local machine.

High-level architecture diagram of Moltworker.

Deploying it

The implementation is open source and self-deployable.

  • Repository: github.com/cloudflare/moltworker
  • Requirements: a Cloudflare account with a paid Workers plan (needed for Sandbox containers). AI Gateway and R2 have generous free tiers.

Moltworker is presented as a demonstration of the Cloudflare Developer Platform for AI agents, not an official product.

What it can do

  • Retrieval — find directions on a map and return a screenshot.
  • Web automation — locate local restaurants, browse menus, and recommend.
  • Content creation — build a video by browsing a site, capturing frames, and compiling them with ffmpeg inside the sandbox.
Key Concepts
  • Moltworker
  • Moltbot
  • Self-Hosted AI Agent
  • Cloudflare Workers
  • Sandbox SDK
  • Browser Rendering
  • R2 Storage
  • AI Gateway
This entry was posted in . Bookmark the permalink.