Guide

An agent is a model-directed loop: the model chooses tools and next steps until a goal is met or a budget runs out. A workflow is a path you defined — prompt chaining, a router, a fixed graph — where the model fills in steps but does not invent the control flow.

That distinction is the most useful one in AI engineering. Most production "agents" that work well are mostly workflows with a little autonomy at the edges. Full open-ended agents shine when the path cannot be scripted: research, debugging, multi-step ops. They also burn tokens, drift from the goal and fail in ways that are hard to replay unless you design for it.

Start with the simplest thing that ships. Add autonomy only where branching cannot be enumerated. A surprising fraction of roadmap items labeled "build an agent" collapse into a router plus two chains once you write down the real user journeys. That is a win.

Concept

Chip Huyen frames agents as systems that perceive, plan and act over multiple steps with external tools. The hard parts are not the loop boilerplate. They are tool reliability, context growth and knowing when to stop.

WorkflowAgent
Control flowCode or graph you wroteModel chooses the next step
PredictabilityHighLower
Cost per taskBounded and easier to forecastCan spike 10 to 100×
Best forKnown stages, compliance, high volumeOpen-ended goals, exploration
Failure modeBrittle when a stage is wrongLoops, tool misuse, cost blowups

If 80% of requests follow three paths, encode those paths as a workflow and reserve an agent for the long tail.

Concepts in this section

Read them in order. Each one builds on the one before.

StepConceptWhat it answers
1Workflow patternsWhich fixed shapes cover most products?
2The ReAct loopHow does an open loop choose the next tool?
3Agent planningPlan first, or pick the next action as you go?
4Autonomy and stoppingHow much freedom, and what makes it stop?

A support ticket, worked out

"Where is my order?" at high volume.

Wrong first move: an open-ended agent with run_sql, web browse and email send. Cost per ticket explodes. A wrong refund is one bad trajectory away.

Better shape:

  1. Router classifies: tracking, cancel, billing or other.
  2. Tracking workflow forces get_order, then a template answer with status and ETA. Escalate if not_found.
  3. Cancel workflow runs get_order, a policy check in code, optional human approve, then cancel_order.
  4. Other is a small agent with help-doc search only, a 4-step cap and no write tools.

Most tickets never pay for an open loop.

Common mistakes

  • Autonomy theater. The user journeys were enumerable. You built a loop anyway.
  • No budgets. Step, token, dollar and wall-clock caps are part of the design.
  • Debugging from the final paragraph. You need the trajectory: tools, observations, stop reason.

Key takeaways

  • Prefer workflows. Add agent loops only where paths cannot be enumerated.
  • Compose the five workflow patterns before you invent a framework.
  • ReAct is reason → act → observe, with hard caps.
  • Plan-then-execute when you need approval. Interleave when the environment is uncertain.
  • Recover with structured errors and external verification. Escalate after repeated failure.

Further learning

Building effective agents (Anthropic)Discover how Anthropic approaches the development of reliable AI agents. Learn about our research on agent capabilities, safety considerations, and technical framework for building trustworthy AI.anthropic.com ReAct: Synergizing Reasoning and Acting in Language ModelsWhile large language models (LLMs) have demonstrated impressive capabilities across tasks in language understanding and interactive decision making, their abilities for reasoning (e.g. chain-of-thought prompting) and …arXiv.org Agents (Chip Huyen)Intelligent agents are considered by many to be the ultimate goal of AI. The classic book by Stuart Russell and Peter Norvig, Artificial Intelligence: A Modern Approach (Prentice Hall, 1995), defines the field of AI r…Chip Huyen
How We Build Effective Agents: Barry Zhang, AnthropicAI Engineer

Start with workflow patterns.