Agent patterns

Agents vs. workflows

Also called: agent vs workflow

A workflow follows a path you designed in advance; an agent decides its own path at run time by calling tools in a loop toward a goal. Knowing which one you actually need is the first context-engineering decision.

James Phoenix
Understanding Data Updated July 3, 2026

Most systems people call "agents" are really workflows, and that is usually fine. The distinction is not marketing, it changes how you build, evaluate, and pay for the thing.

A workflow is a fixed path: you decide the steps in advance and the model fills in each one. Classify a ticket, then route it. Draft copy, then translate it. An agent is different: give a model tools and run it in a loop, and it decides which step comes next based on what it has learned so far. In a workflow you design the path. In an agent you design the environment and the agent finds the path. Anthropic's public write-up, Building Effective Agents, is the clearest taxonomy of these patterns and worth reading alongside this entry.

An agent is a loop with tools

The whole idea fits in a few lines. Give the model a tool, let it call the tool, feed the result back, and keep going until it is done. The Vercel AI SDK runs that loop for you when you pass tools and a stop condition:

TypeScript
import { generateText, tool, stepCountIs } from 'ai'
import { openai } from '@ai-sdk/openai'
import { z } from 'zod'

const getWeather = tool({
  description: 'Get the current weather for a city',
  inputSchema: z.object({ city: z.string() }),
  execute: async ({ city }) => ({ city, tempC: 21 }),
})

const { text, steps } = await generateText({
  model: openai('gpt-5-mini'),
  tools: { getWeather },
  stopWhen: stepCountIs(5),
  prompt: 'What is the weather in Lisbon? Use the tool, then answer in one sentence.',
})

The model asks for the tool, the SDK runs it, the result comes back, and the model answers. steps records each hop so you can see what it did.

Which one do you need?

  • Start with a workflow. If the path is predictable, a fixed pipeline is cheaper, faster, and easier to trust.
  • Reach for an agent only when the solution path genuinely cannot be known in advance: open-ended research, multi-tool support, messy edge cases.
  • Mind the cost. Every loop step is another model call. An agent that takes five steps costs several times what a two-step workflow costs.
Tip
The honest rule of thumb: build far more workflows than agents. When you do need an agent, the quality of its tools and the tightness of its loop matter more than any clever prompt.

Related terms

Engineering context for real systems?

Getting the right information into the window at the right time is most of the job. If you want that thinking applied to your product, that is what I do.

See how I can help