# Chapter 32. Choosing the Foundation: Claude Managed Agents or an Open Stack (/affordable-self-improving-ai-workers/choosing-the-foundation/overview)

---
type: Document
title: "Chapter 32. Choosing the Foundation: Claude Managed Agents or an Open Stack"
description: "Nobody builds an agent platform from scratch. Compare Claude Managed Agents with an open stack on Pi Durable and Cloudflare, price your own worker on each, and choose with numbers."
status: stable
order: 432
ksor:
  owner: team:panaversity
  audience: [ public ]
  approval:
    by: process:panaversity
    at: 2026-11-30T08:18:55Z
chapter: "32"
part: IV
expert_status: manager
objectives: [] # by design: beyond the exams (DEC-33, DEC-62)
word_budget: 4000
prerequisites: [ "23", "29", "31" ]
build_step: "The same small AP worker built twice with Claude Code, on Pi Durable in a Durable Object and on the OpenAI Agents SDK in a Durable Object; both killed mid-run; a one-page foundation memo priced with model.ts"
artifact: "brightline-lab-ch32 with CLAUDE.md, spec.md, a Pi Durable worker, an Agents SDK worker, crash tests, and docs/foundation-memo.md"
field_guides: []
delta_entries: []
concepts: [ "32.1", "32.2", "32.3", "32.4", "32.5", "32.6", "32.7", "32.8", "32.9" ]
last_verified: 2026-11-29
sources:
  - id: paper
    title: "Building Affordable, Self-Improving AI Workers: Pi Durable and Cloudflare as the Foundation for an Open, Model-Independent Alternative to Claude Managed Agents (Panaversity, 29 November 2026)"
    resource: "Panaversity paper, version 1.0, 29 November 2026 (not yet published)"
generated:
  at: 2026-11-30T08:18:55Z
  by: human:zia
trust_tier: unverified
build_id: sha256:d6ce3f28a2cf8e492a60bae1b426b7cc6466e35e83d70c3b9763db2c55009f4b
dirty: true
ksor_version: 0.0.60
---

## The point

**Nobody builds an agent platform from scratch. The real choice is the foundation you build on.** In Part III you hosted Brightline's AP worker on Claude Managed Agents, and taught it to learn. Anthropic ran everything under it. That was the fastest way to a working worker.

This chapter asks whether it is the cheapest way to *keep* one. It compares two foundations. The first is **Claude Managed Agents**, which you know. The second is an **open stack**: Pi Durable, an open-source harness, running on Cloudflare Durable Objects and Workflows. You did not write either one, and you will not. On both, you add only the professional layer: the worker's memory, its rules, its learning and its cost control.

**The model decides the choice.** Model calls are the largest running cost of an AI worker that you can control. Claude Managed Agents runs only Claude models. An open stack can run any model, Claude included, so each kind of work can go to the cheapest model that does it well. This chapter shows how much that is worth, honestly, including when it is worth very little.

![A map of the Part IV platform in four rows, foundation at the bottom, then work, platform and learning, with economics as a column on the right. Highlighted as this chapter, Chapter 32: Harness (Pi Durable); Runtime (Durable Objects); Process engine (Cloudflare Workflows); Model access (any model, AI Gateway). Dashed, later in this part: Memory (facts, source, expiry); Dreaming (proposes candidates); Evaluation (held-out cases, new judge); Releases (approve, canary, roll back); Control plane (workers, versions, tenants); Model router (filter, then rank); Role contracts (one authorize check); Tenant walls (and proven deletion); The AP worker (one object per conversation); Waits, approvals (asleep, not paying); Workflows (month-end reconciliation); Events, schedules (per-worker coordinator); economics (Chapter 37). A note at the foot says approved knowledge, case files and the governed door are stand-ins here, and Part VI replaces them with the systems of record.](img/part-iv-map-ch32.png)

*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, but the numbers in it come from the Panaversity paper this part is built on.

