# 34.2 Choosing the right mechanism (/affordable-self-improving-ai-workers/workers-delegate-workflows-execute/choosing-the-right-mechanism)

---
type: Document
title: "34.2 Choosing the right mechanism"
description: "Six ways to run a piece of work, from a direct tool call to a Workflow, a decision table for choosing the lightest one that is safe, and how Claude Managed Agents, the OpenAI Agents SDK and the open stack each hand work to a process."
status: stable
order: 434.02
ksor:
  owner: team:panaversity
  audience: [ public ]
  approval:
    by: process:panaversity
    at: 2026-11-30T08:18:55Z
chapter: "34"
part: IV
expert_status: manager
concepts: [ "34.2" ]
last_verified: 2026-11-29
sources:
  - id: paper
    title: "Building Affordable, Self-Improving AI Workers (Panaversity, 29 November 2026), sections 7.3 and 18.3"
    resource: "Panaversity paper, version 1.0, 29 November 2026 (not yet published)"
  - id: cf-workflows
    title: "Cloudflare Workflows (Cloudflare documentation, verified 2026-11-29)"
    resource: https://developers.cloudflare.com/workflows/
  - id: openai-agents-js
    title: "OpenAI Agents SDK for TypeScript (verified 2026-11-29)"
    resource: https://openai.github.io/openai-agents-js/
generated:
  at: 2026-11-30T08:18:55Z
  by: human:zia
trust_tier: unverified
build_id: sha256:d6ce3f28a2cf8e492a60bae1b426b7cc6466e35e83d70c3b9763db2c55009f4b
dirty: true
ksor_version: 0.0.60
---

**In everyday life.** You do not hire a removal company to carry a chair to the next room. You do not carry a piano downstairs by yourself either. The size and risk of the job decide the tool.

**What you will learn.** Six ways to run a piece of work on the open stack, how to choose the lightest one that is safe, and how each foundation hands work to a process.

**Why it matters.** A Workflow for every small job adds cost, code and places to fail. No Workflow for a big job loses work. The choice is a design decision you should be able to explain.

### Six mechanisms, lightest first

| Mechanism | Use it for | Example in the AP worker |
| --- | --- | --- |
| Direct tool call | A short action with an immediate result | Look up an invoice |
| Pi Durable task | Recoverable work inside the current conversation: a tool call Pi saves as a step, as in Chapter 33 | Post one approved invoice |
| Lifecycle job | A timer or deferred job for one conversation, run by `Lifecycle`, which owns the object's alarm (34.3) | "Remind me on Friday if Ana has not answered" |
| Fiber | Recoverable application work tied to one object, from Cloudflare's Agents SDK | Not used in this part; test it yourself before you rely on it |
| Queue | Taking in events fast, and handling them in the background | Invoices arriving from the accounting system |
| Workflow | A process with several steps, long waits, its own retries, or a life beyond the conversation | Month-end reconciliation |

Start at the top of the table and move down only when the job needs it.

### When a Workflow is worth it

Use a Workflow when **one or more** of these is true:

- The job must have its own life, start to end, separate from the conversation.
- It has several business steps, and each can fail and be retried on its own.
- Different steps need different retry rules: retry a slow API five times, but never retry a payment without checking first.
- It may wait a long time: days for a reviewer, a week for a supplier.
- It must finish even if nobody talks to the worker again.
- People need to see its progress and know when it is done.

**About 30 seconds** is a useful rough guide. A job that usually finishes in a few seconds probably belongs in a tool. A job that takes minutes or hours probably does not. It is a guide, not a rule: a ten-second job that must outlive the conversation still needs a Workflow.

**A person's approval alone is not a reason.** Since Pi 1.6, a tool can wait days for a person without keeping the object awake. Whether the approval belongs in a Workflow depends on what is being approved, as 34.6 explains.

### What a Workflow costs

Little. The paper prices the medium worker at about 2,400 Workflow steps a month, which is **about $0.02 a month** on Cloudflare's paid plan prices. On the free plan you pay nothing while you learn. The cost of a Workflow is not money. It is the code you write and keep for the handoff, which the next pages cover.

### How each foundation hands work to a process

*Checked on 29 November 2026.*

**Claude Managed Agents.** A session can start an outside process through a tool, and wait for its result. The process itself lives outside Anthropic, on whatever runs your business processes. Chapter 23 showed schedules and web events with Claude Managed Agents. The handoff problem in 34.5 is the same there: the tool must start the process once, with a stable ID.

**OpenAI Agents SDK.** The SDK runs the agent loop. For a durable process it hands off to a workflow engine. Some durable workflow engines offer integrations with the Agents SDK; check which languages and versions they support before you choose one. As Chapter 32 showed, the SDK itself saves state only at a pause.

**The open stack.** Cloudflare Workflows. A Workflow is a class with a `run` method. Each `step.do` is saved when it finishes and retried on its own if it fails. `step.sleep` and `step.waitForEvent` wait without running. Workflow state is kept for a limited time after it ends: 3 days on the free plan, and 7 days by default on the paid plan, up to 30. So the lasting record of each run goes in your own Postgres table.

| | Claude Managed Agents | OpenAI Agents SDK | Open stack |
| --- | --- | --- | --- |
| Where the process runs | Outside Anthropic, your choice | A workflow engine you add | Cloudflare Workflows |
| Who writes the handoff | You | You | You |
| Can the agent and the process share one store? | No | Depends on your engine | Not in one transaction |

The last row is why 34.5 exists. On every foundation, the agent's state and the process's state live in different places, and no transaction covers both.

> **The invariant.** Use the lightest mechanism that is safe. A Workflow earns its place when the job has steps, waits or a life of its own.

**Check yourself.** The worker must email a supplier a copy of a rejected invoice. It takes one call and two seconds. Workflow or not? *(Not. It is a single short action. Make it a Pi Durable task with a saved idempotency key, so the email is not sent twice after a crash.)*
