Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

Handbooks  /  Agents vs Workflows
AI~9 min readComparison
Head to Head

Agents vs workflows: who decides the next step?

WorkflowsvsAgents

Every "AI agent" pitch makes autonomy sound like the goal. It isn't — it's a cost. A workflow's fixed path is cheaper, faster, and easier to trust than an agent's open-ended loop, and most tasks don't actually need what only an agent can provide.

01

The one distinction that decides everything

In a workflow, the control flow — which LLM call happens after which, and with what — is written by you, in code, ahead of time. In an agent, the model itself decides its next action at runtime, in a loop: plan, call a tool, observe the result, decide again, until it judges the task done. The difference isn't capability, it's who's driving.

→ The rule

If you can write down the sequence of steps in advance and have it hold for the vast majority of real cases, that's a workflow. If the right next step genuinely depends on what's discovered along the way and can't be known ahead of time, that's an agent.

02

Head to head

DimensionWorkflowsAgents
Control flowFixed by your codeDecided by the model, at runtime
PredictabilityHigh — deterministic pathsLower — harder to test exhaustively
Cost & latencyBounded — known number of LLM callsVariable — can loop many times, unpredictably
DebuggabilityEasy — trace step X did YHarder — must inspect a whole trajectory
Failure modeFails at a known step, has a fallbackCan loop unproductively without guardrails
Engineering overheadLowerHigher — needs sandboxing, step limits, cost caps
Best forWell-defined, repeatable tasksOpen-ended tasks whose path can’t be known upfront
03

When to use each

Reach for workflows

  • The task is well-understood and repeatable
  • Predictability and cost control matter more than flexibility
  • You can enumerate the paths the task will take
  • Debuggability and easy fallback handling matter

Reach for agents

  • The next step genuinely depends on what’s discovered
  • The task space is open-ended (research, debugging an unknown issue)
  • Hardcoding the path would require anticipating every case
  • You’ve confirmed a workflow can’t cover this task’s variability
04

Autonomy is earned, not defaulted to

Start with the simplest workflow that solves the problem. Reach for full agentic autonomy only when the task's unpredictability genuinely requires it — an agent loop costs more in latency, dollars, and reliability risk than a fixed sequence of calls, so that cost needs to buy you something a workflow structurally can't provide, not just feel more impressive to build.

→ The decision rule

Ask: can I write down the steps this task needs, even as a handful of branches? If yes, a workflow will be cheaper, faster, and easier to trust than an agent — build that first.

05

It’s a spectrum, not a binary

"Workflow" and "agent" aren't two discrete categories so much as two ends of a spectrum measured by how much of the control flow you hand to the model. A simple prompt chain (call 1's output feeds call 2, always) is a pure workflow. A router (the model picks one of N predetermined paths, but the path itself is fixed once chosen) hands the model a little control — more agent-like than a chain, but still bounded and enumerable. A full agent loop with an unbounded number of tool calls and no predetermined stopping point sits at the far end, where the model controls not just which path but how many steps it takes and when it's done.

The real engineering decision, then, isn't "workflow or agent" as a one-time architectural choice — it's incrementally deciding, task by task and even sub-task by sub-task, how much of the control flow genuinely needs to be dynamic. Most production systems that call themselves "agents" are actually a workflow with one or two genuinely agentic components embedded in it, not autonomy end to end.

→ The trade you’re actually making

Every increment of autonomy you hand the model buys flexibility and costs predictability — the right amount is exactly as much as the task's real variability demands, no more.

06

A worked scenario: a support-ticket system

Triaging an incoming support ticket — classify it, route it to one of five fixed handlers (billing, bug report, feature request, account access, other) — is a workflow: the five categories are known in advance, the routing logic is stable, and hardcoding "if billing, go here" is both cheaper and more reliable than letting a model improvise a route it might get wrong in a way that's hard to catch. This handles the large majority of incoming tickets cheaply and predictably.

