Wink Pings

Tobi Says Pi Durable Is the POSIX of Agent Programming; Cloudflare Stuffed It Into a Durable Object

Cloudflare documentation shows that PiHarness can run Pi Durable inside a Durable Object, with transcript, retries, tool calls, and crash recovery all going into SQLite. Tobi Lutke compares it to the POSIX of agent programming; what is really worth looking at is the recovery semantics after a crash and the bill.

Cloudflare’s Agents SDK has added a PiHarness. It runs Pi Durable inside a Durable Object: Pi handles the agent loop, while Cloudflare handles storage, wake-ups, and restarts after crashes. The docs are on the Agents SDK’s Pi page.

Pi itself is a minimal, extensible agent harness. It manages the transcript, the inbox for follow-up and steer, model calls, tool execution, retries, and crash recovery. PiHarness does two specific things: it writes Pi’s transcript, inbox, and tasks into the Durable Object’s SQLite, with table names starting with pi_; then it schedules a job through Lifecycle and uses Pi’s wake() to maintain a heartbeat. After the object is evicted, the job’s alarm wakes it up, Pi reopens storage, and continues running.

This sounds like infrastructure, and it is. Tobi Lutke said on X that “pi-durable is the posix of agent programming.” POSIX matters because developers do not have to care which kind of Unix is underneath. For PiHarness to live up to that metaphor, the key is not the API names but what happens after a crash in the middle of a tool call: the docs say tools marked with replay as safe will be rerun, other tools will not be rerun, and the model gets an interrupted result and decides the next step itself. Only when replay semantics are clearly defined does durable avoid becoming blind retries.

Someone in the replies said that pushing retries down into the durable layer in production cuts glue code in half. Others use Pi Durable to run a PR review agent on a Durable Object. Another use case is more everyday: when you restart the IDE for an upgrade, an agent that is in the middle of work can survive. That experience is more convincing than the four words “supports crash recovery.”

The install entry point is npm i agents @earendil-works/pi-durable @earendil-works/pi-ai @earendil-works/pi-schema @earendil-works/chord. Version details are easier to trip over than the API: the Pi packages are optional peer deps of agents, at about version 1.5.0; Pi Durable is still experimental, and minor versions may change the API; the Agents SDK only supports Pi 1.5 from 0.33.0 onward. The docs also warn that after a conversation has run on Pi 1.5, rolling the Worker back to Pi 1.4 will make that conversation unreadable, so a bad deployment can only be fixed forward.

Recovery behavior deserves separate attention. If an object is evicted, crashes, or exceeds memory or CPU limits, the next alarm restarts the object, and Pi continues from the last checkpoint. If a deployment happens mid-run, the runtime gives in-flight work 30 seconds, then the alarm restarts it. If the model was streaming output at the time, Pi keeps the part of the answer already stored; that request counts as one failed attempt according to settings.retry, and if retries are enabled it calls the model again; if not, it ends as interrupted. If a tool is running, tools marked with replay as safe are rerun, and other tools are not. If a task repeatedly crashes the object, restartLimit defaults to 5 times and then stops it, avoiding infinite restarts.

The limitations are also laid out clearly: Pi Durable does not yet have an approval or permission step for tool calls; abort() has to wait for the session to be idle, and tools that ignore the abort signal will hold the session up; a single model request streaming for more than 15 minutes may be cut off, although the harness hands off a new alarm every 10 minutes; background tasks rely on heartbeat checks and can be discovered as complete up to 30 seconds late; running sessions are not gracefully evicted; and sessions cannot yet be deleted.

Billing is the other side. Durable agents run for a long time, and retries and crash recovery both amplify the number of calls. Some people in the replies worried about runaway bills, and Allan Leinwand pointed to Cloudflare’s Spend Management. This feature launched around the same time and first supports Workers and Durable Objects; you can set thresholds, send emails, and pause billable calls when limits are reached. Agents can be durable, and so can the bill.

Durable Objects limit settings in Cloudflare Spend Management

Tobi’s POSIX metaphor carries weight, but POSIX won because the underlying layer was replaceable—developers could stop caring about differences between Unix systems. PiHarness now moves agent persistence, retries, and recovery into the platform; people writing glue code will write less, but platform limits will become your limits. Those limitations in the docs are more worth reading than the launch announcement.

发布时间: 2026-11-16 03:28