27.1 Workflow or agent
- Approved by
- Panaversity ·
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). 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.
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".1 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).2 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".3 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".3 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'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), 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_policyand 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."1 They also say what the flexible side costs: "The autonomous nature of agents means higher costs, and the potential for compounding errors."1 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.
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.
Check yourself
Question 1 / 8
0 answered
Anthropic's engineers define a workflow and an agent. In a workflow, what holds the plan?
Sources
- Owner
- Panaversity