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:
- Tasks journals model calls and tool execution. Completed steps reuse their recorded results after a restart. Interrupted steps can run again.
- Sessions stores conversation history and compacts the model context.
- Streams stores ordered events for replay after reconnecting.
- Workspace provides tools to read and write persistent files.
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
- The example is experimental. Its behaviour, including recovery after restarts, is described by the changelog, not measured here.
- The example model is GPT-6.1 Sol through AI Gateway. Other models need their own configuration.
- This page covers the Codex example only. Other Agents SDK announcements from the same period are separate work.
Related playbooks
- Qwen Code 0.28 runs one shared agent loop
- Foundry retires codex-mini on November 15
- ChatGPT and Codex share one token budget
- Codex 0.167: run parallel sessions in one place
Sources
- Cloudflare Changelog, Run the Codex agent loop on Cloudflare Workers — the Durable Object loop and its experimental status.
Back to: Coding playbooks hub · Also: Codex Guardian v3: the evidence pipeline in 0.168 · Hermes 0.23.1: the plugin catalog cap fix