# 27.1 Workflow or agent (/building-ai-workers/agent-architecture/workflow-or-agent)

---
type: Document
title: "27.1 Workflow or agent"
description: "Who decides what happens next, your code or the model, and how business needs, error tolerance and audit needs choose a workflow or an agent for each step."
status: stable
order: 327.01
ksor:
  owner: team:panaversity
  audience:
    - public
  approval:
    by: process:panaversity
    at: 2026-11-30T08:16:34Z
chapter: '27'
part: III
expert_status: manager
concepts: [ "27.1" ]
last_verified: '2026-11-30'

sources:
  - id: anthropic-building-effective-agents
    title: Building effective agents (Anthropic, 19 December 2024, verified 2026-11-30)
    resource: https://www.anthropic.com/research/building-effective-agents
  - id: anthropic-ccdv-f-exam-guide
    title: Claude Certified Developer - Foundations Exam Guide, version 1.1, effective December 7, 2026 (read 2026-11-30)
    resource: https://cc.sj-cdn.net/instructor/6nizmqk8tpzpfjvt6qmmav7rh/public/1794946771/Claude_Certified_Developer_-_Foundations_Exam_Guide_Updated_Dec_7.pdf
  - id: claude-code-workflows
    title: Orchestrate subagents at scale with dynamic workflows (verified 2026-11-30)
    resource: https://code.claude.com/docs/en/workflows
generated:
  at: 2026-11-30T08:16:34Z
  by: esl-rewrite/1.2.0+ksor.1
trust_tier: unverified
build_id: sha256:d6ce3f28a2cf8e492a60bae1b426b7cc6466e35e83d70c3b9763db2c55009f4b
dirty: true
ksor_version: 0.0.60
---

**In everyday life.** You travel to a cousin's wedding in another city. The long part of the trip is a bus. Its path was fixed before you left: the same roads and the same stops, every day. You can show anyone the timetable and say where the bus will be next month. The last part is a taxi, because you do not know which gate of the hall will be open. The driver decides street by street. Afterward you can say which streets the taxi took. You could not have promised them before. You never chose "bus" or "taxi" for the whole trip. You chose for each part. In this section, the bus is a step that code holds, the taxi is a step the model keeps, and the trip is the job.

**What you will learn.** You practice this in Lab 27, Task 1, where you fill the table before you build.

- What is a workflow, and what is an agent?
- Why is the choice made for each step, and not for the job?
- What do the guide's three tests decide?
- What does code still hold in a step the model keeps?
- What does each choice cost?

**Why it matters.** Suppose you choose one design for the whole job. Then you give the model steps it should never decide, or you give code steps it cannot plan for.

**At work.** It is Wednesday morning. The auditors' second question has no answer yet ([The point](overview.md#the-point)). You open `docs/architecture.md` and write the review's steps down the side. Before you fill a row, you ask Dave for three things, and he answers in three sentences.

- *What the review must do:* every open invoice gets a decision, with the policy line for each problem.
- *What may go wrong:* the review may flag an invoice that is fine. It may never skip one.
- *What the auditors need:* for any invoice, show which steps ran, in what order and on which values, and show that the same invoice would go through the same steps next month.

<!-- EDITOR: Dave's three sentences above are proposed in the spec (raised point 3b). No page of the book states Brightline's audit needs, and they are not yet in specs/labs/part-2-facts.md. They also leave a gap: they cover a fine invoice that is flagged and an invoice that is skipped, and say nothing of a problem invoice that the review calls fine. This section sends that case to Chapter 24's golden sets. The options: add a clause for it to Dave's second sentence, in the spec and the facts file, or leave the sentences as they are. -->

### What is a workflow, and what is an agent?

**In a workflow, code that you wrote holds the plan. In an agent, the model holds it.** Anthropic's engineers define both: "Workflows are systems where LLMs and tools are orchestrated through predefined code paths. Agents, on the other hand, are systems where LLMs dynamically direct their own processes and tool usage".[^anthropic-building-effective-agents] An LLM is a large language model, the kind of model this book calls a model.

The plan is the order of the steps, each branch, and when to stop.

The word has two other uses. Part II used "workflow" for the steps a team already follows (9.1). And Claude Code's documentation calls a script that the model itself writes a "dynamic workflow" (27.7).[^claude-code-workflows] In this chapter a workflow is code the builder wrote.

Afterward the trace shows who decided: a call your code started, or a tool call the model chose. In Lab 27 your workflow writes one span for each call its code makes, so you can read both designs in the same way.

### Why is the choice made for each step, and not for the job?

**Because one job holds both kinds of step.** The exam guide asks you to evaluate "whether a workflow or an agentic architecture fits".[^anthropic-ccdv-f-exam-guide] Agentic means built around an agent. An **architecture** is the answer written as a table: one row for each step, and in each row, who decides what happens next. There are three possible owners: code you wrote before the run, the model during the run, or a person.

