Workflows vs agents
In a workflow, you decide the steps: the order is written down before the run starts, and a model fills in text at fixed points. In an agent, the model decides the steps: it picks which tool to call next, and when it is done, from what it has seen so far. Use a workflow when you can draw the steps in advance, and an agent when the steps depend on what the run finds. Many real systems are a workflow with one or two agent steps inside it.
Two definitions
Anthropic's engineering guide "Building effective agents" draws the line by who controls the path. In a workflow, models and tools run through "predefined code paths". In an agent, the models "dynamically direct their own processes and tool usage". The guide calls both kinds "agentic systems" and draws "an important architectural distinction" between them: neither is better in general. A shorter definition from Simon Willison matches the loop: "An LLM agent runs tools in a loop to achieve a goal."
Picture both as a diagram. A workflow is a workflow DAGWorkflow DAG: A workflow drawn as a directed acyclic graph: steps joined by edges that never loop back, run in the order their inputs allow.: boxes joined by arrows that never point back, run in the order the arrows allow. Branches exist, but every branch was drawn by a person. An AI agentAI agent: A system in which a language model decides, step by step, which tools to call and in what order, reading each result before it chooses the next step, until it can answer. is a single box with a loop inside: call the model, run the tools it asked for, call the model again. That loop, the agent loopAgent loop: The cycle an AI agent repeats: call the model, run the tools it asks for, add the results to the conversation, then call the model again until it answers., has no fixed length and no fixed order. The model writes the path as it goes, choosing each tool callTool calling: A model's structured request to run one named tool with JSON arguments, instead of answering in text. The application runs the tool and returns the result. after reading the last result.
Two questions tell them apart on a real system:
- Could you list every step before the run starts? If yes, it is a workflow, even if a model writes the text in each step.
- Can the model call a different tool, or the same tool again, because of what it just read? If yes, that part is an agent.
Patterns in between
Between a single model call and a free-running agent sits a ladder of patterns. The same guide names five workflow patterns. Each one adds a little structure around model calls. In the first three, a person fixes the path in advance:
| Pattern | What it does | Fits when |
|---|---|---|
| Prompt chaining | Each model call works on the output of the one before | The task splits into fixed steps; the guide says it is "ideal for situations where the task can be easily and cleanly decomposed into fixed subtasks" |
| Routing | One step classifies the input; each class goes down its own path | There are "distinct categories that are better handled separately" and the classification is reliable |
| Parallelization | Several calls work on parts of the task, or on the same task, and the results are combined in code | Independent parts, or several opinions on one question |
| Orchestrator-workers | A central model splits the task and hands parts to worker models | You cannot know the subtasks before you see the input |
| Evaluator-optimizer | One call drafts, another critiques, and the draft is revised | There are "clear evaluation criteria" and revision measurably helps |
The last two are where control starts to move to the model. In orchestrator-workers, the orchestrator decides which subtasks exist, so the shape of the run changes with each input. An evaluator-optimizer loop runs until the evaluator is satisfied, so its length is decided at run time too.
A chain can also carry checks in code between its steps. The guide suggests such programmatic checks on intermediate results, shown as a "gate" in its diagram: a step that stops or reroutes the run when a result is not on track. A gate costs no model call and behaves the same way every time.
What you give up with an agent
Handing the path to the model buys flexibility. You pay for it in four places.
Cost. A workflow makes a known number of model calls. An agent makes as many as it decides to, up to its limit, and every call resends the conversation and the tool definitions. The guide is plain about it: "The autonomous nature of agents means higher costs, and the potential for compounding errors."
Latency. Each iteration waits for a full model reply before the next tool call can start. A three-step chain has three model calls; an agent answering the same question might take six.
Predictability. A wrong turn early in an agent run is carried into every later step, because each step builds on the last. A workflow fails at a known step, with a known input, which is easier to explain to the person who reported it.
Testability. You can test each step of a workflow alone and expect the same structure on every run. An agent may reach the right answer by different paths on different runs, so a test has to check the outcome, and often the tools called, over many inputs rather than one. The guide recommends "extensive testing in sandboxed environments, along with the appropriate guardrails."
None of this argues against agents. It argues for paying these costs only where the flexibility earns them.
A rule of thumb
Start from the simplest thing that could work, and move down this list only when the step above fails on real inputs:
- One model call, with good instructions and any context it needs (retrieval, examples).
- A fixed chain of calls, with checks in code between them.
- Routing: classify first, then run a fixed path per class.
- An agent for the part that needs it, with a short tool list and a low iteration limit.
- Several agents, such as a supervisorSupervisor agent: An agent whose tools include other agents: it splits a task, hands each part to a worker agent, and combines the answers into one reply. with workers, when one agent has too many jobs.
A quick test: write down the steps for ten real inputs. If most of them share one flowchart, build that flowchart as a workflow and send the odd ones to a person or to a fallback path. If the ten flowcharts all differ, because each depends on what a lookup returned, that is the job for an agent.
Mixing both: a DAG with an agent step
The choice is rarely all or nothing. A common design keeps the outer flow fixed and puts an agent only where the open-ended work is:
- Fixed edges around the agent. A trigger, input clean-up and output formatting stay as ordinary steps. They run the same way every time and are easy to test.
- Routing in front of the agent. A classifier and a branch send only the open-ended cases to the agent. Simple cases take a short, cheap path.
- Fixed procedures behind the agent. When the agent needs to do something that must always happen the same way, such as filing a refund request, give it that procedure as one tool. The agent decides whether and when to call it; the steps inside stay fixed.
- A person at the risky step. An approval gateApproval gate: A step that pauses a run until a person approves or rejects what happens next, such as a payment, an email or a write tool call. on the write path holds the run until someone decides, whatever the agent concluded.
This keeps the agent's freedom small and visible. The workflow around it limits what can happen; the agent decides only what to look up and how to answer.
Example: a support inbox
Messages arrive from a web form. Most are refund requests, some are bug reports, and the rest are product questions.
- Classify. One model call reads the message and answers with one word:
refund,bugorquestion. This is the only model call on two of the three paths. - Route. A switch sends each word down its own branch. Anything else, such as an empty or odd reply, goes to a default branch that puts the message in a human queue. Switch matches the text exactly, so ask the classifier for the exact lower-case word.
- Refunds follow a fixed procedure: look up the order, draft the reply from a template, then stop at an approval gate. A person approves or rejects every refund. No agent is needed: the steps are the same every time.
- Bug reports become an issue in the tracker through one HTTP request. Again, nothing to decide.
- Questions go to an agent with a documentation search tool and a limit of four iterations. Questions vary, the number of searches needed varies, and this is where an agent earns its cost.
If the questions later turn out to include "where is my order?", give the agent an order-status lookup as one more tool, built as its own small workflow, rather than turning the whole inbox into one agent with every tool.
The result costs one model call for most messages, keeps refunds under a person's control, and confines the unpredictable part to one branch, which you can test on its own.
Workflows and agents in L2M
In L2M, fixed steps and agents share one canvas. The workflow editor builds a graph of nodes; the engine runs them one at a time in an order their connections allow, and validation refuses a graph with a cycle. The core nodes cover the fixed parts:
- IF sends the run down its true or false branch from a condition template. Switch compares a value with a list of cases and takes the matching branch, or its default branch when none matches. Steps on the branch not taken are skipped.
- Merge / Join brings branches back together (append, combine by key, or choose one branch). Several branches with a model call each give you sectioning or voting; they run one after another, so they buy focus, not speed.
- Execute Workflow runs another workflow as a step, every time the run reaches it.
- Approval Gate pauses the run until a person approves or rejects.
Steps pass data on through templates: a prompt or field reads the step connected straight before it with {{field}}, and any earlier step with {{results.<nodeId>.field}} (templates and expressions).
The model-driven parts are the Agent Orchestrator and Supervisor Node. On the canvas an agent is one step in the graph, but it also has attachment ports: chat_model for its model, memory, tool for its tools, and on a supervisor worker for other agents. Nodes on a port are not steps; the agent uses them while its loop runs (attachment ports). Its maxIterations is required: a new Agent Orchestrator starts at 6, a new Supervisor Node at 10.
The Workflow Tool node is the bridge between the two. Attached to an agent's tool port, it turns another workflow into one tool: the agent decides when to call it, and the child workflow runs its fixed steps with the call's arguments as input (Workflow Tool). Unless the child declares itself read-only, it counts as a write tool, so optional write-tool approval asks before each call. That is how to build the order-status lookup from the example. Execute Workflow is the other half: the same child, run as a fixed step rather than offered as a choice.
The pattern library has runnable samples of these shapes, including conditional branching from a webhook and a supervisor with workers. To serve a fixed workflow to MCP clients outside L2M, see the workflow as an MCP tool recipe.
In the live demo, the conditional branching sample is a small fixed workflow: a webhook, one LLM Call, then an IF node that checks the answer is not empty and picks Success Output or Error Output.
See also: regression testing for AI agents shows how to catch a change that breaks an agent step, by saving known-good runs and replaying changes against them.
Further reading
- Building effective agents (Anthropic engineering, December 2024): workflows and agents, the five workflow patterns, and when each fits
- Agent definition (Simon Willison, September 2025): "tools in a loop" as a working definition
- In L2M: Workflow editor, Workflow Tool, Templates and expressions, Pattern library