Workflows vs agents: how to decide
In a workflow, you decide the steps in code, and the LLM does specific jobs inside them: classify, extract, write, check. In an agent, the LLM decides the steps itself, choosing tools in a loop until the task is done. Workflows are predictable, cheaper, faster and easier to test, so they should be your default. Use an agent when the path to the goal genuinely can't be known in advance, and even then, keep it inside a workflow with limits, checks and approvals.
Two kinds of agentic systems
Anthropic's guide Building Effective Agents draws a useful line between two kinds of systems that use LLMs with tools.
Workflows are systems where LLMs and tools are orchestrated through predefined code paths. You write the sequence: first classify, then retrieve, then generate, then check.
Agents are systems where the LLM dynamically directs its own process and tool usage, deciding what to do next based on what it has seen so far.
Both are useful, and many people call both "agents", which causes confusion. The question that separates them is simple: who decides the next step, your code or the model?
Workflow patterns
Most production LLM features are workflows built from a few patterns.
Prompt chaining
Break a task into a sequence of steps, each a separate model call with one job, where each output feeds the next. For example: extract the facts from a document, then write a summary from the facts, then translate it. You can add checks between steps, like validating the extracted facts before writing.
Routing
Classify the input first, then send it to the right specialised path. A support system routes refund requests, technical issues and sales questions to different prompts, tools or teams. Routing is also how you control cost: simple questions go to a small model or a cached answer, and only complex ones go to a large model.
Parallelisation
Run several model calls at the same time and combine the results. Either split a task into independent parts (check a contract for each of ten risk types in parallel), or run the same task several times and vote, to improve reliability.
Orchestrator and workers
A central model breaks a task into sub-tasks, sends them to worker calls, and combines their results. The sub-tasks aren't fixed in advance, which makes this a step toward an agent.
Evaluator and optimiser
One call generates an output, another evaluates it against criteria and gives feedback, and the first improves it, in a loop with a limit. Useful for writing, translation and code where you can describe what "good" looks like.
When an agent is worth it
An agent adds flexibility, and it costs predictability. It is worth it when:
- The number and order of steps depend on what the agent discovers, like investigating a bug or researching a question.
- The inputs are too varied for fixed paths.
- The task needs many tools, and which ones are needed changes per case.
- Mistakes can be caught, either by tests (as in coding), by checks, or by a person approving actions.
It is not worth it when:
- The steps are the same every time.
- A wrong action is expensive and hard to undo.
- Speed and cost per request matter a lot.
- You need to explain exactly why the system did what it did, every time.
Comparison
| Workflow | Agent | |
|---|---|---|
| Who decides the steps | Your code | The model |
| Predictability | High | Lower |
| Latency and cost | Lower, fixed | Higher, variable |
| Testing | Test each step | Test outcomes and trajectories |
| Handles unexpected cases | Only those you coded | Often, sometimes badly |
| Debugging | Follow the code path | Read the trace of decisions |
| Best for | Repeated processes with known steps | Open-ended tasks with variable steps |
Combine them
The best systems usually combine both. A workflow handles the overall process and the risky steps, and an agent handles the one part that needs flexibility.
A customer support system might be a workflow that authenticates the user, routes the request, and for complicated billing issues, hands off to an agent with read-only tools to investigate, whose proposed fix then goes through a fixed approval step before anything changes.
A way to decide
- Write down the steps a person would take to do this task.
- If the steps are the same every time, build a script or workflow.
- If only some steps vary, make those steps LLM calls inside a workflow.
- If the sequence itself varies, consider an agent for that part, with tools, limits and checks.
- Measure: build the simplest version, evaluate it, and add agency only where the evaluation shows it's needed.
From the floor
When we built the DevFix agent in AI Engineer HQ, a command line agent that writes code, runs it, checks the errors and fixes them until the tests pass, I started by separating the two types of agentic systems, workflows and agents, using Anthropic's diagram. We set workflows like routing and parallelisation aside for that build and focused on the agent, and the fix-and-retest loop is a good fit for one, because the number of steps depends on what goes wrong.
In the agentic workflow session, a builder asked whether an agent is a kind of workflow, using the example of booking a trip: flights first, then hotels, then everything else. My answer was yes, an agent reasons about the order of steps the way we plan a trip. And when the steps always happen in the same order, that is the signal to build a workflow instead.