Your worker has been both designs since Chapter 23. It is code around a session, with a model inside it (23.16).

Some steps are both kinds at once. "Is this invoice a problem?" changes with what is found, and the auditors want it on the same path every time. Split such a step until each part is one kind or the other. Looking up the vendor and the purchase order is the same every time. Judging what they show is not.

### What do the guide's three tests decide?

**Each test decides who can own a step.** The guide's words are "business requirements, error tolerance, and audit constraints".[^anthropic-ccdv-f-exam-guide] In the table they are three columns, and Dave's three sentences fill them.

| The guide's words | The question for one step | What the answer decides |
| --- | --- | --- |
| **Business requirements** | Is this step known before the run, or does it change with what the worker finds? | Known before the run: code. Changes with what is found: the model may keep it |
| **Error tolerance** | What does a wrong choice cost here, and what would catch it? | Cheap, or caught by a check: the model may keep it. Costly, and no check catches it: a person |
| **Audit constraints** | Must the step take the same path every time, or is a record of the path enough? | The same path: code. A record: either design gives one |

Here are three rows of Brightline's table.

| Step | Business requirements | Error tolerance | Audit constraints | Who decides |
| --- | --- | --- | --- | --- |
| Take the next invoice | Known. Every open invoice, one at a time | A skipped invoice, which the review may never have | The same path | Code, as a loop |
| Look up the vendor and the purchase order | Known. Each is a lookup by id | A decision that depends on the wrong terms | The same path | Code |
| Find the policy line and decide | Changes with what is found | A fine invoice is flagged, which Dave accepts. The check tests each policy line against what `search_policy` returned | A record of its searches | The model |

The check tests that each entry is there and that its policy line is real. It does not test the judgment itself. That is measured on cases with known answers, as [Chapter 24](../evaluating-ai-workers/golden-sets.md)'s golden sets do.

"Audit" can mean two things, and the third column asks which. It can mean the same path every time, which only code gives. A model's wording changes from run to run ([19.16](../business-data-and-retrieval/measuring-retrieval.md)), and so can its next step. Or it can mean a record of the path that was taken, which a trace gives for either design. So an agent's run can be audited too. What it cannot promise is next month's path.

### What does code still hold in a step the model keeps?

**A stop, a boundary and a check.** The table has six columns: the step, the three tests, who decides, and a sixth for these three. You fill the sixth for each step the model keeps.

- *A stop:* the step's own turn limit, inside the run's budget (21.8).
- *A boundary:* the tools that step has. "Find the policy line and decide" gets `search_policy` and nothing else.
- *A check:* code that tests what comes back (23.16).

A step that must always happen, or must never happen, belongs to code as well. The form of "always" is the loop, and the form of "never" is the boundary. The review never pays an invoice, because no step has a tool that pays.

A person takes a step when a wrong choice costs too much and no check would catch it. Approving Friday's payment run stays with Dave (9.1).

Under the steps, the table has four more rows, for the whole run. They are when the run stops, what a helper sees, whose notes the run may read, and what stays in the window. Each needs an owner too, and 27.6 uses them to read a failing run.

### What does each choice cost?

**Code handles only what you planned for. The model handles more, costs more, and may take another path.** Anthropic's engineers say in one sentence what each side gives: "workflows offer predictability and consistency for well-defined tasks, whereas agents are the better option when flexibility and model-driven decision-making are needed at scale."[^anthropic-building-effective-agents] They also say what the flexible side costs: "The autonomous nature of agents means higher costs, and the potential for compounding errors."[^anthropic-building-effective-agents] A compounding error is one early mistake that every later step builds on.

So the other choice is often fair. Where no audit asks for the same path, a step can stay with the model, inside its stop, its boundary and its check.

**The operating rule:** do not ask whether the job is a workflow or an agent. Ask, for each step, who decides what happens next, and write the answer down.

<!-- EDITOR: do the concepts give away Task 1's main decision? Who owns each step of the workflow is printed in "The point", in Figure 27.1, in the table of three rows above and in 27.2's plan, and Task 1's first prediction ("a line of your code, or the model?") is answered in "The point". The spec's worked run tells it, so this draft follows the spec. The other option: 27.1's example table uses another job, and the prediction asks something the page does not answer, such as whether the orchestrator hands every vendor lookup to `vendor-lookup`. -->

**Do this now.** Ask your coding agent to draw this table for a worker you already have. Copy this line:

> Read this project's worker and its newest trace. List each step of one run, in order. For each step, say who decided that it would happen next: code in this project, the model, or a person. Then mark each step the model decided that has no turn limit, no limit on its tools, or no check on its result. Change no file.

[^anthropic-building-effective-agents]: Building effective agents, Anthropic.
[^claude-code-workflows]: Orchestrate subagents at scale with dynamic workflows, Claude Code, Anthropic.
[^anthropic-ccdv-f-exam-guide]: Claude Certified Developer - Foundations Exam Guide, version 1.1, Anthropic.
