# Lab 34: The worker delegates, the Workflow executes (/affordable-self-improving-ai-workers/workers-delegate-workflows-execute/lab)

---
type: Document
title: "Lab 34: The worker delegates, the Workflow executes"
description: "Lab 34: from your own spec and failure tests, have Claude Code add a reconciliation Workflow, a signed invoice webhook, a month-end schedule, a safe handoff and a per-worker coordinator to Brightline's AP worker, then break each one on purpose."
status: stable
order: 434.9
ksor:
  owner: team:panaversity
  audience: [ public ]
  approval:
    by: process:panaversity
    at: 2026-11-30T08:18:55Z
chapter: "34"
part: IV
expert_status: manager
concepts: []
last_verified: 2026-11-29
generated:
  at: 2026-11-30T08:18:55Z
  by: human:zia
trust_tier: unverified
build_id: sha256:d6ce3f28a2cf8e492a60bae1b426b7cc6466e35e83d70c3b9763db2c55009f4b
dirty: true
ksor_version: 0.0.60
---

**What you do.** You spec a month-end reconciliation and its failure tests. Claude Code builds it as a Workflow that the AP worker from Lab 33 starts. Then it adds a web event endpoint, a schedule, a safe handoff and a coordinator for the worker. Then you break every part on purpose: cut the handoff, send events twice, fire the schedule twice, revoke the worker mid-run.

**What you need.** Your finished Lab 33 folder, or the lab's starting point. The setup from [32.8](../choosing-the-foundation/set-up-once-with-claude-code.md). No API key: every test runs on recorded model answers. Task 8 needs access to Claude Managed Agents and is optional.

**Download.** [brightline-lab-ch34.zip](https://github.com/panaversity/agentfactory-v2-resources/releases/latest/download/brightline-lab-ch34.zip). It ships a month of invoices and purchase orders for two clients, Acme and Lahore Foods, and a fake accounting system that sends signed web events (`npm run event`). It also ships recorded model answers for unclear matches, the crash and clock helpers from Lab 33, and an empty `spec-reconcile.md`. If your Lab 33 folder is not finished, start from the Lab 33 solution it includes. Scripts read a process (`npm run process`), answer a review (`npm run review`) and revoke the worker (`npm run revoke`). Each task's answer key is its own download, such as [Task 1's answer key](https://github.com/panaversity/agentfactory-v2-resources/releases/latest/download/brightline-lab-ch34-key-task-1.md). For another task, change the number at the end of that address. The complete solution is one more download, [brightline-lab-ch34-answer-key.zip](https://github.com/panaversity/agentfactory-v2-resources/releases/latest/download/brightline-lab-ch34-answer-key.zip). Unzip it inside your lab folder, and open it only after you try.

**How a task works.** Each task gives you a request to send to Claude Code, then **What good looks like**, then **Check before you approve**. Predict first, then check.

**Core path.** Tasks 0 to 7. **Extension.** Task 8, the timer and the port. The core tasks are enough for the next chapter. Each lab's download includes what it needs from the labs before it, so a skipped extension never blocks you.

### Sitting 1: specify and build

#### Task 0. Start clean

> Task 0. Read CLAUDE.md, the lab README and my Lab 33 code. Install the pinned packages. Run npm test: the Lab 33 tests should pass and the new ones should fail. Change nothing.

**Check before you approve.** Is your Cloudflare billing notification still set?

#### Task 1. Write the spec

Write `spec-reconcile.md` yourself from [34.4](build-the-reconciliation-workflow.md). It needs the ten steps and the retry rule of each, which step may call a model and its budget, the review and its timeout, and the seven failure tests. Add the web event rules from [34.3](how-work-arrives.md) and the six guarantees from [34.7](many-conversations-one-worker.md).

**Check before you approve.** For each step that changes something outside, have you written its key?

#### Task 2. Web events and the schedule

Send Step 1 from [34.3](how-work-arrives.md). Then:

> Add a Cron Trigger that runs every hour and starts each client's reconciliation when it is 06:00 on the 1st in that client's time zone, with the process ID recon-{client}-{month}.

**What good looks like:** the same signed event sent three times reaches the worker once; a bad signature is refused; the schedule fired twice starts one reconciliation.

**Check before you approve.** What does the web event endpoint do before it replies?

#### Task 3. The Workflow and the handoff

Send Steps 2, 3 and 4 from [34.4](build-the-reconciliation-workflow.md) and [34.5](the-handoff-that-can-go-wrong.md).

**What good looks like:** failure tests 1, 2, 5 and 7 pass. While the Workflow runs, the worker still answers "has invoice INV-1043 been paid?" and "where is November's reconciliation?".

**Check before you approve.** Where is the process ID made? Kill the conversation object with `npm run crash -- after-create`. How many Workflow instances exist afterwards?

#### Task 4. The review and the coordinator

Send Step 5 from [34.6](approval-at-two-levels.md) and Step 6 from [34.7](many-conversations-one-worker.md).

**What good looks like:** failure tests 3, 4 and 6 pass, and the five concurrency tests in 34.7 pass.

**Check before you approve.** Use the checklist in [34.8](limits-and-todays-tools.md). Which line took longest to check?

### Sitting 2: break it

#### Task 5. A long wait, an approval and a rejection

Start November's reconciliation. When it waits for review, stop `npm run dev` and start it again: the Workflow is still waiting. Then approve it with `npm run review -- recon-acme-2026-11 yes`. Start Lahore Foods' November and reject it with a reason.

The test clock moves a conversation's time, not a Workflow's. To test the 7-day timeout, your tests use the Workflow test tools instead, the helpers Cloudflare's test kit gives for driving a Workflow in a test: `forceEventTimeout` ends the wait at once (test 4).

**What good looks like:** the first publishes once, and the worker tells Ana. The second publishes nothing, and the worker repeats the reviewer's reason.

**Check before you approve.** Click the first review link again. What happens?

#### Task 6. Two conversations, one month

Open two conversations and ask both, at the same moment, to reconcile Acme's November.

**What good looks like:** one process, `recon-acme-2026-11`. Both conversations can report its status.

#### Task 7. Revoke the worker

Start a reconciliation and let it reach the review. Revoke the worker. Approve the report. Then send a new invoice event.

**What good looks like:** the Workflow stops before publishing; the invoice event is held, not processed; every conversation refuses to post.

**Check before you approve.** Predict first: is anything lost? Unrevoke the worker with `npm run revoke -- --undo` and see what happens to the held event.

#### Task 8. A timer, and a port

Send an invoice over $500, such as INV-2118, so it waits for Ana. In a second conversation, ask: "Remind me on Friday if INV-2118 is not paid." Then run `npm run advance -- 3d` followed by that second conversation's name, the `conversation` value `npm run send` printed, such as `npm run advance -- 3d conv-7`.

Why a second conversation? A conversation handles one message at a time. The first one is busy: its run is parked, waiting for Ana, so a new message there waits behind it.

**What good looks like:** the reminder arrives in the second conversation, and Ana's approval still waits in the first. The code that set the reminder goes through Lifecycle's jobs, not `setAlarm`.

*Port (optional).* Start the same Workflow from a Claude Managed Agents session, through a tool that calls your Worker with the stable process ID. Does the handoff need any change? Write one paragraph in `docs/handoff-review.md`.

### What you have now

Brightline's AP worker no longer does everything inside a conversation. It takes in events safely, starts each process once, waits for reviews it can trust, and stays inside one budget across all its conversations. Later in this part, the platform runs many such workers for several companies, and the worker learns.