But "investigate this obscure production bug using logs, code search, and running tests to reproduce it" cannot be hardcoded into a fixed path, because you genuinely don't know what the investigation will find — the next useful action (check this log, grep for that error, run this specific test) depends entirely on what the previous action turned up. That's an agent loop, deliberately reserved for the minority of tickets that actually need open-ended investigation, while the cheap, predictable workflow handles routing for the other 90%.

→ The pattern generalizes

Most real systems are a workflow with an agent embedded at exactly the one point where the path genuinely can't be predetermined — not an agent end to end.

The picture

The picture: a path you wrote vs a loop the model drives

workflow: path fixed in code ticket classify billing bug +3 more reply 2 LLM calls, every timefails at a known step agent: model picks each step LLM decides call tool observe done or cap n steps, chosen at runtime
The page’s support-ticket system, both halves. In the workflow every arrow was written by you, so the number of LLM calls is known before the ticket arrives. In the agent the only fixed parts are the loop and the exit; which tool, how many times and when to stop are all decided by the model, one step at a time.
By the numbers

Worked example: what an agent loop costs as it runs

Illustrative but typical sizes. Every call starts from a 2,000-token prompt (instructions, the task, tool definitions). Each agent step appends about 500 tokens: the tool call plus its result. Chat model APIs are stateless, so the whole transcript is re-sent on every call, and step i pays for everything before it. Total input over n steps is n × 2,000 + 500 × n(n − 1)/2. For reliability, assume each step independently goes right 95% of the time.

DesignLLM callsInput tokens, totalLargest single promptAll steps go right (95% each)
Workflow: classify, then route24,0002,00090.25%
Agent, 3 steps37,5003,00085.7%
Agent, 10 steps1042,5006,50059.9%
Agent, 20 steps20135,00011,50035.8%

Two curves bend the wrong way. Tokens grow quadratically, because every step re-reads all earlier steps: going from 10 steps to 20 multiplies input tokens by 3.18, and the 20-step run uses 33.75× the workflow’s 4,000. Prompt caching lowers the price of a re-sent prefix, but not the growing length of the context the model has to read. Reliability compounds: at 95% per step, a 20-step run gets every step right only 35.8% of the time. Agents survive that by noticing a failed step and trying again, which is real capability, but it means extra steps on top of the ones planned, and it only works if each failure comes back as a clear message. A workflow’s two calls fail where you can see them.

Trade-offs

Cost and trade-offs across the spectrum

CaseTimeSpaceWhy
Prompt chainA fixed n callsEach call sees only what you pass itThe cheapest pattern. Every step can be tested on its own.
Router1 classify + 1 handlerSmall, per callThe model chooses among paths you wrote, so every path is still testable.
Parallel fan-outk calls at onceSeparate per branchCost grows with k; latency is the slowest branch, not the sum.
Evaluator–optimizer loop2 calls per round, capped roundsGrows each roundDraft, critique, revise. A bounded loop: you choose the cap.
Orchestrator–workers1 planner + workers, how many decided at runtimeThe planner sees summaries, not every worker’s transcriptThe plan is dynamic; each worker is not. The first real step into agent territory.
Full agent loopn, decided by the modelPer call grows with n; total grows with n² unless trimmedNeeds a step cap, a budget, timeouts and a sandbox before it is safe to run.

Read down the table and each row hands the model a little more of the control flow, and costs a little more predictability: the spectrum the page describes, with the bill attached. The pattern names follow Anthropic’s engineering post Building effective agents, which draws the same line between workflows (LLMs orchestrated through predefined code paths) and agents (LLMs directing their own process and tool use).

Watch for

