Sulat.com / Writing on AIWednesday, November 11, 2026
A brick depot office stands at the edge of a tram yard at dusk, the Cloudflare logo painted on its wall.
Agent Engineering/11 November 2026

Cloudflare can run OpenAI Codex on Durable Objects, in a container or as WebAssembly

Official docs put the Codex CLI in a Cloudflare Container driven by a Durable Object. A 9 November example runs the loop as WebAssembly inside the object.

At a glance

  • A Durable Object is a globally unique, single-threaded Worker with its own SQLite-backed storage, plus WebSockets, hibernation and alarms.
  • Official Agents SDK docs describe the Codex CLI running in a Linux container, driven by a Durable Object, the way it runs on a laptop.
  • A 9 November changelog sets out a separate experimental path: Codex's turn loop compiled to WebAssembly and run inside the Durable Object.
  • Those primitives make per-user, scheduled and multi-tenant coding agents possible, within the documented limits. They are not shipping products.
  • Credentials stay outside the container. After five minutes idle the filesystem is snapshotted. Files written after the last snapshot can be lost.

Cloudflare says OpenAI Codex can run on Durable Objects. Its developer account posted about it on 11 November and reached for a familiar line from the Agents SDK docs: Codex can run “the way it runs on your laptop.” The code attached to that post belongs to another experimental example, the one that landed in a 9 November changelog.

“Run OpenAI Codex on Cloudflare, with its tools and configuration, the way it runs on your laptop.”

— Cloudflare, in the Codex harness docs

What a Durable Object is

A Durable Object is a special kind of Cloudflare Worker that pairs compute with its own storage. Like a regular Worker, it starts near the first request, comes up quickly, and shuts down when idle. You can have millions of them. What sets one apart is that it has a name, and it can remember.

Each object has a globally unique ID. Requests for that ID, from anywhere, go to the same instance, and only one of those IDs runs at a time. The instance is single-threaded. It can pause mid-task to let other work in, much as a web browser does, and that is how it coordinates work without a separate lock service. New objects use a SQLite-backed store that is private to that instance, transactional and strongly consistent. In-memory values can speed things up, but they’re wiped if the object hibernates, so anything that has to last belongs in storage.

Diagram of a request routed by ID to one named Durable Object, with private SQLite storage, plus panels for WebSockets, hibernation and alarms.
A Durable Object is a named instance of a special Worker, with its own SQLite-backed storage, plus WebSockets, hibernation and alarms.

A plain Worker is stateless. Each request may run on a different instance, with no shared memory. The usual pattern is simple: the Worker handles auth and routing, then hands the stateful work to a Durable Object.

Two-panel comparison: a stateless Worker on the left routes to a stateful Durable Object on the right, which has a unique ID and private storage.
A plain Worker is stateless. The usual pattern is to let it handle auth and routing, then hand stateful work to a Durable Object.

Think of a Durable Object as a named office with one clerk and a locked filing cabinet. Anyone can find that office by its number. The clerk deals with one job at a time, so two people can’t overwrite the same file at once. The cabinet stays put even when the clerk steps out.

When the object has been idle for a short time and is eligible, the runtime can hibernate it. Clients can stay connected over WebSockets while the object itself leaves memory. Duration charges don’t accrue during that sleep. A later message or request wakes it, and the constructor runs again. Alarms let the object schedule a wake-up of its own, so you can do work later without a separate job runner. Alarms don’t repeat by themselves, and the docs say they can run a little late if maintenance or failover is under way.

Lifecycle diagram of a Durable Object moving from active, to idle, to hibernated, then waking on a request, WebSocket message or alarm. Storage is kept; in-memory values are wiped.
A request, message or alarm wakes the object. When it hibernates, storage is kept and in-memory values are wiped.

How builders use them

Cloudflare tells builders to model each object around one “atom” of coordination: a chat room, a game session, a document, a user’s data, or a tenant’s workspace. Official examples include chat rooms and multiplayer games, where one object holds the room and WebSockets fan updates out to everyone in it.

Six panels showing documented Durable Object uses: chat and multiplayer, Liveblocks rooms, PartyKit and PartyServer, per-credential rate limiters, the Agents SDK, and MCP state.
Official docs and customer examples show rooms, collaboration, rate limits and agents all modelled as one Durable Object per unit of coordination.

Liveblocks, in a Cloudflare customer story, built collaboration rooms this way. When users connect over a WebSocket, they’re forwarded to a Durable Object that holds the room’s state, and an update is shown to everyone in the room. In that story, Jonathan Rowny, a principal software engineer at Liveblocks, said developers don’t have to design CRDTs or operational transforms for that path.

