Agents

AI agents vs workflows: what is the difference?

"Agent" is the most overused word in AI right now. Here is a precise way to tell the difference: who decides what happens next?

The core distinction#

WorkflowYour code decides the stepsFixed path, model fills in stepsPredictable cost and latencyEasy to test and debugAgentThe model decides the next stepPath varies per taskHandles open-ended problemsCostlier, slower, harder to testvs

Climb the ladder, do not jump#

Start at the bottom. Move up only when the lower rung cannot do the job.

Single LLM callclassify, summarize, extractstart hereWorkflow: fixed stepschain, route, run in parallelWorkflow with loops and checksevaluator, retry, orchestrator-workersAgentmodel picks tools in a loop until doneonly if needed
Every rung up adds cost, latency and ways to fail.

Five workflow patterns you will actually use#

  1. Prompt chaining. Output of step one feeds step two (draft, then translate, then format).
  2. Routing. Classify the input, then send it to a specialized prompt or model.
  3. Parallelization. Run independent steps at once, or run the same task several times and vote.
  4. Orchestrator-workers. One model splits a task, others do the pieces, then results are combined.
  5. Evaluator-optimizer. One call produces, another critiques, repeat until good enough.

All five keep your code in charge of the structure.

What an agent looks like#

An agent is a tool-use loop: call the model, run the tools it asks for, append the results, repeat until it stops asking. Coding agents like Claude Code are the clearest example.

ts
while (true) {
  const response = await callModel(messages, tools);
  if (response.stop_reason !== "tool_use") break; // model decided it is done
  messages.push(...(await runTools(response)));     // model decided what to run
}

The loop is trivial. The hard part is everything around it: tool design, context management, permissions and stopping conditions.

Should this be an agent? A four-question check#

QuestionAgent only if...
ComplexityThe steps cannot be fully specified in advance
ValueThe outcome justifies higher cost and latency
ViabilityThe model is demonstrably capable at this task type
Cost of errorMistakes can be caught or rolled back (tests, review, undo)

If any answer is no, stay at a simpler rung.

Cost, latency and safety#

An agent makes a variable number of model calls, and its context grows with each tool result. Budget for that: set step limits, trim tool output and cache the stable prefix (prompt caching). Give agents the minimum permissions, require approval for irreversible actions, and treat tool output as untrusted (MCP security).

A practical rule#

Write the workflow first. If you keep adding "unless" branches that the model could handle better, let it decide that one step. Agentic where it helps, deterministic everywhere else.

And test it: you cannot improve what you do not measure. See LLM evals explained.

Frequently asked questions

What is an AI agent?

An AI agent is a language model running in a loop with tools: it decides which tool to call, reads the result and repeats until the task is done or it needs a human. Coding agents like Claude Code are a common example.

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

In a workflow, developer-written code decides the sequence of steps and the LLM performs individual steps. In an agent, the LLM decides which steps and tools to use next, in a loop, until it considers the task done.

When should I use an agent instead of a workflow?

When the task is open-ended, the number of steps cannot be predicted, the value justifies higher cost and latency, and mistakes can be caught or undone. If you can write the steps down, write a workflow.

Are agents more expensive than workflows?

Usually yes. An agent makes a variable number of model calls and carries a growing context, so cost and latency are higher and less predictable.

What are common workflow patterns?

Prompt chaining, routing, parallelization, orchestrator-workers and evaluator-optimizer loops.