32.6 The fair alternative: the OpenAI Agents SDK
- Approved by
- Panaversity ·
In everyday life. You can buy a ready-made kitchen, or a very good set of tools and build the kitchen yourself. The tools are well made and widely used. The kitchen will be exactly what you want, but you will build the cupboards.
What you will learn. What the OpenAI Agents SDK does well, what it does not do inside a run, and the three things you add to match Pi Durable.
Why it matters. A fair comparison uses the strongest alternative, not a weak one. If you choose Pi Durable, you should know what you gave up.
What it does well
You met the OpenAI Agents SDK in Chapter 22. In TypeScript, it is open source, mature and widely used. On the same Cloudflare infrastructure, in a Durable Object, it gives you:
- The agent loop, with tools, handoffs between agents and guardrails.
- Many models. It can call models from other providers, not only OpenAI's.
- A pause for a person. A tool can require approval. The run stops, and you can save its state as a string (
RunState) and resume it later, even after a restart.
That last point is real: the human-in-the-loop pause works well.
What it does not do inside a run
The SDK saves the run's state when the run pauses. It does not save a checkpoint before each step. So if the process dies in the middle of a run, the run is gone.
Tested for this book. We built the same AP worker on @openai/agents 0.22.0 in a Durable Object and crashed it at the same place, right after it posted an invoice. The approval pause before it had worked. But after the crash, nothing resumed. The invoice was posted, and no record said the step had finished. Running the saved state again would have posted it a second time, because the tool made a new key each time.
What you add
To make the SDK worker as safe as the Pi Durable one, you add three things:
- A checkpoint before each tool call. You have two choices. Make each model turn and tool call a step in a Cloudflare Workflow. Or save the run's progress in your own table before each call.
- An idempotency key saved before each outside action, so a rerun finds the same key.
- A wake-up for unfinished runs. An alarm on the Durable Object that finds a run that stopped half way and carries it on.
None of this is hard for an experienced engineer, and Claude Code can write it. But it is your code to test and keep working. In the lab you ask Claude Code to add it, and count the lines.
How to read the comparison
| Pi Durable | OpenAI Agents SDK | |
|---|---|---|
| Checkpoint before each step | Built in | You add it |
| Safe rerun of a tool after a crash | Built in, per tool | You add it |
| Wait for a person without holding a process | Built in | Built in (RunState) |
| Many model providers | Yes | Yes |
| Maturity | Experimental | More mature |
| Engineering you own | Less | More |
Both are honest choices. Pi Durable gives you more for free inside a run and asks you to accept an experimental package. The SDK is more mature and asks you to build durability yourself.
The invariant. Putting an agent framework inside a Durable Object does not make its runs durable. Durability comes from saving each step, and from keys that make a rerun safe.
Check yourself. Your SDK worker saves RunState only at approval pauses. It crashes after a tool call that came after the approval. What does the saved state contain? (The run as it was at the pause, before the tool ran. A rerun would call the tool again.)
Sources
- Owner
- Panaversity