Agent Workflows vs Autonomous Agents: The Five Patterns You Actually Ship
Most "agents" in production are workflows: model calls arranged in code-defined paths. Learn the five patterns — chaining, routing, parallelization, orchestrator-workers, evaluator-optimizer — and when to hand control to a real loop.
After this lesson you can
- ✓Explain the difference between a workflow and an agent in one sentence an interviewer will accept
- ✓Pick the right pattern for a task and justify it with cost, latency and reliability arguments
- ✓Implement a routing workflow with the Gemini, Claude and OpenAI SDKs
The distinction that matters
A workflow is a system where the LLM and tools are orchestrated through code paths you wrote. You decide the sequence; the model fills in the steps. An agent is a system where the model decides its own sequence — which tool to call next, when to stop — inside a loop you control only at the edges (budget, permissions, termination).
This is not a purity test. The industry converged on the same advice from every major lab: start with a single, well-prompted call; move to a workflow when you need predictability across several steps; reach for an autonomous loop only when the number of steps is genuinely unknown ahead of time. Workflows are cheaper, easier to test, and fail in ways you can reproduce. Agents buy flexibility at the price of variance.
The five patterns below are the vocabulary every provider now uses — Anthropic’s "Building effective agents", Google’s ADK workflow agents, and OpenAI’s Agents SDK guide all describe essentially the same shapes. Learn them once and you can read any framework’s docs.
Pattern 1 — Prompt chaining
Break a task into a fixed sequence where each call’s output is the next call’s input, with optional programmatic checks ("gates") between steps. Draft → critique → rewrite. Extract → validate schema → summarise. You trade latency (more calls) for accuracy (each call has one job).
Use it when the task decomposes cleanly and you want each stage independently testable. The gate between steps is where you put deterministic checks — a JSON schema validation, a length limit, a profanity filter — so the model never has to be trusted to police itself.
Pattern 2 — Routing
Classify the input, then send it to a specialised prompt, model, or tool set. Customer-support triage (billing vs technical vs refund), model routing (cheap model for easy questions, frontier model for hard ones), language routing. The classifier is usually a small, fast, cheap model constrained to output one of N labels.
Routing is the highest-leverage pattern for cost. A router that sends 70% of traffic to a model ten times cheaper pays for itself on day one, and it isolates prompts so improving the billing prompt cannot regress the technical one.
from anthropic import Anthropic
client = Anthropic() # reads ANTHROPIC_API_KEY
ROUTES = {
"billing": "You are a billing specialist. Be precise about amounts and dates.",
"technical": "You are a senior support engineer. Ask for logs before guessing.",
"other": "You are a friendly generalist. Keep it short.",
}
def classify(message: str) -> str:
resp = client.messages.create(
model="claude-haiku-4-5", # small + fast for the router
max_tokens=5,
temperature=0,
system="Classify the ticket as one of: billing, technical, other. "
"Reply with exactly one lowercase word.",
messages=[{"role": "user", "content": message}],
)
label = resp.content[0].text.strip().lower()
return label if label in ROUTES else "other"
def answer(message: str) -> str:
route = classify(message)
resp = client.messages.create(
model="claude-sonnet-4-5", # bigger model for the actual answer
max_tokens=800,
system=ROUTES[route],
messages=[{"role": "user", "content": message}],
)
return resp.content[0].textPattern 3 — Parallelization
Run independent calls at the same time and merge. Two flavours: sectioning (split the work — summarise each chapter, then combine) and voting (run the same prompt N times, take the majority or the strictest verdict). Voting is how you get reliability from a stochastic component — three cheap judges disagreeing is a signal in itself.
The engineering cost is in the merge step and in error handling: one slow or failed branch must not sink the request. Use asyncio.gather with return_exceptions=True (Python) or Promise.allSettled (TypeScript), set a per-branch timeout, and decide up front whether a partial result is acceptable.
Pattern 4 — Orchestrator-workers
A central model breaks the task into subtasks it did not know in advance, delegates each to a worker, then synthesises. Unlike parallelization, the fan-out is decided at runtime by the model. Coding agents that touch several files, research agents that spawn a search per sub-question, and data agents that query several systems all use this shape.
This is the bridge between workflows and agents. The orchestrator is agentic (it decides the subtasks); the workers are usually plain workflows with a tight brief. Lesson 3 covers this pattern in depth, including the handoff and supervisor variants.
Pattern 5 — Evaluator-optimizer
One call produces, a second call grades against explicit criteria, and the loop repeats until the grade passes or a budget is spent. Translation with a native-speaker critic, code with a test-runner critic, marketing copy with a brand-guideline critic. It works when you can write evaluation criteria clearly and when the model’s critique is measurably better than its first draft — check both before adopting it.
Always cap the iterations. An evaluator that never says "good enough" is the classic way to burn a budget, and it is the first follow-up question an interviewer asks about this pattern.
- •Cap iterations (2–3 is typical) and log the grade at every step
- •Separate the evaluator’s prompt from the generator’s — never let one model grade its own output in the same context
- •Prefer deterministic evaluators (tests, schema checks, linters) over LLM judges wherever one exists
When to build a real agent
Reach for an autonomous loop when the task is open-ended, when the number of steps cannot be predicted, and when you have a way for the model to get ground truth from the environment (test results, tool errors, a human). Without feedback from the environment, an agent is just a workflow with worse observability.
Even then, the agent should be a thin loop: send messages, execute tool calls, append results, repeat until a stop condition. Frameworks — Google ADK, the Claude Agent SDK, the OpenAI Agents SDK — package that loop with sessions, tracing and guardrails. Learn what the loop does before you let a framework hide it, and you will be able to debug any of them.
Interview questions this lesson prepares you for
- What is the difference between an agent and a workflow, and why does it matter for reliability?
- You have a support bot with three intents. Walk me through a routing design and how you would measure whether the router is good enough.
- When would you use voting-style parallelization, and what does it cost?
- How do you stop an evaluator-optimizer loop from running forever?