- How you use it
- A setting in your project
- What it can do
- installs software · writes files · network · secrets access · runs shell
- What's inside
The option
| Option | AConfig · v0.87.1+wwfix.5Pi Durable on Cloudflare sample app |
|---|---|
| How you use it | A setting in your project |
| What it can do | installs software · writes files · network · secrets access · runs shell |
| What's inside |
What this thread does
As of November 2026, the Cloudflare sample persists a shared Pi agent in one Durable Object per session. Do first: keep its pinned dependency versions together and run it locally before adding authentication for deployment (sample README).
What it is
Pi Durable is a harness from Earendil, the team behind the Pi coding agent, for agents that run for a long time without holding a process open. The agent's state lives in storage; it sleeps when idle and wakes when a message arrives or a timer fires.
On 16 October 2026 @pidotdev published a walkthrough and a sample repo that put it on Cloudflare Durable Objects:
- One Durable Object per session, with all conversations stored in its built-in SQLite.
- Multiplayer: several browsers join the same session over hibernating WebSockets and see live events.
- Several conversations at once, plus forks from an earlier message.
- Scheduled work: one-off or recurring follow-ups are mapped to a single Durable Object alarm that is recalculated each time the object wakes.
- Subagents: a
search_historytool starts a child conversation that searches the others without copying their transcripts. - Reconnecting keeps committed transcripts and queued prompts.
When to use it
- You want an agent that can wait hours or days for a person or a timer without paying for an idle server.
- Several people should share one agent session.
- You are already on Cloudflare Workers.
Requirements and cost
- Node.js 22.19+, pnpm 11 and an OpenAI API key. The sample is wired to OpenAI's
gpt-6-lunainsrc/chat.ts; using another provider means changing that file. - SQLite-backed Durable Objects are available on the Workers Free plan with daily limits (for example 100,000 requests a day). Beyond that, the Workers Paid plan bills requests, duration and storage; hibernating WebSockets keep duration charges down.
- Model tokens are billed by OpenAI.
Run it locally
After the install steps, put your key after OPENAI_API_KEY= in vendor/pi-durable-cloudflare/.dev.vars, then start the Worker and React client together with npx -y pnpm@11.15.1 --dir vendor/pi-durable-cloudflare --config.verify-deps-before-run=false dev. It is a dev server that keeps running; open the local URL it prints.
Caveats
- Pi Durable is experimental; the APIs may change.
- The sample has no authentication or rate limiting. Anyone who can reach a deployed copy can start sessions on your API key. Add both before deploying.
- Alarms can fire more than once, so scheduled handlers must be safe to repeat.
- History search is plain substring matching on purpose.
Alternatives
- Cloudflare's own Agents SDK also builds agents on Durable Objects.
- If you are choosing Pi as a coding-agent harness rather than building an app, see Pi vs Claude Code vs Codex CLI.
- For hosting tools rather than an agent, see remote MCP server on Cloudflare Workers.
Durable sleep and upgrade boundaries
As of November 2026, the sample’s package.json, read 15 November 2026, now pins Pi Durable, Pi AI and Chord to 1.5.2. Its session adapter maps onWake to Durable Object alarms. TennyZhuang’s 2 October report explains why the old in-process sleep kept a Cloudflare invocation billable.
The upstream 1.4.0 changelog (21 October 2026) removes TaskRuntime.sleep(): finish the phase with runtime.sleepUntil(until, checkpoint, context) and resume the work in the next phase. Add the sleeping state and new runtime methods in custom wrappers, and an explicit checkpointWhen to document definitions. Five consecutive crash restarts now park a task unless configured otherwise. Opening SQLite storage migrates it to schema 2; 1.3.0 and earlier cannot reopen it. Back up storage before upgrading.
The same changelog’s 1.5.0, 2 November entry introduces further breaks in JSON Schema tool definitions, custom storage commits/runCounted, watch callbacks and conversation views, and removes watchEvents() and old state getters. As of November 2026, the Cloudflare sample is on 1.5.2; follow the full migration notes before changing that pin. These changes do not remove the authentication, rate-limit or repeat-safe alarm requirements above.
Not for: hosting a remote MCP server on Workers
checked 2026-11-15
Started from a post by @pidotdev, packaged by the editor. Original post
- 01 · YouPaste the line from Try it into your agent.
- 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
- 03 · YouApprove a one-line report. Nothing is posted without you.