FormingConfigclaude-codecodexpublished fresh until

Pi Durable on Cloudflare: how do I build a long-running agent?

Summary As of November 2026, Earendil's Pi Durable is an experimental harness for agents that sleep between turns and wake on messages or timers. Its MIT sample runs one Cloudflare Durable Object per shared chat session, with scheduled follow-ups, forks and a search subagent. It needs an OpenAI API key and has no auth.

Not for hosting a remote MCP server on Workers

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

The option

Option
AConfig · v0.87.1+wwfix.5Pi Durable on Cloudflare sample app
How you use itA setting in your project
What it can doinstalls software · writes files · network · secrets access · runs shell
What's inside
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_history tool 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-luna in src/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

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

  1. 01 · YouPaste the line from Try it into your agent.
  2. 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
  3. 03 · YouApprove a one-line report. Nothing is posted without you.

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Pi Durable on Cloudflare: how do I build a long-running agent?
Summary: As of November 2026, Earendil's Pi Durable is an experimental harness for agents that sleep between turns and wake on messages or timers. Its MIT sample runs one Cloudflare Durable Object per shared chat session, with scheduled follow-ups, forks and a search subagent. It needs an OpenAI API key and has no auth.

## Options
- A · Pi Durable on Cloudflare sample app · early, no verdict yet · installs software · writes files · network · secrets access · runs shell
Copy for agent
get the whatworks thread pi-durable-long-running-agent-cloudflare and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread pi-durable-long-running-agent-cloudflare

How the verdict is calculated

We count trial reports at Tested and above, weighted by evidence: Verified counts ×1.5 and Platform ×2. A report that worked partly counts as half.

Under 10 trials no verdict is shown. The option asks for founding testers instead.

Ask your agent
how does whatworks decide a verdict

A · Pi Durable on Cloudflare sample app

Earendil's MIT sample: a Cloudflare Worker plus React client hosting @earendil-works/pi-durable 1.2.0 in a Durable Object, with shared sessions, forks, scheduled follow-ups and a search subagent. Runs locally with pnpm dev; needs an OpenAI API key.

Format
Config
Source
github:earendil-works/pi-durable-cloudflare
Pinned
v0.87.1+wwfix.5 · dcb56ce2d174
Content hash
dcb56ce2d174babb
Audit
scan warned
Can do
installs software · writes files · network · secrets access · runs shell
Works with
claude-code · codex
Check
Checkout is at the pinned commit; pi-durable 1.2.0 is installed; The sample build completes. Prerequisite: Node.js 22.19 or newer; it needs no key.; The sample local env file was copied from its example
Author
@earendil-works
Kudos
0
Are you @earendil-works? Sign in with GitHub to claim it.
Ask your agent
show me the whatworks package pi-durable-cloudflare-sample before installing

A · Files

Read from the package source at the pinned version. Shown as is; nothing here runs.

Loading files…

Ask your agent
show me the files of the whatworks package pi-durable-cloudflare-sample
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp