AI Workflows & Orchestration
IC4IC5IC6

Workflows vs. Agents: The Autonomy Spectrum

The decision that quietly determines your token bill, your p99, and whether anyone can debug the 2am page: did the LLM follow your code path, or write its own?

15 min read · 13 sections
0

1. Quick anchor

A workflow is an LLM-powered system where you, the engineer, wrote the control flow: LLM calls and tools are orchestrated through predefined code paths. An agent is a system where the LLM directs its own process — it decides at runtime which tool to call next, when to stop, and how to recover. These are not two categories; they're the two ends of one autonomy spectrum, and almost everything good in production lives in the hybrid middle. The single sharpest test (from Anthropic's Building Effective Agents): can you draw the flowchart before execution? If yes, it's a workflow; if the path depends on what the model discovers along the way, it's an agent. The senior move is not "build the most autonomous thing" — it's the simplest thing that works, because every notch of autonomy you add trades away cost predictability, latency bounds, and debuggability.

2. Why interviewers probe this

This is the load-bearing first decision of any LLM system design, and it separates people who've shipped from people who've watched a demo.

  • IC4 — Do you know the taxonomy and the tradeoff? Can you define workflow vs. agent precisely (not "agents are smarter"), name the five workflow patterns, and articulate why a fixed code path is cheaper and more debuggable than a loop the model controls?
  • IC5 — Can you diagnose and bound autonomy? Given a system that's over budget or flaky, can you locate where non-determinism entered, decompose an agent back into a workflow where possible, and reason quantitatively about per-step success compounding over multi-step runs?
  • IC6 — Can you architect the hybrid and defend it? Can you place a deterministic supervisor over bounded autonomous specialists, justify it against compliance/audit constraints, and know when not to reach for an agent at all? Staff interviewers are listening for "the simplest thing that works" as a reflex, not a slogan.

3. Concept build-up

Beginner explainerNew here? The words first

The words first.

  • LLM — large language model; the thing you call with a prompt and get text (or a tool call) back.
  • Tool — a function the model can invoke (search, SQL query, send_email). The model emits a structured request; your code runs it.
  • Control flow — the order things happen in. In a workflow you wrote it; in an agent the model picks it.
  • Workflow — LLM calls wired together by code you wrote ahead of time. Predictable path.
  • Agent — a loop where the model looks at results and decides the next action itself. Path discovered at runtime.
  • Autonomy spectrum — the dial between "fully scripted" and "model drives everything"; most systems sit in between.
  • Orchestrator — a coordinating LLM (or piece of code) that breaks a task into subtasks and hands them out.
  • Determinism — same input, same path, same-ish output. Workflows have a lot of it; agents have little.

Step by step.

  1. Write down the task. Ask: do I know the steps in advance?
  2. If yes — chain or route fixed LLM calls. That's a workflow.
  3. If the steps depend on what the model finds (it might need 2 searches or 9), you need a loop. That's agent territory.
  4. Before reaching for the loop, ask if a workflow plus a bit of branching covers 90% of cases.
  5. If you must add autonomy, fence it: cap iterations, validate outputs, route by a classifier first.
  6. Measure cost and per-step success — small failure rates compound fast over many steps.

Remember this: Reach for the simplest pattern that works, and only buy autonomy when the path genuinely can't be known in advance.

3.1 The spectrum, precisely

Anthropic's framing (December 2024 onward) draws one line and puts everything on it. At the left: a single LLM call. Moving right, you add augmentations — retrieval, tools, memory — but the code still decides what happens when. That whole region is workflows: "systems where LLMs and tools are orchestrated through predefined code paths." Push further right and the model itself starts choosing the next step based on observations; now it "dynamically directs its own processes and tool usage." That's an agent.

The crucial reframe for an interview: agentic is not a binary badge, it's a dose. A system can be 95% scripted with one bounded autonomous step. The question is never "is this an agent?" but "how much of the control flow have I handed to the model, and what did I get for it?"

The flowchart test operationalizes this. If you can draw boxes and arrows that fully describe execution before you run it, you have a workflow — and that drawing is your test suite, your audit log, and your cost model. If the arrows can only be drawn after the run (because the model decided how many loops, which tools, in what order), you have an agent, and you've traded that drawing away.

3.2 The five workflow patterns

Before anyone needs an agent, these five patterns (Anthropic's taxonomy) cover the overwhelming majority of production systems. Know all five cold.

  1. Prompt chaining. Sequential calls where each step consumes the previous output: outline → check outline → draft. Decomposes a hard task into smaller, individually verifiable steps. Low cost, low complexity. Add a programmatic gate between steps ("does the outline have 5 sections?") and you catch errors before they compound.
  2. Routing / classification. A classifier call sends the input to a specialized handler: a support query routes to pricing, refund, or returns. One cheap upstream classification, then a focused downstream prompt. Single entry point, high accuracy, because each handler does one thing well.
  3. Parallelization. Two flavors. Sectioning: split into independent subtasks, run concurrently, aggregate (cuts latency). Voting: run the same task N times and aggregate, e.g. majority vote for confidence (buys reliability). You pay more tokens; you save wall-clock or gain certainty.
  4. Orchestrator–workers. A central LLM dynamically decomposes a task into subtasks it can't enumerate in advance, delegates to worker LLMs, and synthesizes. This is where you cross into agentic territory — the subtask count and structure are model-decided. Powerful and flexible, but cost runs roughly 3–10x a flat workflow, and you inherit three new failure modes: misdecomposition, worker failure, and synthesis hallucination.
  5. Evaluator–optimizer. A generator produces output; an evaluator critiques it against explicit success criteria; if it fails, the generator refines. A loop — so loop depth (and cost) is variable. Worth it when criteria are crisp and refinement measurably helps: code review, legal drafting, translation.

Patterns 1–3 are unambiguously workflows. Patterns 4–5 are the on-ramp to autonomy: they introduce model-controlled loops. Anthropic's own guidance is blunt — most production systems shouldn't need to go beyond parallelization.

Per-step success compounding — on real numbers

Name the symbols: p = probability a single step succeeds, n = number of sequential steps, P = probability the whole run succeeds end-to-end. For independent steps, P = p^n.

Work it. Say each step is a strong 99% reliable: p = 0.99.

  • A 3-step prompt chain: P = 0.99^3 = 0.970 → ~97% of runs fully succeed.
  • A 10-step agent trajectory: P = 0.99^10 = 0.904 → ~90%.
  • A 30-step agent that explored a lot: P = 0.99^30 = 0.740 → ~74%.

Drop per-step reliability to a still-decent 95% and the 10-step run is 0.95^10 = 0.599 — barely a coin-flip better than failing.

What it did to the data: it turned "each step is fine" into "the run usually breaks," purely by chaining length. This is the quantitative reason workflows (few, fixed steps) beat sprawling agent loops on reliability — and why bounding the number of agent steps is the highest-leverage knob you have.

3.3 Why workflows win (when they apply)

Four concrete arguments, each one an interview-ready bullet:

  • Cost predictability. A workflow has a fixed token budget per run — you can compute it ahead of time and route cheap steps to a cheap model (e.g. Haiku for the classifier, a larger model only for the hard synthesis). Agents risk a 4–15x token spike from exploration loops you didn't author. Finance hates a variance that wide.
  • Compliance & auditability. Every path in a workflow is enumerable and testable before deployment. Agents are non-deterministic by construction. SOC 2, GDPR, and financial regulation strongly favor systems where you can prove what the code can do.
  • Debugging & reproducibility. A workflow failure lands on a known branch — you bisect a flowchart. An agent failure requires reconstructing a unique trajectory from traces. At 2am, the difference between "step 3 returned bad JSON" and "the model went down a weird path for reasons" is enormous.
  • High-volume repeatability. Workflows scale to thousands of daily runs with predictable latency. Agents accumulate error over steps (see the whiteboard) and accumulate latency variance, which wrecks your p99.

3.4 When agents genuinely win

Don't over-correct into "always workflow." Agents earn their keep on open-ended tasks where the solution path depends on discoveries: research, debugging, adaptive multi-tool problem-solving. If you cannot know in advance whether the task needs two steps or nine — if the next action must depend on the last observation — a fixed flowchart is a lie, and forcing one produces a worse system than an honest loop. The 2025+ tooling makes the loop better: Claude's interleaved thinking (beta header interleaved-thinking-2025-05-14 on Claude 4 / Opus 4.7+) inserts reasoning blocks between tool calls so the model reflects on intermediate results before choosing the next action — fewer wasted tool calls and hallucinated loops, at the cost of added latency.

3.5 The hybrid is the real answer

In practice the winning architecture is a deterministic supervisor routing to bounded autonomous specialists: a scripted entry point (routing workflow) that hands well-scoped sub-problems to small agents which are free to loop within a fence (capped iterations, validated outputs, scoped tools). You get the audit trail and cost control of a workflow at the top, and the flexibility of an agent only where the task demands it. See /agents for how to build the autonomous specialists, and /system-design for wiring the supervisor.

4. Minimal implementation

Here's the same task — answer a customer-support query — built first as a routing workflow (you can draw the flowchart) and then the delta to make one branch agentic. Production-shaped: structured-output routing, a cheap model for the classifier, an iteration cap on the agent.

import os
from anthropic import Anthropic
 
client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
 
# ---- WORKFLOW: routing. The flowchart exists before we run. ----
ROUTES = {
    "pricing":  "You are a pricing specialist. Answer only pricing questions.",
    "refund":   "You are a refunds specialist. Follow the refund policy exactly.",
    "returns":  "You are a returns specialist. Explain the returns process.",
    "other":    "You are a general support agent.",
}
 
def classify(query: str) -> str:
    """One cheap, schema-constrained call decides the branch."""
    resp = client.messages.create(
        model="claude-haiku-4-5",          # small model: routing is easy + high-volume
        max_tokens=64,
        tools=[{
            "name": "route",
            "description": "Pick the handler for this support query.",
            "input_schema": {
                "type": "object",
                "properties": {"label": {"type": "string", "enum": list(ROUTES)}},
                "required": ["label"],
            },
        }],
        tool_choice={"type": "tool", "name": "route"},  # force the schema -> ~99.9% valid
        messages=[{"role": "user", "content": query}],
    )
    for block in resp.content:
        if block.type == "tool_use":
            return block.input["label"]
    return "other"
 
def handle(query: str) -> str:
    label = classify(query)                # <-- predefined code path picks the branch
    resp = client.messages.create(
        model="claude-sonnet-4-5",
        max_tokens=512,
        system=ROUTES[label],
        messages=[{"role": "user", "content": query}],
    )
    return f"[routed: {label}] " + "".join(
        b.text for b in resp.content if b.type == "text"
    )
 
# ---- AGENT delta: ONE branch loops, the model picks tools, but we FENCE it. ----
def agentic_branch(query: str, tools: list, max_steps: int = 6) -> str:
    """The model directs its own process -- bounded by max_steps."""
    messages = [{"role": "user", "content": query}]
    for step in range(max_steps):          # <-- the fence: cap the autonomy
        resp = client.messages.create(
            model="claude-sonnet-4-5",
            max_tokens=1024,
            tools=tools,
            messages=messages,
        )
        messages.append({"role": "assistant", "content": resp.content})
        if resp.stop_reason != "tool_use":         # model decided it's done
            return "".join(b.text for b in resp.content if b.type == "text")
        # else: run the tools the MODEL chose, feed results back, loop again
        results = [run_tool(b) for b in resp.content if b.type == "tool_use"]
        messages.append({"role": "user", "content": results})
    return "Hit step cap without resolving — escalating to human."  # honest failure
 
if __name__ == "__main__":
    print(handle("How much is the Pro plan annually?"))

What to notice, and what an interviewer wants you to say about it:

  • The workflow's control flow is in your code. classifyhandle is a flowchart. You can unit-test every branch, compute the token cost (one Haiku call + one Sonnet call), and audit every path.
  • tool_choice forces the schema. Claude's Structured Outputs (GA Nov 2025+) constrain generation to your JSON Schema, giving ~99.9% valid routing labels — no hallucinated branch, no KeyError. This is the production standard; never parse a free-text label with a regex.
  • The agent's control flow is in the model's hands — but inside agentic_branch the for step in range(max_steps) loop is the single most important line. Unbounded, that loop is your 15x token spike. Bounded, it's a controlled experiment.
  • The failure path is explicit and honest. Hitting the cap escalates to a human rather than looping forever or hallucinating a resolution.

5. Production tradeoffs

Dimension Workflow Agent What changes at scale
Token cost / run Fixed, pre-computable 4–15x spike risk from exploration Budget per-route; route cheap steps to Haiku
Latency (p99) Bounded, low variance High variance (loop depth varies) Agent p99 dominated by max-step cap, not mean
Reliability High; p^n with small n Degrades with trajectory length A 10-step loop at 99%/step ≈ 90% end-to-end
Debuggability Bisect a known flowchart Reconstruct a unique trajectory Step-level tracing becomes mandatory
Auditability Every path testable pre-deploy Non-deterministic Regulated domains: keep control flow in code
Right tool for Known, repeatable, high-volume Open-ended, path-depends-on-discovery Hybrid: deterministic supervisor + bounded specialists

The prose that matters: at low volume, an agent's looseness is hidden by small numbers — the demo works, the cost is a rounding error. Scale exposes everything. The 8% per-run failure that was invisible at 50 runs/day is 80 angry tickets at 1,000 runs/day, each one a unique trajectory your on-call has to reconstruct. The token variance that was noise becomes a six-figure line item with a standard deviation finance can't forecast.

Three failure modes to name explicitly. Orchestrator misdecomposition: the coordinating model splits the task wrong, and every downstream worker does excellent work on the wrong subproblem. Synthesis hallucination: workers return correct pieces and the aggregator invents a confident, wrong summary. Silent loop creep: a refinement loop with no cap or no improving evaluator burns tokens converging on nothing. Mitigations are unglamorous and effective: cap iterations, gate steps with cheap deterministic checks, validate every structured output against a schema, and for long-running or restart-prone systems, reach for durable execution. Temporal's model — an event-history log replayed deterministically on restart, skipping already-completed activities, with at-least-once activity retries made effectively exactly-once via idempotency keys — turns "the box crashed at step 7" from a catastrophe into a no-op resume. LangGraph's checkpointing (Postgres/Redis backends, GA in v0.2+) brings the same pause/resume/recover to graph-shaped LLM systems. Evaluate durability early; in 2026 it's first-class, not an afterthought (/inference, /harness).

6. How it's asked

[IC4] Define workflows vs. agents using the Anthropic taxonomy, and give the one-line test. Workflows are systems where LLM calls and tools are orchestrated through code paths you defined ahead of time; agents are systems where the LLM dynamically directs its own process — choosing tools and next steps at runtime from observations. They're two ends of one autonomy spectrum, not separate buckets. The one-line test: can you draw the complete flowchart before execution? Yes means workflow (and that flowchart is your test suite and audit log); no means agent, and you've traded predictability for flexibility.
[IC5] Your orchestrator-worker system costs 8x projection and fails ~1 in 12 runs. Diagnose and fix. First I'd ask whether the task actually needs dynamic decomposition — if the subtasks are knowable, I collapse the orchestrator into a fixed prompt chain or sectioned parallelization and most of the cost and variance evaporates. If it genuinely needs an agent, I instrument step-level tracing to localize the ~8% failure: misdecomposition, worker failure, or synthesis hallucination each has a different fix. For cost, I cap orchestrator iterations, route the decomposition and synthesis to the right-sized models, and add cheap deterministic gates between steps so a bad subtask fails fast instead of fanning out. The p^n math tells me trajectory length is likely the reliability culprit, so shortening and bounding the loop is the highest-leverage move.
[IC6] Architect a regulated, high-volume support system that's auditable but handles open-ended troubleshooting. A deterministic supervisor owns the top: a routing-classifier workflow (schema-forced, cheap model) that's fully enumerable and testable for the auditors, logging every decision. Closed-form intents — pricing, refunds, returns — terminate in scripted handlers with no autonomy. Only the genuinely open-ended branch (technical troubleshooting) hands off to a bounded autonomous specialist: scoped tools, a hard iteration cap, structured-output validation on every step, and a human-escalation path when it hits the cap. I'd put it on durable execution (Temporal or LangGraph checkpointing) so long sessions survive restarts, and OpenTelemetry spans on every LLM/tool call so each autonomous trajectory is reconstructable for compliance. Autonomy lives in exactly one fenced place, and the system as a whole is "the simplest thing that works" for each class of request.
[IC5] When is reaching for an agent the wrong instinct, even though it would technically work? Whenever the path is knowable in advance, an agent is a strictly worse workflow: you pay the cost variance, the latency variance, and the debugging tax for flexibility you don't use. The trap is that agents demo beautifully — the model improvising looks impressive in a notebook — so people ship the loop before checking whether routing plus a chain covers 95% of traffic at a fraction of the cost. The senior instinct is to start at the simplest pattern and add autonomy only when a real, observed task class can't be expressed as a fixed path.

7. Pitfalls & flashcards

  • Conflating "agentic" with "good." Autonomy is a cost you pay for flexibility, not a feature. If the flowchart exists, the workflow wins.
  • Unbounded loops. Every agent loop needs a hard step cap and an honest failure path. The cap, not the mean, sets your p99 and worst-case cost.
  • Ignoring p^n. "Each step is 99%" feels safe until you chain 30 of them into a 74% run. Shorten and bound trajectories.
  • Free-text routing. Parsing a classification label with a regex is a latent bug. Force a JSON Schema with tool_choice.
  • No step-level tracing. Without per-span traces (token counts, tool params, state transitions), agent failures are unfixable. Industry data: ~62% have step-level tracing, only ~52% close the loop to evaluation — instrument from day one (/evals).
  • Skipping durability. For long-running or restart-prone systems, "the worker crashed" should be a resume, not an incident. Evaluate Temporal/LangGraph checkpointing early.

Flashcard. Workflow = you wrote the control flow (LLM calls orchestrated through predefined code paths). Agent = the LLM wrote the control flow (it directs its own process at runtime). One spectrum. Test: can you draw the flowchart first? Default to the simplest pattern that works; buy autonomy only when the path can't be known in advance.

8. Further reading

Next: /agents — build the bounded autonomous specialist that lives inside the hybrid you just designed.

Primary sources
← More in AI Workflows & Orchestration