A two-person firm in Lahore sells an AP worker to small distributors for $100 a month. Its first ten customers love it. Then the firm looks at its costs. On Claude Managed Agents, each worker costs about $56 a month to run, review and teach. That leaves $44. Most of the $56 is model calls and the minutes a person spends checking the worker's work. The firm cannot cut its price to win bigger customers, because it cannot choose a cheaper model for the simple jobs.

A rival firm runs the same kind of worker on an open stack. It sends routine invoice reading to an economy model and keeps Claude for the hard cases. Its cost is about $30 a month for the same work. It can charge less and still earn more.

Neither firm wrote an agent platform. They chose different foundations. This chapter teaches you to make that choice with numbers, not with loyalty or fashion.

## Words this chapter uses

The words of Chapters 23, 29 and 31 keep their meaning: session, run, harness, memory store, dreaming, golden set.

| Word | Meaning |
| --- | --- |
| Foundation | What your worker runs on: the harness, the runtime, the process engine and the model access. You choose it; you do not write it |
| Harness | The software around the model that runs its loop, calls its tools and keeps its state |
| Open stack | A foundation made of parts you can see, change and run where you choose, here Pi Durable on Cloudflare |
| Durable | Able to survive a crash: work already done is not lost or done twice |
| Checkpoint | A saved point in a run. After a crash, the run starts again from the last checkpoint |
| Durable Object | A small Cloudflare program with its own storage. Your worker gets one per conversation |
| Hibernate | To sleep without being billed, and wake on the next event |
| Economy model | A low-priced model that does routine work well, such as Qwen Flash or DeepSeek Flash |
| Lock-in | When moving away from a product costs so much that you stay even if a better choice exists |
| Variable cost | A cost that grows with the work: model calls, runtime, review minutes |
| Contribution | What a worker earns minus its variable costs. It is not profit: fixed costs come out later |
| Idempotency key | A unique label on an action, so that doing it twice has the effect of doing it once |

## What you will build

**Where you are.** Brightline's AP worker runs on Claude Managed Agents for two companies, and learns from its runs (Chapter 31). Brightline now wants to sell it to more distributors at a lower price.

**What you build.** As in every chapter of this part, Claude Code writes the code. You write the spec and the tests, and you review.

1. **The setup for the whole part:** a free Cloudflare account with a billing notification, Wrangler, a free Neon database, and a `CLAUDE.md` that pins the versions.
2. **A first worker on Pi Durable,** in a Durable Object, with one read-only AP tool. You kill it in the middle of a run and watch it carry on.
3. **The same worker on the OpenAI Agents SDK,** from the same spec. The same kill loses the step. You ask Claude Code to fix it, and count the code it adds.
4. **One model change:** the Pi Durable worker moves to an economy model, and you compare quality and cost on five golden questions.
5. **A one-page memo** that chooses a foundation for Brightline, with the numbers.

**By the end of this chapter,** you can price an AI worker on two foundations, explain where the difference comes from, and choose one with evidence. You can also say what would change your choice.

## In this chapter

- [32.1](the-foundation-not-the-platform.md) The foundation, not the platform
- [32.2](claude-managed-agents-first.md) Claude Managed Agents first
- [32.3](the-model-is-the-biggest-bill.md) The model is the biggest bill
- [32.4](price-your-own-worker.md) Price your own worker
- [32.5](why-this-open-stack.md) Why this open stack
- [32.6](the-fair-alternative.md) The fair alternative: the OpenAI Agents SDK
- [32.7](when-each-fits.md) When each foundation fits
- [32.8](set-up-once-with-claude-code.md) Set up once, and build with Claude Code
- [32.9](how-todays-tools-realize-it.md) How today's tools realize it
- [Lab 32](lab.md) One worker, two foundations, one memo

## What this chapter is built on

The chapter follows Panaversity's paper *Building Affordable, Self-Improving AI Workers* (29 November 2026), its technical companion and its cost model, `model.ts`. Every cost in the chapter comes from that model, with the prices checked on 29 November 2026. The figures are the paper's illustration, not a promise: you will replace them with your own measured numbers in the lab.
