What is an agent? Workflows versus agents

The five workflow patterns, where true agents begin, and how to decide which one a problem deserves.

Intermediate about 3 h

The picture

  1. 01

    Single call

    simplest

  2. 02

    Workflow

    code decides the path

  3. 03

    Agent

    model decides the path

  4. 04

    Multi-agent

    several loops

  5. 05

    Add autonomy only when verified

A working definition

  • A workflow orchestrates LLM calls and tools through predefined code paths.
  • An agent lets the model dynamically decide its own steps and tool use in a loop, until it judges the task done or a limit is reached.

The difference is who controls the flow: your code, or the model. More model control means more flexibility and more ways to fail.

Five workflow patterns (cheapest first)

  1. Prompt chaining: a fixed sequence, each call consuming the previous output, with programmatic checks between steps. Draft marketing copy, then translate it.
  2. Routing: classify the input, then send it to a specialised prompt or model. Easy questions to a cheap model, hard ones to a strong one.
  3. Parallelisation: run independent subtasks at once (sectioning) or run the same task several times and vote. Review a document for security and for style simultaneously.
  4. Orchestrator-workers: one model breaks a task into subtasks that worker calls handle, then it merges the results. A code change touching an unknown number of files.
  5. Evaluator-optimiser: one call produces, another critiques, loop until good. Translation with literary nuance.
# Routing, the simplest useful pattern
def route(ticket: str) -> str:
    label = llm(f"Classify as billing, technical or other. One word.\n\n{ticket}").strip().lower()
    return {"billing": handle_billing, "technical": handle_technical}.get(label, handle_other)(ticket)

Where an agent earns its keep

Use a real agent when the number and order of steps cannot be known in advance and you have ground truth to check progress (tests pass, a record exists, a value matches). Coding assistants and research tools fit; fixed business processes mostly do not.

A decision aid

  1. Can one well-prompted call do it? Ship that.
  2. Is the path known? Use a workflow (chain, route, parallelise).
  3. Is the path unknowable but the result verifiable? Use an agent with budgets and checks.
  4. Do separate sub-problems need different tools or context? Consider several cooperating agents. Not before.

The costs of autonomy

Every extra loop iteration adds latency, spend and a chance to go wrong, and errors compound: if each step is 95 percent reliable, ten steps succeed about 60 percent of the time. Reliable agents come from small steps, verification between them and tight scope, not from bigger prompts.

Common mistakes

  • Reaching for a multi-agent framework before a single prompt has been tried.
  • Giving an agent a vague goal and no way to check progress.
  • Judging an agent from one impressive run instead of a test set.

Exercises

  1. Take an agent demo you have seen and re-implement it as a workflow. Compare reliability and cost.
  2. For three tasks from your work, say which of the four decision-aid levels each needs and why.

You are done when you can…

  • Name the five workflow patterns and give a use case for each
  • Explain the difference between a workflow and an agent in terms of who controls the flow
  • Argue for the simplest design that meets a given requirement