Skip to content
The AI Agent Factory

32.5 Why this open stack

Approved by
Panaversity ·
11 min read

In everyday life. When a hospital chooses a records system, it does not pick the one with the most features. It picks the one that never loses a patient's record, even when the power fails in the middle of an update.

What you will learn. The seven foundations that were compared, the three reasons this book uses Pi Durable on Cloudflare, and its limits.

Why it matters. An open stack is only worth having if it is as reliable as the managed one where it counts. A worker must not lose work or do it twice.

Seven foundations

The Panaversity paper compared seven ways to run a worker that can learn. As of 29 November 2026.

FoundationMain strengthMain limit
Claude Managed AgentsMemory, dreaming and execution in one productClaude models only
OpenAI Agents APIManaged agent executionOpenAI's models mostly
Claude Agent SDK in Durable ObjectsClaude's own agent featuresUsually needs a full process host, not a light runtime
Claude Code in Durable ObjectsStrong at coding and skillsNeeds a container
Codex in Durable ObjectsA capable harnessExperimental integration
OpenAI Agents SDK in Durable ObjectsFlexible TypeScript framework, many modelsYou add durable execution yourself
Pi Durable in Durable ObjectsAny model, durable execution built inExperimental

The last row is the one this part uses. The one above it is the fair alternative, on the next page.

Reason 1. Pi Durable does not lose work

Pi Durable is an open-source harness from Earendil, the company that develops the Pi coding agent. Its core is MIT licensed. Its main idea is simple: every step is a task that saves a checkpoint before the next one starts. A model call is a task. Each tool call is a task. If the process dies, the run starts again from the last checkpoint, not from the beginning.

Two details make this safe for real work:

  • A tool is run again after a crash only if you mark it replay: "safe". Otherwise the model is told the call was interrupted, and decides what to do. A payment tool can be marked safe only if it carries an idempotency key, so that paying twice has the effect of paying once.
  • A tool can wait. It can pause for a person's answer, a deadline or another session, and hold no process while it waits. Since Pi 1.6, released with version 0.34 of Cloudflare's agents package on 20 November 2026, the Durable Object can sleep during that wait. That package is Cloudflare's own library for running agents on its platform; it is not the OpenAI Agents SDK of Chapter 22.

It also works with any model that Pi's model library, pi-ai, can reach: Claude, OpenAI, Workers AI models (models that Cloudflare runs itself), and models behind Cloudflare's AI Gateway (a Cloudflare service that passes your model calls on to many providers).

Tested for this book. Before writing this chapter, we built a small AP worker on Pi Durable 1.6.1. Then we crashed it on purpose, right after it posted an invoice to a test ledger. The object restarted by itself, Pi ran the posting tool again with the same saved idempotency key, and the invoice was posted exactly once. A tool waiting for approval also survived a full restart. You repeat a version of this test in the lab.

Reason 2. Durable Objects fit one conversation each

A Cloudflare Durable Object is a small program with its own SQLite storage. Each conversation with the worker gets its own object. That gives three things:

  • No races. An object runs one thing at a time, so two messages in one conversation are handled in order.
  • State next to the code. Pi saves its checkpoints in the object's own SQLite, with no network trip.
  • No bill while waiting. An object that has nothing to do hibernates and is not billed for time. A worker that waits three days for an approval costs nothing for those three days.

PiHarness, in Cloudflare's agents package, connects Pi Durable to a Durable Object. You use it with a plain Durable Object; that package's full Agent class (not the OpenAI SDK's Agent) is not needed. The paper's cost model puts the runtime for a medium worker at about $0.35 a month, against $4.80 on Claude Managed Agents. But the two do not buy the same thing: a Durable Object has no Linux container. For a worker that must run code or edit files, you would add a sandbox, at extra cost.

Reason 3. It is the stack the book already uses

Part III built the connector and the database on Cloudflare Workers and Neon, and Chapter 23's reference page named Cloudflare Workflows for the nervous system. This stack adds Pi Durable and Durable Objects to the same platform. Workflows runs the long business processes the worker hands off, and Chapter 34 builds it. Cloudflare's free plan covers most of what this part needs while you learn.

The limits, stated plainly

  • Pi Durable is experimental. Its API can change in minor releases. Cloudflare's agents package supports one Pi minor version at a time. We pin agents 0.34 and Pi 1.6, and test again before each new cohort.
  • You cannot roll back a conversation's version. A conversation that has run on Pi 1.6 cannot go back to Pi 1.5; fix a bad release by moving forward.
  • No subagent primitive. Pi Durable has no subagents built in, but Cloudflare's documentation describes a pattern for them: you build them from sessions and forks (a fork is a copy of a session that carries on by itself), in a few lines.
  • It cannot delete a conversation yet. Deleting data for a customer needs a design of its own, which this part builds.
  • A small team maintains it. That is fast, but it is a risk: 32.7 lists the rules that manage it.

The invariant. Choose an open foundation for the same reasons you would choose a managed one: it must not lose work or do it twice. Model freedom comes second.

Check yourself. A worker's payment tool is marked replay: "safe", but it creates a new random key each time it runs. What can go wrong after a crash? (The tool runs again with a new key, and the payment is made twice. The key must be saved before the outside call.)

Owner
Panaversity