PartyKit was built on Durable Objects to make the same room-and-connection model easier to use. Cloudflare acquired the project in 2024, and PartyServer now runs as a regular Worker with Durable Objects.

For a strict rate limit across locations, Cloudflare’s Workers docs recommend a Durable Object per credential, with the counter checked and updated together in storage.

The Agents SDK treats each agent as a Durable Object. Routing sends the request to the right one. The agent gets a durable identity and local SQL storage. It can hold real-time connections, schedule work through the Lifecycle and a Scheduler, and recover after eviction. MCP can sit alongside this. The current recommended MCP handler is stateless, and anything that must survive a request can live in a Durable Object or an Agent. An older API, McpAgent, put the MCP server itself on a Durable Object. Cloudflare has deprecated it.

How Codex runs on them

Codex’s own docs were last touched on 10 November. They describe an experimental ContainerHarness and a codex() preset, where the official OpenAI Codex CLI runs in a Linux container and a Durable Object drives it. The CLI owns the loop, so you get its native tools, plugins, settings and session format. The Durable Object owns the record: sessions, operations, transcripts and the CLI’s session files, held in the object’s SQLite database.

Credentials stay outside the container. The CLI is handed a placeholder host and key, and ContainerEgress adds the real credentials after the request has left. There’s no Dockerfile. The harness boots from cloudflare/debian-trixie, installs Codex the first time it’s used, then snapshots the filesystem.

If the Durable Object is evicted or redeployed, Lifecycle reattaches to the running container and replays missed events. After five minutes idle, the harness takes a snapshot and stops the container. The next prompt restores that snapshot and picks the CLI session back up. Should the container die mid-turn, the session itself survives, with status “unanswered” and reason “container_lost”. Set onContainerLost to “retry” and the harness reruns the turn when side effects are safe. Files written after the last snapshot can still be lost, so anything that has to last belongs in separate durable storage.

Cloudflare treats the container as the sandbox. The Codex path, and a claudeCode() preset on the same harness, run without the CLIs’ usual permission prompts. According to the docs, everything in the container should be treated as readable by the agent, credentials should stay out, and every route to the harness should sit behind auth. Each prompt can run commands and spend model credit. Tokens used in setup stay in the snapshot.

The setup needs Node.js 24 or later, the Cloudflare CLI, an OpenAI API key, and Docker for local containers. AI Gateway is optional, and Unified Billing works with it. Cloudflare’s agents repository already has a container harness example. The API is experimental and may change.

The 9 November changelog is a different design. It walks through an experimental Agents SDK example that takes Codex’s Rust turn-processing, compiles it to WebAssembly, and runs the loop inside the Durable Object. Tasks, Sessions, Streams and a Workspace come with it, and the sample calls a model such as openai/gpt-6.1-sol through AI Gateway. That’s the design in the code Cloudflare posted on 11 November.

Matt Carey works on agents and MCP at Cloudflare. On 9 November he called getting the harnesses running “a fun challenge,” and said he’d “had to pull out the wasm for OpenAI Codex.” The next day he added that he wasn’t sure people should use the wasm version yet. Pi Durable, he said, would be more stable on Durable Objects.

Back in September, Cloudflare wrote up Cloudflare Containers as execution environments for the OpenAI Agents API. In that arrangement OpenAI still manages sessions and orchestration.

The harness comparison page was updated on 10 November as well. It lists Codex as experimental: a Linux container driven by a Durable Object. Durability is mixed. The object can reattach after a restart, but if the container is lost the run fails or retries. This path has no built-in Cloudflare Computer integration.

Container path or Wasm path

PathWhere the loop runsWhat persistsLimits
Container CLIThe official Codex CLI in a Linux container, driven by a Durable ObjectSessions, transcripts and CLI session files in the object’s SQLite store, plus filesystem snapshotsExperimental. Idle snapshot after five minutes. Files written after the last snapshot can be lost. No built-in Cloudflare Computer integration.
Wasm loopCodex turn-processing compiled to WebAssembly, run inside the Durable ObjectThe 9 November changelog says conversations and files survive restartsExperimental. Matt Carey has said this path may be less stable than Pi Durable.
Two architecture flows. The container path runs the official Codex CLI in Linux, with credentials added after egress. The Wasm path runs the turn loop inside the Durable Object via AI Gateway. Each flow has a documented-limit box.
These are two experimental designs. On the container path, the official Codex CLI runs in Linux and credentials are added after egress. On the Wasm path, the loop runs inside the Durable Object.

