Skip to content
The AI Agent Factory

Part IV. Building Affordable, Self-Improving AI Workers

Approved by
Panaversity ·
11 min read

The Tech Stack for an AI-Native Startup

The point

A worker that costs more than it earns is a hobby, not a business. At the end of Part III, Brightline's AP worker runs on Claude Managed Agents. It learns from its own runs. It works. This part asks the next question: what does it cost to run and to teach, and who decides that cost?

On Claude Managed Agents, Anthropic does. Every model call goes to a Claude model, at Claude's prices. For many workers that is the right choice. For a worker you sell by the month, the model bill is the largest cost you can control. A platform that runs only one family of models puts a ceiling on your margin.

This part builds the same worker on an open stack instead. Pi Durable is the harness, and Cloudflare Durable Objects are the runtime. Cloudflare Workflows run the business processes the worker hands off. That stack can call any model, Claude included. You will not build it from scratch. You assemble ready parts, and add only the professional layer on top: memory, governance, learning and cost control.

You build every part of it with Claude Code. You write the spec and the failure tests first. Claude Code writes the code until the tests pass. Then you review what it wrote, with a checklist. You stay the engineer in charge.

The six chapters

ChapterWhat you buildThe question it answers
32 Choosing the FoundationTwo small workers, one on each foundation, and a priced memoShould this worker run on Claude Managed Agents or an open stack?
33 Building a Durable AI Worker on Cloudflare with Claude CodeThe full AP worker on Pi Durable, one Durable Object per conversationHow does a worker survive crashes and wait for people, without paying for the wait?
34 Workers Delegate, Workflows ExecuteA reconciliation Workflow, webhooks and schedulesHow does a worker hand off a business process it cannot finish in one conversation?
35 The Worker PlatformA control plane, model routing and a role contractHow do ten workers for three companies stay inside their rules and their budget?
36 The Self-Improvement PlatformChapter 31's learning loop on any modelHow does learning stay the company's, and get cheaper as the worker gets better?
37 The Economics of Digital FTEsA monthly contribution report and a price floorDoes each worker earn more than it costs to run, review and teach?

The part ends with The First Reference Worker: the smallest platform that learns, put together from the labs, with nothing new to build.

For founders: the stack and the strategy

If you plan to build a company on AI Workers, this part gives you its technology: a stack that any model can run on, built by a small team with Claude Code, with costs you can measure and a margin you can protect. A stack is not a strategy. Anthropic's guide The Founder's Playbook: Building an AI-Native Startup gives the strategy. It follows a startup through four stages: Idea, MVP (minimum viable product), Launch and Scale. Its main point is that building is no longer the hard part. Choosing what to build is.

The two fit together. The workers you build in Chapters 33 and 34 are the kind of product an MVP needs. The control plane, the learning platform and the contribution report in Chapters 35 to 37 are what Launch and Scale ask for: rules that hold for many customers, workers that get better and cheaper, and a price that covers the cost. Part VII teaches each of the four stages.

Reference: Anthropic, The Founder's Playbook: Building an AI-Native Startup, May 2026, https://claude.com/resources/guides/the-founders-playbook-building-an-ai-native-startup

Where this part sits in the book's architecture

Chapter 4 drew the worker in layers: channels, runtime, memory, and three records the company owns. This part builds the runtime and the platform around it. It does not build the three records. Like Part III, it uses plain stand-ins for them, and Part VI replaces each stand-in with the governed record.

Chapter 4's layerWhat this part buildsWhat Part VI changes
Channels, where people and systems reach the workerSigned web events, approval links and a small API (Chapters 33 to 35)Nothing: the worker is not its interface
RuntimePi Durable in a Durable Object per conversation, and Workflows for business processes (Chapters 33 and 34)Nothing
MemoryMemory tables in Neon, each memory with its source, approver and expiry (Chapter 36)Nothing: memory stays the worker's
Approved knowledge (KSoR)A stand-in: approved procedures and the role contract, in Neon tables (Chapters 35 and 36)The KSoR becomes the authority. The worker reads policies and limits from it
Case files (SSoR)A stand-in: assignment and process records, process events and usage rows (Chapters 34 and 35)Each matter gets its case file in the SSoR
Governed door (DSoR)A stand-in: authorize checks against the role contract, approvals, and idempotency keys at the ledger (Chapters 33 and 35)Reads and writes to company systems go through the DSoR

One rule holds while both exist: where a stand-in and a system of record disagree, the system of record wins. So build the stand-ins behind small interfaces, such as one authorize function and one place that writes a process record. Part VI can then replace what is behind them without touching the worker.

The worker is not its interface. A person may reach Brightline's AP worker through a chat, an email, an approval link, or a screen inside another product. None of these holds the worker's rules. Its authority is checked in code at each tool and each process step, so a new channel cannot widen what the worker may do. You can add a channel without rewriting the worker's business logic or its controls, and you should be able to.

Two paths through the labs

Each lab marks its tasks as core or extension. The core tasks teach what the next chapter builds on, and they are enough to move on. Each lab's download includes what it needs from the labs before it. The extension tasks, such as the port to another model, go deeper, and you can come back to them.

Before you start

You need Part III, above all Chapter 23 (hosted agents), Chapter 29 (model selection and cost) and Chapter 31 (self-improving workers). You need Claude Code, as in Chapter 12, a free Cloudflare account and a free Neon account. Every lab sets a billing notification first, and every lab's tests run without an API key, from recorded model answers.

This part is beyond the exams. No Anthropic exam objective is taught here first. Part V, which comes next, holds the Developer Professional exam. Some chapters here help with it, and they say so.

Owner
Panaversity