Common mistakes

  • No hard stop

    An agent with no step cap, token budget or wall-clock timeout will eventually loop: the same tool, the same arguments, the same error. Set all three, and detect repeats (an identical tool call twice in a row is almost always a stuck loop). When a limit trips, return what was found so far, not a crash.

  • Pouring raw tool output into the context

    A tool that returns a 50,000-line log puts all of it into every later call, which is the quadratic row above at its worst. Make tools return the useful slice (the top matches, the last 50 lines, a summary) plus a way to ask for more. In the worked example, trimming each step from 500 tokens to 200 takes the 20-step run from 135,000 input tokens to 78,000, 42% fewer, without removing a single step.

  • Letting the model do deterministic work

    Date arithmetic, totals, schema validation and routing on a field you already have are free, exact and testable in code. Put them in code, around the model, and spend LLM calls only on the steps that need judgement.

  • Irreversible actions without a gate

    Refunds, emails, deletes and deploys should not be one tool call away from a model that is wrong some percentage of the time. Require a confirmation or human approval for side effects, give tools the narrowest credentials that work, and prefer a dry-run mode the agent can call first.

  • Vague tools, silent errors and no traces

    Overlapping tool names and one-line descriptions make the model guess which tool to use; an error that just says 500 makes it guess why it failed. Write descriptions that say when to use each tool, return errors that say how to fix the call, and log every step of every run. You cannot debug an agent from its final answer.

In the wild

Where this shows up in production and interviews

  • Coding agents

    Coding assistants that edit files, run the tests and read the failures are the clearest case for a real agent loop: what to do next depends on what the test run printed, which nobody can know in advance. They are also where step caps, sandboxes and approval prompts for risky commands became standard.

  • Document pipelines

    Invoice extraction, contract clause tagging and ticket summarisation are workflows: the same steps on every document, with an LLM as one or two of them. They run at volume, so the fixed, known cost per item is the feature.

  • Agent inside a workflow

    The page’s point in production form: a fixed pipeline handles intake, validation and routing, and hands one bounded sub-task (the investigation, the open-ended search) to an agent with its own cap and budget, then takes the result back into fixed code.

  • The interview version

    Expect “would you build this as an agent?” Answer with the test from the page (can you write the steps down?), then the costs: calls per task, how context grows, how errors compound over steps, and the guardrails (step cap, budget, approval gates, traces) you would ship with any loop.

Your call

Which would you pick?

Three situations. Pick the side you'd actually build — the explanation follows.

Support tickets arrive and must be routed to one of five fixed queues: billing, bug, feature request, account access, other. Volume is high and the categories have been stable for two years.

A user reports "the export is broken." The cause could be permissions, a malformed row, a timeout, or a third-party outage — and which one it is only becomes clear as you look.

Your team has built an agent for a task. In review, someone shows that a three-step chain with one branch handles 95% of real cases.

Frequently asked

Quick answers

Agent or workflow — which should I use?

Default to a workflow: fixed code paths are cheaper, faster, and easier to debug. Reach for an agent only when the task’s next step genuinely can’t be known in advance and depends on what’s discovered along the way.

Is an agent just a more advanced workflow?

Not quite — it’s a different control-flow model. A workflow’s path is fixed by your code; an agent’s path is decided by the model at runtime. Think of them as two ends of a spectrum measured by how much control flow you hand to the model, not a strict hierarchy.

Why not just always use an agent for flexibility?

Agent loops cost more in latency and dollars (unbounded LLM calls), are harder to test exhaustively, and can fail by looping unproductively. That cost only pays off when a workflow genuinely can’t cover the task’s real variability — using an agent by default pays that cost for no benefit on predictable tasks.

Can a system mix workflows and agents?

Yes, and most production systems do — a fixed workflow handles the well-understood majority of a task, with an agent embedded at the specific point where the path genuinely can’t be predetermined, rather than either extreme applied end to end.

▶  Watch it explained

Agents vs Workflows: who decides the next step?

Agents vs Workflows · Vibe Engines · 2026
Finished this one? 0 / 209 Handbooks done
NextThe Agent Memory Handbook Next on the “Building agents” ladder · rung 3 of 10

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Handbooks