What running Codex on Durable Objects makes possible

These are patterns the documented APIs already allow, within their limits. Cloudflare and OpenAI haven’t shipped them as products.

Give the object a user ID, and you have a per-user coding agent. The Durable Object keeps that person’s sessions, transcripts and CLI session files in its SQLite store. On the container path, an idle agent can snapshot and stop, then come back on the next prompt.

Three-step flow: address a Durable Object by user ID, keep sessions in SQLite, and run Codex with snapshot and resume. A limit box warns that files written after the last snapshot can be lost.
Address the object by a user ID and it can keep that person’s sessions. Files written after the last snapshot can still be lost.

Alarms, and the Agents SDK Scheduler, make background or scheduled runs possible. The object can wake later to continue a job, check a pull request, or retry work. Alarm handlers should be safe if they fire twice, and the Codex container docs warn that a retry can rerun a turn if side effects aren’t safe.

Three-step flow: set an alarm or use the Scheduler, the object wakes, then the job continues. A limit box says handlers should be safe if they fire twice, and a container retry can rerun a turn.
Alarms and the Agents SDK Scheduler can wake an object later. Handlers should be safe if they fire twice.

Because the record lives with the object, an agent can keep state between sessions, even if the Durable Object is evicted and later reattached. The Wasm changelog makes the same claim for conversations and files across restarts. On the container path, files written after the last snapshot can still vanish, so anything that must survive belongs in separate durable storage.

Three-step flow: the Durable Object saves the record in SQLite, in-memory values may go away on eviction, and Lifecycle can reattach the stored record. A limit box covers unsaved container files.
The Durable Object can keep the record between sessions, but container files written after the last snapshot can still vanish.

Multi-tenant sandboxes follow the same rule. You give each tenant, repo or pull request its own object, and on the container path its own container, each with private storage. Funneling every tenant through a single object is the bottleneck the docs warn against. Every route to the harness should sit behind auth, and everything in the container should be treated as readable by the agent.

Three-step flow: pick one tenant, repo or pull request as the unit of coordination, isolate it in its own object and container, and put auth in front of every route. A limit box warns against funneling every tenant through one object.
Give each tenant, repo or pull request its own object. The docs warn against putting every tenant through a single instance.

A pull-request bot can be a Worker that receives a webhook and routes it to a Durable Object for that repo or PR, then uses alarms for follow-ups. The Agents SDK already documents Slack, email and webhook channels. That’s a pattern, not a Codex bot Cloudflare has shipped.

Three-step flow: a Worker receives a webhook, routes it to one Durable Object per repo or pull request, then an alarm can schedule the next step. A limit box says this is a pattern, not a shipped Codex bot.
A Worker can route a webhook to a Durable Object for that repo or pull request. That’s a pattern, not a Codex bot Cloudflare has shipped.

Storage is colocated with the object and private to it. On the container path the CLI still runs in a Linux sandbox driven by the Durable Object, and that path has no built-in Cloudflare Computer integration. Keep credentials out of the container. Model credit is still spent whenever a prompt runs.

Three-step flow: storage is private to the object, the object owns the record, and on the container path the Codex CLI still runs in a Linux sandbox. A limit box notes no built-in Cloudflare Computer integration.
Storage is private to the object. On the container path the CLI still runs in a Linux sandbox, and this path has no built-in Cloudflare Computer integration.

An idle Durable Object that is eligible for hibernation isn’t billed for duration. The container path also snapshots and stops the container after five minutes idle, so a running sandbox isn’t sitting there while nobody is prompting. Once work starts again, duration and model usage resume. Tokens placed in setup stay in the snapshot.

Three-step flow: the object is billed while active, an eligible idle object can hibernate without duration charges, and on the container path the sandbox can stop after five minutes idle. A limit box notes duration and model usage resume when work starts again.
An eligible idle Durable Object isn’t billed for duration. On the container path the sandbox can also stop after five minutes idle.

In short

A Durable Object is a named, single-instance Worker with its own SQLite-backed storage. There’s one per ID, it’s globally unique, and it’s single-threaded. Builders already use that primitive for chat rooms, multiplayer, collaboration, rate limits, agents and per-tenant state.

Codex can run on it in two experimental ways: the official CLI in a container driven by the object, or a WebAssembly port of the loop inside the object. Persistent, scheduled and multi-tenant coding agents are possible from those APIs, within the published limits.


Discover more from Sulat AI & Tech News

Subscribe to get the latest posts sent to your email.