Skip to content

Lesson 2 of 6 · 4 min read

Workflows and Agents

Free lessonReviewed By the AIAgentInterviews editorial team
Reading position
In this lesson

TL;DR: Ask who decides the next step. If code can decide it, because you can write the steps down before the input arrives, build a workflow: it is cheaper, faster, repeatable and testable. Use an agent where the path depends on what is discovered along the way, and fence that agentic step inside a deterministic spine with its own budget.

After this lesson, you should be able to place a design on the spectrum from a single model call to a full agent, defend the choice with cost and variance arithmetic, and recognise from traces when an agent should be frozen into a workflow or a workflow has grown an agent-shaped hole.

Before you read

Commit to an answer now. The lesson that follows explains it, and having guessed first, even wrongly, makes the explanation easier to remember.

  1. 1Across 500 production runs, an invoice-intake agent calls extract, validate_vendor, match_po and create_bill in exactly that order every time. What does that tell you?

An agent that is really a workflow

An accounts-payable team ships an "invoice agent". It has four tools and a good prompt, and it works. Six weeks later someone reads the traces. In 500 runs the model called the same four tools in the same order 493 times. In the other seven it skipped validate_vendor, and two of those seven paid an invoice from a vendor whose bank details had changed the day before.

Nothing about those seven invoices called for a different path. The model was free to choose, so occasionally it chose differently. The team was paying for six model turns per invoice to rediscover a sequence they could have written in four lines, and the freedom they paid for was the cause of the incident.

The question that decides it

Ask one thing about each step: who decides what happens next?

In a workflow, code decides. The model may do a step (extract fields from a PDF, classify a ticket, draft a reply) but the sequence, the branching and the exits are written down. In an agent, the model decides: it picks the next tool, the arguments, and when it is done, inside a loop the harness runs.

Between the two sits a spectrum, and most good systems live somewhere in the middle of it. Anthropic's "Building effective agents" (December 2024) gave the common points names that have stuck:

PatternWho picks the next stepTypical use
Single model callNobody: one stepClassify, extract, summarise
Prompt chainCode, fixed orderOutline, then draft, then check
RouterA model picks one branch; code runs itSend a ticket to billing or shipping
Parallel fan-outCode splits, runs, mergesScore a document on five criteria at once
Evaluator and optimiserCode alternates a generator and a criticRevise a translation until a checker passes
Orchestrator and workersA model splits the task at run timeResearch across sources not known in advance
AgentThe model, every turnDebugging, open-ended support, coding

Read the table as a dial. Each step down hands more decisions to the model.

SAME TASK, TWO DESIGNS
Refund request: who decides each step

Workflow with one agentic step

Verify customer

code

Fetch order

code

Investigate dispute

agent, read-only, 8 steps max

Policy check

code

Limits enforced

Refund

code, idempotent

Outcome, safe: Agency only where the path is unknown

Agent with every tool

Model picks a tool

Any of 9 tools

Order of steps varies

Model picks again

Refund tool

Reachable before the check

Outcome, unsafe: Every run is a new path to test

What agency costs

Agency is not free, and the costs compound.

Tokens and latency. Every decision the model makes is a model turn, and each turn rereads the growing transcript (see The Agent Loop). A workflow that calls the model twice for extraction and drafting can replace an agent that takes eight turns to reach the same tools.

Variance. Each model-made choice is a chance to choose wrongly. The arithmetic is unforgiving:

per-decision chance of picking the right next step   p = 0.98   (illustrative)
decisions in a run                                   n = 6
chance the whole path is right                       0.98^6 = 0.886
across 10,000 runs                                   ~1,140 runs take a wrong turn
the same six steps as code                           0 wrong turns from step choice

Most wrong turns are recovered, because the model notices and corrects. Some are not, and those are the incidents.

Test surface. A workflow has paths you can enumerate and test one by one. An agent's paths are generated at run time, so you test it statistically, across many runs (see Agent Evals & Observability), and you never quite finish.

What agency buys

Agency earns its cost when the next step depends on what was just found. A support issue that might be a billing error, a shipping delay or a fraud flag, where the evidence decides which; a bug whose cause is three files away from the symptom; a research question whose sources are not known in advance. Writing those as workflows produces an ever-growing tree of if statements that still misses the case nobody imagined. That tree is the signal: a workflow that keeps growing exception branches has an agent-shaped hole in it.

The design most strong candidates land on

Keep a deterministic spine and put agency in a fenced step. In the refund example above, code verifies the customer, fetches the order, runs the policy check and executes the refund. The agent gets the one step that is open-ended (investigating what went wrong) with read-only tools, a step budget, and a structured output the spine validates before anything else happens.

Two habits keep the boundary honest over time. Read the traces of the agentic step: if 90% of runs take the same path, freeze that path into code and leave the agent for the remainder. And when a model upgrade arrives, re-test whether each fenced step still needs the fence, because the cheapest scaffolding to maintain is the scaffolding you delete.

Say it in 30 seconds

"I ask who decides the next step. If I can write the steps before the input arrives, code decides: a chain, a router or a fan-out, which is cheaper, faster and testable. If the path depends on what gets discovered, the model decides, inside a loop with budgets. Usually I build a deterministic spine with one bounded agentic step, because every decision handed to the model is a chance to choose wrong: six decisions at 98% each come out right only 89% of the time."

Check yourself

Answer aloud or on paper before revealing. Producing the explanation unaided is exactly what a panel listens for.

  1. 1A product manager wants 'an agent' to send a weekly status email built from three dashboards. Which design and why?

  2. 2Your support workflow has grown 40 exception branches and still misroutes unusual tickets. What do you change?

  3. 3Each of five model-made decisions is right 95% of the time. What fraction of runs get every decision right, and what does that suggest?

Practise it as an interviewer asks it

Course lessons that teach this

Related lessons