Learn · Module 10 · Agents · Lesson 2 of 6
Workflows or agents?
Most problems don't need an agent. A fixed sequence of steps is cheaper, faster and easier to trust.
- Workflows follow steps you define; agents choose steps at run time.
- If you can draw it as a flowchart, use a workflow.
- Common patterns: chain, router, parallel, evaluate and retry.
In plain words
A workflow is a sequence of steps that you define in code, with model calls at some of them: classify the email, then pick a template, then fill it in. An agent decides its own steps at run time.
The rule of thumb: if you can draw the steps as a flowchart in advance, build a workflow. Use an agent only when the path genuinely depends on what's discovered along the way.
Worked example: two support tasks
| workflow | agent | |
|---|---|---|
| Steps decided by | your code | the model, as it goes |
| Predictability | high: same path every time | lower: path varies |
| Cost and speed | fixed and low | varies, often higher |
| Testing | test each step on its own | test whole runs |
| Best for | known processes | open-ended tasks |
- 1Task A: tag and route incoming tickets
Always the same: classify the ticket, look up the team, assign. A workflow with one model call for classification.
classify → lookup → assign
- 2Task B: investigate why a customer was charged twice
The steps depend on what's found: check payments, then maybe refunds, then maybe a bug report. An agent with read-only tools fits.
?
Common workflow patterns
| pattern | what it does |
|---|---|
| Chain | Step 1's output feeds step 2, and so on. |
| Router | Classify first, then send to a specialised prompt or model. |
| Parallel | Run several calls at once (for example, check five rules) and combine. |
| Evaluate and retry | One call drafts, another checks, redo if it fails. |
You need to extract fields from invoices, validate them, and save them. Which is a better fit?
What to remember
Start with the simplest thing that works: one well-designed call, then a workflow, and only then an agent. Many 'agent' products in production are mostly workflows, with an agent used for one open-ended step.
Common mistakes
- Starting with an agent because it sounds more advanced, when a fixed workflow would be more reliable.
- Giving an agent a task whose steps are always the same.
- Not measuring whether the agent actually beats a simpler workflow.
Answer in your own words, out loud or on paper, before you open the model answer.
When would you use an agent instead of a fixed workflow?
I'd start with a fixed workflow whenever the steps are known in advance, like classify, then retrieve, then answer, because it's more predictable, cheaper, faster and easier to test. I'd use an agent when the path genuinely depends on what's discovered along the way, so the number and order of steps can't be written down ahead of time, for example researching a question across several sources, or fixing a failing test where each step depends on the last error. Even then, I'd constrain it: a small set of tools, step and budget limits, and checkpoints. I'd also keep the workflow as a baseline and only switch if the evaluation shows a clear improvement.
- Describe a router pattern and when it helps.
- How would you design a system to triage support tickets?
Go further
- ArticleBuilding effective agentsAnthropic
- DocsA practical guide to building agentsOpenAI