Agent Upstart

Cool things people are building with agents — and practical help getting the most out of them.

Playbooks · Coding tasks

Cloudflare runs the Codex loop in a Durable Object

Written November 11, 2026

Cloudflare's Agents SDK example runs the Codex agent loop in a Durable Object, with tasks, sessions and streams that survive restarts.

What it is

This is an experimental Agents SDK example that runs the Codex agent loop in a Cloudflare Durable Object. Conversations and files persist across restarts, and completed model and tool results persist too, allowing the agent to recover after interruptions. The example adapts Codex's Rust turn-processing code to WebAssembly and uses Agents SDK capabilities for storage and recovery.

Experimental is the word to keep in mind. This is an example, not a hosted Codex product. It shows how to run the loop durably. It does not turn Cloudflare into a place where Codex runs for you.

The four pieces

Four Agents SDK capabilities combine for durable execution:

Together they answer the question the example is built around: what survives when the process stops. Enough survives for the agent to pick up where it left off instead of starting over.

How it is wired up

The example uses OpenAI's GPT-6.1 Sol through AI Gateway. Configure the model with createAI and install the capabilities on a Durable Object. To use the model, configure the default gateway with Unified Billing or a stored OpenAI API key. For setup and recovery behaviour, the changelog points to the guide linked from it.

Limits

Related playbooks

Sources

Back to: Coding playbooks hub · Also: Codex Guardian v3: the evidence pipeline in 0.168 · Hermes 0.23.1: the plugin catalog cap fix