Module 1 · Lesson 3
AI Agent vs Workflow: When Should You Use Each?
Use a workflow when you know the steps. Use an agent when the right sequence of steps must be discovered at runtime.
This is one of the most important design decisions in agentic software. LangGraph defines workflows as systems with predetermined code paths, while agents dynamically define their own process and tool usage. Anthropic's guidance similarly emphasizes matching architectural complexity to the problem rather than defaulting to autonomy.
What is a workflow?
A workflow is controlled by your application code. The model may be used inside individual steps, but the overall sequence is known.
classify_request()
if category == "billing":
lookup_invoice()
draft_billing_reply()
else:
retrieve_help_article()
draft_support_reply()This design can still use LLMs heavily. What makes it a workflow is that the control flow belongs to your code.
What is an agent?
In an agent, the model can decide which tool to call, whether another step is needed, and sometimes which specialist should handle the task.
while not done:
decision = model(context, tools)
if decision.tool_call:
result = execute(decision.tool_call)
context.append(result)
else:
done = TrueDecision table
| Question | Workflow | Agent |
|---|---|---|
| Are the steps known in advance? | Strong fit | Usually unnecessary |
| Does the task vary significantly each time? | Can become branch-heavy | Often useful |
| Are side effects risky? | Easier to constrain | Needs approvals/guardrails |
| Is deterministic testing important? | Easier | More complex |
| Does the system need open-ended tool selection? | Awkward | Natural fit |
| Is latency tightly constrained? | Usually better | May add multiple turns |
Start deterministic, add autonomy where it earns its cost
A strong production pattern is a hybrid architecture. Keep the outer business process deterministic and insert an agent only where flexible judgment adds value.
For example, a support system might use deterministic authentication and account lookup, then use an agent to investigate the customer's issue across several read-only tools, and finally require an explicit deterministic approval path for refunds or account changes.
Common workflow patterns
Anthropic highlights several useful workflow patterns including prompt chaining, routing, parallelization, orchestrator-worker designs and evaluator-optimizer loops. These patterns can solve surprisingly complex problems without giving a model unrestricted control of the whole application.
Routing
A classifier selects one of several known branches. This is useful when request categories are stable and each category has a clear handler.
Parallelization
Independent tasks run at the same time and their results are combined. This reduces latency when subtasks do not depend on one another.
Evaluator-optimizer
One model produces an answer and another pass evaluates or improves it. This is still a workflow if your code determines when the evaluation runs and what happens next.
Signs you really need an agent
- The task cannot be decomposed into a stable sequence beforehand.
- The model must inspect tool results before deciding the next action.
- The number of steps varies substantially per request.
- The tool selection space is broad and context-dependent.
- Users ask for goals rather than specific operations.
Signs you should stay with a workflow
- The process is regulated or transaction-heavy.
- The same steps happen almost every time.
- A wrong action is expensive or hard to reverse.
- You need predictable latency and cost.
- A small set of explicit branches solves the problem cleanly.
Do not equate “agent” with “better”
Agents trade predictability for flexibility. That can be valuable, but it is not free. Every autonomous decision increases the surface area you must observe, test and constrain.
A production-minded developer asks: which decisions genuinely benefit from model autonomy? Then only those decisions become agentic.