PixioLab

AI agents vs workflows: when to let the model choose the steps

By PixioLab ·

Build a workflow when you can write the steps down in advance. Build an agent only when the next step depends on what the last one found. Workflows are cheaper, faster and easier to test, so most features should start as one and earn their way to an agent.

Two shapes of the same building blocks

A workflow chains model calls and ordinary code along a path you define: classify the request, retrieve, answer, check. The model fills in each step; your code decides the order.

An agent hands the order to the model. It runs in a loop: the model picks a tool, your code runs it, the result goes back, and the model decides what to do next, until it answers or a limit stops it.

Common workflow patterns cover a lot of ground before an agent is needed: a chain of prompts, a router that sends each request to the right handler, parallel calls whose results are combined, and a generate-then-check loop. Anthropic's Building effective agents describes them in detail.

Signs you need an agent

  • The number of steps isn't known up front: a research question might need one search or six.
  • Which tool comes next depends on what the last one returned.
  • The task is open-ended enough that writing every path down would mean writing the agent by hand.

What an agent costs

  • More tokens: every loop re-sends the conversation, tool definitions and results.
  • Latency you can't predict, because the number of steps varies.
  • New failure modes: loops that never finish, the wrong tool, arguments made up, an action taken that shouldn't have been.
  • Harder evaluation: two runs on the same input can take different paths, so you judge outcomes and traces, not one fixed output.

How to bound an agent

  1. Give it budgets enforced in code: a maximum number of steps, of tokens and of wall-clock time.
  2. Return tool errors to the model as tool results, so it can recover, instead of crashing the loop.
  3. Require approval before any side effect that's hard to undo, such as sending, paying or deleting.
  4. Keep a trace of every run: each call, tool, result, token count and stop reason.
  5. Compare it with the simpler version on the same questions, and keep the agent only where it wins.

Where the course goes deeper

Week 4 of the roadmap starts with workflows vs agents on Day 22, writes the agent loop by hand, bounds it, and ends by comparing the agent against plain RAG on multi-part questions. Agentic Design Patterns covers the patterns, tool design and evaluation in depth.

The 45-day path teaches this by building it. See the roadmap.

Start Week 1 free