Choose a workflow when you can write down the steps before you see the input, and an agent when the steps depend on what is discovered along the way. A workflow is a fixed sequence of model calls in your code; an agent lets the model pick the next step in a loop. Most tasks that get built as agents would work as workflows, at lower cost and with fewer surprises.
Key takeaways
- The difference is control flow: in a workflow your code decides the next step, in an agent the model does.
- Anthropic's guidance is to find the simplest solution possible and add complexity only when it demonstrably helps.
- Five workflow patterns cover most needs: prompt chaining, routing, parallelisation, orchestrator-workers and evaluator-optimiser.
- An agent earns its place when the number of steps is unpredictable, the environment gives feedback, and mistakes can be undone.
- You can mix both: a workflow with one agentic step is often the best design.
This article is part of the guide to AI agents, which covers the agent loop itself.
What is the difference between a workflow and an agent?
Anthropic's engineering article "Building effective agents" gives the definitions most teams now use. Workflows are systems where LLMs and tools are orchestrated through predefined code paths. Agents are systems where LLMs dynamically direct their own processes and tool usage, keeping control over how they accomplish tasks. Both are "agentic systems".
The article dates from December 2024, and the page now carries a note that tooling has changed since. The design advice has not: start simple.
| Workflow | Agent | |
|---|---|---|
| Who chooses the next step | Your code | The model |
| Number of model calls | Known in advance | Varies per task |
| Cost per task | Predictable | Variable, often higher |
| Testing | Test each step on its own | Test whole tasks, many times |
| Failure style | A step returns a bad output | Errors compound across steps |
| Best for | Well-defined, repeatable tasks | Open-ended tasks with feedback |
What are the common workflow patterns?
Anthropic describes five. Each one is ordinary code with model calls in it.
| Pattern | What it does | Use it when |
|---|---|---|
| Prompt chaining | Splits a task into steps; each call works on the previous output | The task divides cleanly into fixed subtasks, and you accept more latency for better accuracy |
| Routing | Classifies the input, then sends it to a specialised prompt | Inputs fall into distinct categories that are better handled separately |
| Parallelisation | Runs independent subtasks at once, or the same task several times and votes | You want speed, or several independent opinions |
| Orchestrator-workers | One model call splits the task; others do the parts; a final call combines them | You cannot predict the subtasks in advance, but one round of splitting is enough |
| Evaluator-optimiser | One call writes, another critiques, and the loop repeats | You have clear quality criteria and revision measurably improves the result |
Orchestrator-workers sits close to the border. The model decides the subtasks, but your code still controls the overall shape. The multi-agent systems article covers what happens when the workers become full agents.
What does a workflow look like in code?
Here is routing followed by a chain, for support tickets. There is no loop and no tool calling. The model is asked two narrow questions, and plain Python decides what happens between them.
import anthropic
client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY from the environment
MODEL = "claude-opus-5-5" # use any current model ID from the models page
DRAFT_PROMPTS = {
"billing": "Draft a reply to this billing question. Quote no amounts "
"that are not in the ticket.\n\nTicket:\n",
"technical": "Draft a reply to this technical question. List the steps "
"to try, most likely fix first.\n\nTicket:\n",
}
def ask(prompt: str) -> str:
response = client.messages.create(
model=MODEL,
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return "".join(b.text for b in response.content if b.type == "text")
def handle_ticket(ticket: str) -> str:
# Step 1: route.
category = ask(
"Classify this support ticket. Reply with exactly one word: "
"billing, technical or other.\n\nTicket:\n" + ticket
).strip().lower()
# A gate in code, not in a prompt.
if category not in DRAFT_PROMPTS:
return "ESCALATE_TO_HUMAN"
# Step 2: draft with the specialised prompt.
return ask(DRAFT_PROMPTS[category] + ticket)
Every ticket costs at most two model calls. You can test the classifier alone against a labelled set of tickets, and each draft prompt alone against examples. When something goes wrong, you know which step to look at.
An agent version of this would be given tools such as search_docs, lookup_invoice and send_reply and told to resolve the ticket. It could handle a ticket that needs three lookups. It could also take twelve steps on a ticket that needed one.
How do you choose? A decision rule
Work down this list and stop at the first "yes".
- Can one model call do it, given the right context and a few examples? Use one call. Anthropic notes this is usually enough for many applications.
- Can you list the steps before seeing the input? Use prompt chaining.
- Do inputs fall into a few known types? Add routing. Are parts independent? Run them in parallel.
- Do you have a clear test for "good", and does revision help? Use evaluator-optimiser.
- Are the subtasks unknown, but one round of planning is enough? Use orchestrator-workers.
- Is the number of steps itself unpredictable? Now consider an agent, and only if the next three conditions also hold.
The three conditions for an agent:
- Feedback exists. The agent can see whether a step worked: a test passes, an API returns an error, a search returns results. Without feedback, it is guessing in a loop.
- Mistakes are recoverable. Either actions can be undone, or a human approves the ones that cannot.
- Variable cost is acceptable. You have a step limit and a budget, and the value of a completed task covers the expensive runs.
If any of the three fails, go back up the list.
What does an agent cost that a workflow does not?
Anthropic's guide states the trade directly: the autonomous nature of agents means higher costs and the potential for compounding errors.
In practice that shows up in four places:
- Tokens. Each loop turn re-sends the growing conversation. Anthropic reported in 2025 that agents in its own data typically used about 4 times the tokens of a chat interaction.
- Latency. Ten sequential model calls take ten times as long as one, before tool time.
- Testing. The same input can produce different paths. You need whole-task tests run repeatedly, not unit tests of single prompts. See LLM evaluation in CI.
- Safety work. An agent needs permissions, approvals and stop conditions that a two-step workflow does not. See guardrails for AI agents.
None of this means agents are a bad choice. It means the extra capability has a price, and you should be able to say what you are buying.
Can you combine workflows and agents?
Yes, and it is often the best answer. Two combinations are common:
- An agentic step inside a workflow. The pipeline is fixed: classify, investigate, draft, review. Only the "investigate" step is an agent with search tools and a step limit. The risk is contained to one stage.
- A workflow as a tool. An agent has a tool called
generate_report, and behind it is a fixed five-step chain. The agent decides when to produce a report; your code decides how.
Both keep the unpredictable part as small as it can be.
When should you move from a workflow to an agent?
Move when you have evidence, not a feeling. Good evidence looks like this:
- Your routing step keeps growing new categories, and inputs still fall between them.
- You are writing code to handle "if the first search finds nothing, try another query", and then a third variant.
- Failure analysis shows the workflow had the right tools but the wrong fixed order for a real share of inputs.
Poor evidence is "agents are the current approach" or "the workflow has many steps". A long workflow is still predictable.
Common questions
Is a workflow just prompt engineering?
No. A workflow is code that makes several model calls and decides what to do between them. Each call has its own prompt, but the structure, the gates and the error handling are ordinary software.
Are agents more accurate than workflows?
Not in general. On open-ended tasks an agent can reach answers a fixed path would miss. On well-defined tasks, Anthropic's guide says workflows offer predictability and consistency, and extra autonomy adds ways to go wrong.
Does using tools make something an agent?
No. A workflow can call tools too, for example a fixed "search, then summarise" chain. It becomes an agent when the model decides which tool to call next and when to stop.
Do I need a framework for either?
Not to begin. Anthropic's guide suggests starting with LLM APIs directly, and understanding the underlying code if you later adopt a framework. The workflow above needs nothing beyond the SDK.
Free download: The AI agents field guide
What an agent is, when a simple workflow is the better choice, how MCP connects tools, when several agents help, and the guardrails every agent needs, with working Python. See what’s inside.



