Back to the map

Module 10 · The agent loop · Lesson 2 of 5

Workflows versus agents

Workflows run models through code paths fixed in advance; agents let the model direct its own process: five decision rules, the hybrid with one agentic step, and why you add autonomy only when an eval shows the fixed path failing.

CoreMust-knowJunior 12 minPro Updated Nov 2026

Why it matters

Most LLM systems that fail in production were built as agents when a workflow would have done, or as workflows when the task needed the model to choose. The distinction Anthropic set out in its guide to building effective agents has become the shared vocabulary: workflows orchestrate models and tools through predefined code paths; agents let the model direct its own process and tool use. Interviewers use it as a design question with a right answer per task, and they listen for whether you start simple and add autonomy only when measurement says you need it.

The idea

Two ways to decide the path

In a workflow, your code knows the steps before the request arrives. It may call the model five times, chain prompts, route to one of several branches, fan out in parallel, or run a draft past an evaluator; but the control flow lives in code, and a reader can draw it before running it. The model fills in boxes. In an agent, the control flow lives in the model. Your code provides tools and a loop, and on each lap the model reads what has happened and chooses what happens next. The path exists only after the run, in the trace.

The two are not grades of quality but different allocations of one decision: who picks the next step, the engineer at design time or the model at run time.

workflow: path fixed in codeExtractValidatePostagent: model draws the pathModel picks nextsearchreadfixresult returns, model picks againpredictability: highcost: fixed per runpredictability: lowercost: open-ended
A workflow's path is drawn in code before the request arrives; an agent's path is drawn by the model, one step at a time, as results come back.

Start with the simplest thing

The rule to repeat is: begin with a single call, move to a workflow when one call cannot do the task, and move to an agent only when the workflow's fixed steps measurably fail. Each move buys capability at the price of predictability, cost and debuggability; make the trade with an eval in hand, not on instinct. Many teams reach for the loop first because it demos well; the demo hides that the same task runs three times slower and ten times dearer than the workflow they never tried.

The decision rules

Five questions settle most cases. Are the steps known in advance? If you can list them, write them as code. How much predictability do you need? Regulated outputs, batch jobs and anything with an SLA want the fixed path. What are the cost and latency ceilings? An agent's lap count is open-ended; if the budget is two calls and 800 milliseconds, the loop does not fit. How much do you trust the model's decisions on this task? Trust comes from evals, not hope; a model that picks the wrong tool one time in ten is wrong somewhere on most ten-lap runs. How bad is a wrong step? Reading the wrong document costs a lap; sending the wrong email costs a customer. The worse the wrong step, the more you want it in code or behind a human gate.

The middle ground

The usual answer in a design review is a hybrid: a fixed workflow with one agentic step. Extract, validate and file an expense claim as code, but let a bounded loop with a search tool resolve the one line item the parser could not classify, capped at four laps. Or run an agent for the investigation and hand its findings to a fixed path for the action. The hybrid keeps the predictable parts predictable and spends autonomy only where the steps are genuinely unknown.

 WorkflowAgentHybrid
PredictabilitySame steps every runPath differs run to runFixed outside the agentic step, bounded inside it
CostKnown number of callsOpen-ended; grows with lapsKnown plus a capped loop
LatencySum of fixed stepsLap count times a round tripFixed steps plus a bounded loop
DebuggabilityRead the codeRead the trace, run by runCode for the shape, trace for the step
FitSteps known; outputs must repeatSteps unknown until evidence arrivesMost products: one unknown step in a known path

Saying it with examples

Invoice extraction is a workflow: the steps are the same for every invoice (read the document, extract fields, validate totals, post to the ledger), the output must be predictable, and a wrong step costs money. Incident investigation is an agent: nobody knows in advance whether the next step is a log query, a deploy diff or a dashboard, the evidence from one step decides the next, and a wrong step costs a few seconds of reading. Customer support sits between: route and answer common questions as a workflow, and let an agent loop only for the tickets the router marks as needing investigation.

Workflows versus agents · Backplane