Chapter 34. Workers Delegate, Workflows Execute
- Approved by
- Panaversity ·
The point
A worker should not do everything inside a conversation. In Chapter 33 you built an AP worker that handles one invoice in one conversation. It survives a crash and waits days for a person. That is the right shape for a question, a decision or a single payment.
Month-end reconciliation is a different kind of job. It has ten steps, takes hours, waits days for a review and must finish even if nobody is talking to the worker. It has a beginning and an end, and the finance team wants to see where it is. That is a business process, and it should run as one: with its own ID, its own record, its own retries and its own approvals.
So the rule of this chapter is short. The worker decides. A process carries out the work. The worker understands what was asked, checks that it may do it, and starts the right process. The process runs. When it ends, the worker explains the result.
Most work does not start with a person. Invoices arrive from the accounting system as web events. Reconciliation starts on the first of the month. This chapter also shows how that work arrives safely, and what happens when one worker has twenty conversations open at once.

Where this chapter sits in Part IV. The same map opens every chapter, with that chapter's parts highlighted.
Why it matters
This story is invented.
A finance manager asks an AP worker to reconcile November. The worker starts the job. A few seconds later the machine restarts, before the worker has written down the job's ID. The worker restarts, sees no record of a job, and starts another. Two reconciliations now run on the same month. Both write exception reports. Both send a reviewer an email. The reviewer approves one, rejects the other, and the published report depends on which one finished last.
Nobody wrote a bad line of code. The handoff between the worker and the process had no rule for "started, but not yet written down". This chapter is about that handoff, and about the other places where one worker's many parts can step on each other.
Words this chapter uses
The words of Chapters 32 and 33 keep their meaning: durable, checkpoint, Durable Object, replay-safe, idempotency key, signal, release.
| Word | Meaning |
|---|---|
| Business process | A job with defined steps, a start and an end, such as a month-end reconciliation |
| Workflow | A program that runs a business process as saved steps, each retried on its own |
| Delegate | To hand a process to something else to run, and keep track of it |
| Process ID | A stable name for one run of a process, such as recon-acme-2026-11 |
| Web event | A message another system sends your Worker over the web when something happens, also called a webhook |
| Schedule | A rule that starts work at a time, such as "06:00 on the 1st" |
| Queue | A list of messages waiting to be handled, so the sender does not wait |
| Outbox | A table where a step writes the events it must send, in the same save as its own state |
| Consumer | The code that takes events from an outbox or queue and handles each one once |
| Coordinator | One object per worker that holds what all its conversations share: budget, locks, the stop switch |
| Revoke | To stop a worker everywhere, at once |
| Operation ID | The ID sent with each message to a conversation; Pi Durable accepts each one once (Chapter 33) |
| Assignment | One piece of work the worker was given, such as Ana's request to reconcile November |
| Cron Trigger | Cloudflare's schedule for a whole Worker, which calls it at set times, in UTC |
| Lifecycle job | A timer for one conversation, kept by Lifecycle, which owns the conversation object's alarm |
| Lock | A claim on a business record, such as Acme's payment run, so only one holder acts on it at a time |
What you will build
Where you are. Chapter 33 gave you Brightline's AP worker: one Durable Object per conversation, three invoice tools, an approval that waits for days, and a cost per invoice.
What you build, with Claude Code, from your own spec and failure tests:
- A web event endpoint for invoices that arrive from the accounting system, and a month-end schedule.
- The reconciliation Workflow: ten steps, from fetching invoices to telling the worker it is done.
- A safe handoff: a stable process ID, an outbox and a Postgres consumer that accepts each event once.
- A review that waits inside the Workflow, separate from the per-invoice approval of Chapter 33.
- A coordinator object for the worker: one budget, locks on business records and one switch that stops everything.
By the end of this chapter, you can decide which work belongs in a conversation and which in a process. You can build the handoff so it never starts a job twice. And you can keep many conversations of one worker inside one set of limits.
In this chapter
- 34.1 Two kinds of durability
- 34.2 Choosing the right mechanism
- 34.3 How work arrives: web events and schedules
- 34.4 Build the reconciliation Workflow with Claude Code
- 34.5 The handoff that can go wrong
- 34.6 Approval at two levels
- 34.7 Many conversations, one worker
- 34.8 Mistakes, limits and how today's tools realize it
- Lab 34 The worker delegates, the Workflow executes
What this chapter is built on
The chapter follows section 7 and section 6.3 of Panaversity's paper Building Affordable, Self-Improving AI Workers (29 November 2026), and appendices A2 and A6 of its technical companion. Workflow costs come from the paper's cost model, model.ts. The Workflow, Queue, Cron and coordinator code in this chapter was tested on Wrangler's local runtime on 30 November 2026, but not yet on a deployed account. Check each API against the installed documentation, as CLAUDE.md tells Claude Code to.
Sources
- Building Affordable, Self-Improving AI Workers (Panaversity, 29 November 2026), sections 6.3 and 7, and companion appendices A2 and A6
- Cloudflare Workflows (Cloudflare documentation, verified 2026-11-29)
- Owner
- Panaversity