Skip to content
codewithanjum
AI agents

AI agents vs workflows: when to use an AI agent, and when not

AI agents vs workflows explained with plain definitions, a comparison table, decision rules and two real examples, so you know when an agent is worth it.

By Md Anjum Kamali · · 5 min read

Painting of a wooden marble run carrying glass marbles down a curved track, next to a sign showing a connected node diagram
On this page
  1. How do AI agents and workflows compare?
  2. When should you use an AI agent?
  3. Example 1: a signup alert, which is a workflow
  4. Example 2: researching a company, which is an agent
  5. What does a hybrid look like?
  6. Do agents replace workflows?
  7. A quick test before you build
  8. Questions people ask

Use a workflow when you know the steps in advance and they don't change. Use an AI agent when the steps depend on what turns up along the way and a model has to decide what to do next. Most real systems mix the two: a fixed workflow that hands one messy step to an agent.

An AI agent is a system where a language model gets a goal and a set of tools, and decides on its own which tools to call, in what order, and when it's done.

A workflow is a fixed sequence of steps that runs the same way every time. It can include AI calls, but the path is decided by whoever built it.

Anthropic's engineering post Building effective agents draws the line the same way. It describes workflows as systems where LLMs and tools run "through predefined code paths", and agents as systems where the model directs its own process and tool use. I find that split the most useful one going, because it's about who decides the next step, you or the model.

How do AI agents and workflows compare?

Workflow AI agent
Who picks the next step You, when you build it The model, at run time
Same input, same path? Yes Not always
Cost per run Predictable Varies with how many model calls it makes
Speed Fast Slower, since it thinks between steps
Debugging Read the steps Read the model's reasoning and tool calls
Good at Repeatable jobs with clean data Open-ended jobs with messy inputs
Fails by Breaking on input it wasn't built for Taking a wrong turn or making something up

Neither column is better. They fail differently. A workflow breaks loudly when something unexpected arrives. An agent copes with the unexpected but can be confidently wrong. Which failure you can live with often decides it.

When should you use an AI agent?

Here are the rules I use. If the first two are true, I build a workflow.

  1. Can you draw the job as a flowchart that doesn't change? Build a workflow.
  2. Is the input structured, like a form submission or a webhook payload? Build a workflow.
  3. Does the next step depend on reading something unstructured, like a website, an email or a document? Consider an agent.
  4. Would a person doing this by hand make judgment calls at several points? Consider an agent.
  5. Is being wrong expensive, like sending money or emailing a customer? Keep a workflow in charge and put a human check before the action.
  6. Do you need the same answer every time for audits or billing? Workflow.

There's a middle option people skip. A workflow can make one model call to fill in a value, like "classify this reply as interested, not interested or out of office", and then route on that value with fixed branches. The model helps, but the path stays yours. Anthropic's post lists patterns like prompt chaining and routing for exactly this. I'd try that before reaching for a full agent.

Example 1: a signup alert, which is a workflow

When someone signs up for my product, my backend sends a POST request to an n8n webhook. Then:

  1. A Set node pulls out the name, email and signup time.
  2. A Google Sheets node appends a row.
  3. A Gmail node emails me an alert, in parallel with step 2.

Then I write that person a short first email by hand.

There's no AI in it, and there shouldn't be. The input is structured, the steps never change and I want it to work every single time. An agent here would make every signup slower and more expensive, and add a small chance of something odd happening, for zero benefit. The full build is in my n8n signup workflow post.

Example 2: researching a company, which is an agent

Now take "find out what this company does and write an opener for a cold email". The input is a domain. What happens next depends on the website:

  1. Some homepages say exactly what they sell. One fetch is enough.
  2. Some are a vague tagline, so you need the pricing or about page.
  3. Some redirect, fail to load or are parked domains.
  4. Some sell to a totally different audience than you'd guess from the name.

You could try to write a workflow with a branch for each case, but you'd never cover them all. An agent with a "fetch page" tool can look at what came back and decide whether to fetch another page, try a different URL or give up and say it couldn't tell.

At Prospectee we built an agent like this. It browses company websites using the user's own LLM key, and one user ran it across 45,000 rows for under $2 in model fees. That worked because each row is a messy, open-ended question with a short answer. It's the kind of job agents are good at. If you want to build a small version yourself, my n8n AI agent tutorial walks through it node by node.

What does a hybrid look like?

Most of what I build ends up like this:

Schedule trigger (workflow)
  -> Read new leads from a sheet (workflow)
  -> For each lead: research agent (agent)
  -> Write result back to the sheet (workflow)
  -> If score is high, notify me (workflow)

The workflow owns the schedule and the data, plus anything with consequences. The agent gets one job in the middle where judgment is needed, and its output goes through fixed steps after. If the agent gets something wrong, the damage stops at a cell in a spreadsheet, not an email to a customer.

That shape also makes testing easier. You can run the agent step on twenty sample rows, read the results and tune the prompt without touching anything else.

Do agents replace workflows?

No. Agents make some workflows smaller, because one agent step can replace a pile of brittle branches. But the scaffolding around them is still workflow work: triggers, storage, retries, approvals. Tools like n8n now put both on the same canvas, which is the right idea.

The common mistake I see is starting with an agent because it's the exciting thing, then spending weeks trying to make it behave predictably. If predictable is what you need, you wanted a workflow from the start. Anthropic's post makes the same point: find the simplest solution and only add complexity when it's needed.

A quick test before you build

Write down the job in one sentence and list the steps a person would take. Then ask two questions:

  1. Did I write the same steps for every possible input? Build a workflow.
  2. Did I write "it depends" anywhere? That step might be an agent. Keep everything else as a workflow around it.

Start with the workflow, add the agent where the "it depends" is, and measure whether it actually beats a simpler model call. If you're new to building agents, how to build an AI agent covers the basics from scratch.

Questions people ask

What is the difference between an AI agent and a workflow?

A workflow follows steps you defined in advance, in a fixed order. An AI agent gets a goal and a set of tools, and the model decides which tools to use and in what order until the goal is done.

When should I use an AI agent instead of automation?

When the input is messy and the right next step depends on what you find along the way, like researching a company from its website. If you can draw the steps as a flowchart that never changes, a workflow is cheaper and more reliable.

Can a workflow include an AI step without being an agent?

Yes, and it's often the best option. A workflow can call a model once to classify an email or summarise a page, then carry on with fixed steps. The model fills in a value but doesn't choose what happens next.

Are AI agents more expensive than workflows?

Usually. An agent may call the model several times per task while it reasons and uses tools, and each call costs tokens. A workflow with no model or a single model call has a cost you can predict per run.

Keep reading