Workflows Versus Agents: A Decision Guide
Place a design between code-defined workflows and agents that choose their own steps, compare them on predictability, latency and cost, and use a simple decision guide to pick one for a given task.
Contentsand lesson path
On this page
- The Spectrum of Autonomy: Workflows Versus Autonomous Agents
- Categorizing Architectural Patterns Along the Autonomy Continuum
- The Decision Matrix: Choosing Between Workflows and Agents
- Practice questions
- Apply it
- Review prompt
Lessons of Workflow & Planning Patterns
- Workflows Versus Agents: A Decision Guide Concept · 15 min
- Chaining, Routing and Parallel Calls Worked example · 25 min
- Lab: Plan, Execute, Replan Lab · 25 min
- Reflection Loops That Actually Help Worked example · 20 min
- Measuring a Pattern Against a Baseline Lab · 20 min
- Check: Pick the Pattern Knowledge check · 8 questions
What you will learn
- Decide between a fixed workflow and an autonomous agent for a task and justify the choice with reliability, latency and cost.
Prerequisites: Agent Loops & ReAct
01. The Spectrum of Autonomy: Workflows Versus Autonomous Agents
When you add a large language model (LLM) to a product, an early choice is whether to build a workflow, whose control flow is fixed in code even though its LLM steps can give different outputs, or an agent, which chooses its own steps. The word "agent" is often used for any application that calls an LLM. In this lesson the two words have narrower meanings: workflows and agents sit at the two ends of a scale of autonomy, that is, of how much the model decides about the steps.
A Workflow runs along code-defined paths: the possible steps, branches and loops, and their exit conditions, are written by developers. LLMs work inside those paths, summarising text, extracting entities, classifying intents or translating schemas. An LLM may still pick a branch (routing) or decide whether a draft passes and leaves a review loop (evaluator-optimizer), but it can only choose among paths the code already defines; it cannot invent a new step.
An autonomous agent, by contrast, is a loop in which the model controls its own path. Given a goal, it decides on each turn which tool to call, reads what the tool returns, keeps track of its plan, and decides when the task is finished.
Agents adapt better to open-ended, ill-defined problems, but they are less predictable: the number of steps, the token cost, the latency and the ways a run can fail all vary from one run to the next. Workflows are easier to predict: each path has a known maximum number of model calls, so time and cost per request can be budgeted, and each step can be unit-tested on its own.
02. Categorizing Architectural Patterns Along the Autonomy Continuum
In the article "Building effective agents" (December 2024), Anthropic describes five workflow patterns, starting from a single LLM call augmented with retrieval, tools and memory and moving towards more complex designs:
-
Prompt chaining. The simplest pattern: a task is split into a fixed sequence of LLM calls. The output of step 1 goes into the prompt of step 2, with optional checks in code (gates) between steps that stop the chain when an intermediate result is off track.
-
Routing. A classifier step sends each input to a specialised prompt chain or tool set based on its intent, for example billing questions to an invoice parser and bug reports to the engineering tracker.
-
Parallelization. Independent subtasks run at the same time. Two forms are sectioning (parallel prompts on different parts of a large document) and voting (several answers to the same task, compared to reach a consensus or to filter out outliers).
-
Orchestrator-workers. A central model breaks a problem into subtasks while it runs, hands them to worker models, and combines their outputs into one answer.
-
Evaluator-optimizer. One model writes a draft and another critiques it, in a loop that ends when the draft meets the criteria.
Beyond these five patterns are autonomous agents, where the model directs its own tool use until it decides it is done or a stopping condition (a step, time or cost limit) ends the run.
from typing import Any, Dict, Literal
# Workflow router: explicit code paths; only the last branch runs an agent loop
def execute_customer_request(
intent: Literal["refund", "status", "complex_investigation"],
payload: Dict[str, Any],
) -> Dict[str, Any]:
if intent == "refund":
# Fixed chain: extract order -> validate policy -> issue refund
return execute_refund_workflow(payload)
elif intent == "status":
# Fast direct database lookup
return execute_status_workflow(payload)
else:
# Open-ended investigation requiring dynamic reasoning and tool loop
return run_autonomous_investigation_agent(payload)03. The Decision Matrix: Choosing Between Workflows and Agents
Four questions help you choose between the two:
-
Path predictability. Can the solution steps be drawn as a flowchart? If most requests follow known branches (such as KYC identity verification or invoice ingestion), use a workflow. If the sequence of tools depends on what earlier tools return (such as open-ended software debugging or competitive market research), an agent may fit better.
-
Latency sensitivity. A workflow makes a known maximum number of model calls, so you can measure its worst-case latency in advance. An agent makes as many round trips as the task seems to need, so its latency varies from run to run. Interactive user interfaces usually favour workflows, whereas background job queues can tolerate agent latencies. Measure both on your own tasks before you decide.
-
Cost and token budget. A workflow sends a bounded set of prompts per request. An agent loop sends the growing conversation history on every turn, so total input tokens grow faster than the number of turns. Prompt caching lowers the price of the repeated prefix but not the number of tokens sent; compaction is what reduces the count. For high-volume, low-margin operations, that difference often decides the design.
-
Error recovery. When a step fails in a workflow, the retry policy, fallback endpoint or human escalation queue for that step is written in code and easy to test. In an agent, an unexpected tool error can send the model into repeated failing calls, so you need step limits and loop detection.
In short, keep a bias towards simplicity: build with workflows by default, improve prompts and routing rules first, and use an agent loop where the steps cannot be known in advance and that flexibility is worth the extra cost and variance.
04. Practice questions
05. Apply it
Use these rules when you design a feature that calls an LLM:
- Start by mapping the problem to a prompt chain or a router; move to an agent loop only if the steps cannot be decided in advance.
- Use a workflow for the standard steps (for example fetching data, authentication, formatting), and hand only the open-ended analysis to an agent.
- Measure the cost per request of both designs on the same tasks. If the agent costs many times more, check that its results are worth the difference.
- Cap the iterations of every evaluator-optimizer or agent loop in code (for example at three rounds), so a loop that does not converge ends instead of spending without limit.
- Record why you chose an agent over a workflow in an architecture decision record (ADR), so the extra operational complexity has a stated reason.
- Track latency and cost distributions per pattern in production, and check them after every prompt or model change.
06. Review prompt
Contrast the operational characteristics of an LLM workflow with an autonomous agent across predictability, latency, cost, and error handling. Summarise the five workflow patterns from Anthropic's "Building effective agents", and explain why the lesson recommends starting with a workflow and using an agent only when the steps cannot be known in advance.
References
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.