AI Agent vs Workflow: Choosing the Right Pattern
Should this be an agent or a workflow? This case study follows a team that picked wrong, lost a month, and found the hybrid pattern that AI agent vs workflow debates miss.
Workflow (fixed order):
1. extract -> model call (structured output)
2. match -> deterministic rules
3. IF clean -> route for payment (rule)
IF mismatch-> hand to an AGENT (the only open-ended part)Should this be an agent or just a workflow? If you've stared at that question before starting a build, unsure which way to jump, you're asking the right thing at the right time — and the answer is more nuanced than the internet's "agents are the future" enthusiasm suggests. The AI agent vs workflow choice is one of the highest-impact decisions you'll make, and getting it wrong costs weeks.
Here's a team that got it wrong first, then found the pattern most comparisons leave out.
The Problem: An AI Agent vs Workflow Decision Gone Wrong
A fintech startup needed to process incoming invoices: extract the amount and vendor, match against purchase orders, flag mismatches, and route the rest for payment. They read that agents were more flexible, so they built one — a model with tools for extraction, matching, and routing, free to decide the order per invoice.
It worked in testing. In production it was slow, inconsistent, and expensive. The same invoice would sometimes get matched before extraction finished, sometimes route without matching, sometimes loop twice. Costs ran four times their estimate because every invoice triggered multiple model calls for a job that was, underneath, almost entirely predictable.
The numbers told the story before anyone read a trace. Estimated cost was pennies per invoice; actual cost was four times that. Estimated latency was under a second; actual was several, because each invoice bounced through the model repeatedly as it "decided" an order that never needed deciding. And the accounting team, who cared about consistency above everything, kept finding invoices handled three subtly different ways. A predictable task had been made unpredictable by design.
The Wrong Approach
Their mistake was treating a mostly-deterministic pipeline as if it were an open-ended task. Invoice processing has a known shape: extract, then match, then decide. The order never changes. Giving a model the freedom to choose that order didn't add flexibility — it added variance to a process that wanted none.
They'd confused "involves AI" with "needs an agent." Extraction benefits from a model. Matching is mostly rules. Routing is a rule. Only the exception-handling — what to do with a weird mismatch — had any genuine unpredictability. They'd wrapped the whole pipeline in agency to get flexibility on the 10% that needed it, and paid for it on the 90% that didn't.
There's a seductive logic behind the mistake, which is why smart teams make it. Agents are more capable than workflows, so more capability sounds strictly better. But capability you don't need isn't free — it's variance, cost, and latency you pay for on every single run. A workflow's rigidity isn't a limitation here; it's the feature. Doing the same thing every time is exactly what invoice processing wanted.
You can spot this mistake in the wild by one symptom: an agent that produces different results for identical inputs. A workflow can't do that — same input, same output, by construction. If your "agent" is giving inconsistent answers on a task where consistency is the whole point, that inconsistency isn't a bug to tune away. It's a signal you chose the wrong pattern, and the fix is architectural, not a better prompt.
⚡ Pro tip: "Involves a model" and "needs an agent" are different claims. Most AI features are a model call or two inside a fixed workflow, not an agent deciding the workflow itself.
The Correct Pattern
The fix was a workflow with one agentic step — the hybrid the AI agent vs workflow debate usually skips.
Workflow (fixed order):
1. extract -> model call (structured output)
2. match -> deterministic rules
3. IF clean -> route for payment (rule)
IF mismatch-> hand to an AGENT (the only open-ended part)What this does: it hard-codes the predictable spine of the process and reserves agency for the single genuinely uncertain part — resolving mismatches, where the path really does depend on what the model finds. The 90% that's deterministic runs as fast, cheap, reliable code. The 10% that needs judgment gets an agent, scoped tightly to just that job.
The key move is scoping the agent narrowly. The mismatch agent doesn't see the whole pipeline — it gets one job, one small set of tools, and one question: is this mismatch explainable and resolvable, or does it need a human? A tightly scoped agent is far more reliable than a broad one, because there's less room to wander. The workflow does the marching; the agent only handles the fork in the road.
⚡ Pro tip: Scope any agent that lives inside a workflow to the narrowest possible job. The mismatch agent should not be able to touch extraction or routing — fewer powers means fewer ways to go wrong.
⚡ Pro tip: When a task is mostly predictable with pockets of uncertainty, don't choose between agent and workflow — nest a small agent inside a workflow at exactly the uncertain step. It's the pattern that wins most real cases.
Results and What Changed
Costs dropped by roughly three-quarters, because the common path no longer fired multiple model calls per invoice — most invoices touched the model exactly once, for extraction.
Consistency became near-total on the clean path, since a fixed workflow does the same thing every time by construction. The variance that had haunted them lived only in the mismatch branch now, which was small, isolated, and easy to monitor.
And debugging got dramatically simpler. When something went wrong, they knew instantly whether it was the deterministic spine (a code bug, reproducible) or the agentic branch (a model call, traceable). Before, every failure was a hunt through a single opaque loop.
There was a staffing effect too. The clean path became something a junior engineer could own and modify without fear, because it was ordinary code. Only the mismatch branch needed someone comfortable reasoning about model behavior. Splitting the deterministic spine from the agentic pocket didn't just cut costs — it let the team divide the work along the line between "code you can reason about" and "a model you have to observe."
⚡ Pro tip: A workflow's biggest underrated benefit is reproducibility. The same input gives the same output every time, which makes bugs findable — something you lose the moment you hand the whole flow to a model.
How to Apply This to Your Situation
Map your task and mark each step as predictable or uncertain. Extraction, formatting, lookups, and rule-based routing are almost always predictable. The uncertain steps are the ones where the right next action depends on what a previous step returned.
If every step is predictable, build a workflow — no agent. If the whole task is uncertain end to end, build an agent. And if it's mostly predictable with a few uncertain pockets, which is the most common reality, build a workflow and drop a scoped agent into just those pockets.
One warning as you mark up your flowchart: be honest about which boxes are truly uncertain. The temptation is to label borderline steps "uncertain" so you can use the exciting agent pattern. Resist it. Every box you can specify should be code. The uncertain set should be as small as you can make it while staying honest — usually it's the exception handling, the judgment calls, the "it depends" steps, and not much else.
Concretely, here's the exercise: list every step, and next to each write the rule that decides its output. Steps where you can write the rule are code. Steps where the honest answer is "it depends on what we find" are the agent. Most teams are surprised how few land in the second column once they force themselves to actually write the rule down.
⚡ Pro tip: Draw the task as a flowchart and highlight the boxes you couldn't fully specify. Those highlighted boxes — and only those — are your agent. Everything else is code.
Next Steps
The AI agent vs workflow question has three answers, not two: workflow, agent, or the hybrid where a small agent lives inside a fixed workflow at the uncertain step. That third answer wins far more often than either pure form, because most real tasks are mostly knowable with a few genuinely open pockets.
Reach for the hybrid as your default hypothesis for any task that touches data. Assume it's a workflow with an agentic pocket until you've proven the whole thing is either fully knowable or fully open. That default steers you right more often than either "build an agent" or "never build an agent" ever will.
⚠️ Common mistake: Picking "agent" for flexibility on a task that's 90% deterministic, then paying agent costs and inheriting agent variance across the 90% that never needed either. Flexibility you don't use is just overhead you do pay for.
Whether you land on a pure agent or a scoped one inside a workflow, the prompts that drive the model steps are worth managing deliberately. PromptABCD keeps the extraction prompt, the mismatch-agent's instructions, and any other model steps versioned in one place, so a workflow that mixes code and model calls doesn't scatter its prompts across the codebase.
Continue Reading
Save the prompts from this post
PromptABCD is a free prompt manager. Paste, organize, and reuse your best AI prompts — no more hunting through chat history.
