Pi Durable, Cloudflare Workflows, or Vercel Workflow?

By

Updated

Tagged: AI

Compare agent crash recovery with durable workflow platforms. Follow one research task through storage, retries, approvals, and the work you still own.

Picture a support agent that looks up a customer’s issue, drafts a reply, and waits for someone to approve sending it. If your server restarts halfway through any of those stages, the job still needs to pick up where it left off.

You can build that with Pi Durable, Cloudflare Workflows, or Vercel’s Workflow SDK. Picking between them changes where your state lives, who restarts crashed work, and how much of the agent loop you write yourself.

It helps to separate two layers first. An agent harness runs the model turns and tool calls. A workflow runtime saves durable checkpoints and makes sure unfinished jobs keep moving. Plenty of apps end up using both.

Let’s walk through this same support-reply task on all three platforms to compare how their recovery designs work, rather than benchmarking speed.

Start by separating the agent from its job

Around the AI part, our task is a normal five-step business process:

  1. Load the support request and its account details.
  2. Ask a model to investigate and draft a reply.
  3. Save that exact draft for review.
  4. Wait for an authorized decision.
  5. Send the approved reply and store the provider’s receipt.

Inside step 2, the model rarely finishes in one call. It might read an order, check a policy, and run another lookup before it has enough context to write the draft.

That’s why the business process and the agent loop need different checkpoints. If you only save the final draft, a crash mid-investigation wipes out all the tool calls the model already ran. If you only save the conversation, you still have to build the approval flow and reliable delivery around it.

Fig 1 · 1/4Choose which recovery layer you need
The harness and workflow runtime have different jobs

Pi Durable gives you an agent harness

Pi Durable is a library that persists conversation and execution state, including model requests and tool calls. You supply the model configuration and tools, and Pi takes care of saving the loop as it runs.

You can back it with local SQLite, JSONL files, or a Cloudflare Durable Object SQLite adapter. That means it fits inside a hosted app just as well as a local Node program.

In our support-reply task, Pi Durable can recover an interrupted investigation right from its saved state. Everything around the loop is still up to your app: how new requests arrive, how a crashed worker gets restarted, and who can read the draft.

The Pi Durable tutorial walks through a local SQLite example, which is a good place to start when you want direct control over both the harness and its storage.

If you go with local storage, keep the database on a persistent volume and set up backups. When a new process starts, it needs access to the old database file. Replacing an ephemeral container with an empty filesystem leaves it nothing to resume.

There are two SQLite limits to keep in mind before you scale it out. The built-in Node SQLite adapter separates recovering from a process crash from guaranteeing the newest commits survive a host power loss. Pi Durable also expects a single process to own a storage backend at a time, so don’t point multiple replicas at the same file.

Cloudflare Workflows manages durable steps

Cloudflare Workflows runs a business process as a series of persistent steps. You wrap work whose result needs to survive a retry or restart in step.do, and Cloudflare handles execution and step state.

For our support ticket, loading the request and generating the draft can live in separate steps. When you need to pause for approval, you call step.waitForEvent, and an authenticated route in your app sends the matching event to that instance once someone approves.

That gives you a durable waiting point without extra plumbing. Your app still has to check that the decision belongs to the right draft and came from someone allowed to approve it.

You don’t have to stuff the entire investigation into one opaque step either. Cloudflare’s durable AI agent guide shows how to draw finer boundaries around model and tool work using their supported integration.

Where you draw those boundaries decides what repeats on a failure. If one step combines a model call, several lookups, and an unprotected email send, retrying that step can re-run much more than you meant to.

That’s why Cloudflare’s rules of Workflows advise making API and binding calls idempotent. A remote request can finish right before a crash, before Workflows records the step as successful, so you have to protect against duplicates on the remote side too.

Workflow SDK separates workflow code and step code

Vercel’s Workflow SDK splits your code with "use workflow" and "use step" directives. Workflow functions coordinate the process, while step functions do the work like fetching data or calling a model.

Under the hood, the persistence and execution backend is called a World. The managed option is Vercel World. You can also self-host with a Postgres backend or build a custom World if you want something else.

For our support reply, a workflow coordinates generating the draft and sending it later, and a hook suspends execution until an external decision arrives.

Be careful with permissions on that resume path. A hook token only identifies which paused run to wake up, so your app still needs to authenticate and authorize the caller before resuming the hook.

Going with the managed backend leaves the infrastructure to the provider. If you self-host instead, you own keeping storage available along with the pieces that deliver queued work.

Compare the operational responsibilities

QuestionPi DurableCloudflare WorkflowsWorkflow SDK
What do you program directly?Model/tool harness with durable stateDurable steps, waits, and app integrationWorkflow functions and step functions
Where does recovery state live?Your chosen storage adapterCloudflare’s managed workflow storageYour chosen World’s backend
Who runs the process?Your host app and supervisorCloudflareVercel World or your chosen backend
How does approval fit?App-owned persisted decisionApp authorization plus a workflow eventApp authorization plus a hook
What still needs provider deduplication?Remote side effectsRemote side effects inside retried workRemote side effects inside retried work

Each column here draws the line of responsibility in a different place. These tools don’t have to be mutually exclusive either: a Pi Durable harness can live inside a larger app, and a workflow runtime can coordinate an agent built with a separate library.

Choose using the failure you need to recover

Pick your platform based on which crash hurts most in your setup.

If you’re building a local agent that reads repositories and runs tools, start by checking whether your harness can recover the exact unfinished turn when a process dies. That’s the specific problem Pi Durable solves, and the app around it may only need a supervisor and persistent storage.

Apps that already use Cloudflare bindings have a good test bed in Cloudflare Workflows. Pick one concrete job with several waits and a human approval, since that maps naturally to durable steps and events. Check the runtime limits and how your model library fits before you lock in your step boundaries.

Already running on Vercel? Try the Workflow SDK with its managed World first. If you need to self-host, test the supported Postgres backend early before committing the whole flow to it.

Whichever option you pick, test the email boundary on its own. Let the provider accept a fake message, stop the worker before its receipt gets saved, and then resume the same logical operation. Check whether the provider logged one send or two.

Test the approval boundary the same way. Stop the worker while approval is pending, change the draft afterward, and verify that the old approval can’t authorize the new content. Then cancel the request and try delivering the old approval event again. I built those checks as an agent approval flow that survives a restart.

Start with the smallest support request that hits every one of those boundaries, and make sure its saved state stays available when you replace the worker.

Want me to talk about your product? You can sponsor this site.

Related posts about ai: