Agents and tools
Workflow patterns
Chaining, routing, parallelization, orchestrator-workers and evaluator-optimizer cover most production systems before you need an open agent loop.
Most production "agents" that work well are workflows: paths you defined, where the model fills in steps but does not invent the control flow. Anthropic's catalog of simple, composable patterns covers most of those paths. Combine them. Do not invent a new abstraction for each feature.
Concept
Before you start: a workflow is a graph you wrote. An agent is a loop where the model chooses the next step. These patterns stay on the workflow side.
The big idea
If 80% of requests follow three paths, encode those paths. Keep the model where inputs vary. Keep code in charge where mistakes are expensive.
Prompt chaining. Split a task into fixed stages. Output of stage N is input to stage N+1. Example: extract fields → validate → draft reply → tone-check. Each stage can use a smaller, cheaper model. Failures localize: you know which stage broke.
Routing. A classifier (model or rules) sends the input to a specialized prompt, model or sub-workflow. "Billing question" versus "technical outage" versus "cancel account." Routing keeps context and tools small per lane.
Parallelization has two flavors:
- Sectioning — independent subtasks run at once (summarize three docs), then merge.
- Voting — the same task several times, or with different models; take majority or a judge. Buys reliability at 2 to 5× cost.
Orchestrator–workers. One model plans and delegates subtasks to workers (often other model calls with narrower tools). The orchestrator synthesizes. This is the seed of multi-agent systems. Start with workers as plain functions before you spawn full agents.
Evaluator–optimizer. One model drafts; another critiques against a rubric; repeat until pass or max rounds. Works when quality criteria are clear (style guide, schema validity, "must cite sources"). Pair with code checks where you can. Do not use an LLM judge for "is this valid JSON?"
Walking through an internal finance bot
- Route by intent: policy, invoice status or forecast.
- Chain for policy: retrieve → quote → answer with citations.
- Orchestrator–workers for forecast: one worker pulls metrics, one pulls the assumptions doc, the orchestrator writes the narrative.
- Evaluator checks that every number has a source id.
- Escalate to a thin agent only when the question matches no known intent, and cap it.
A content pipeline in the source: router → (research chain or rewrite chain) → evaluator that checks "claim has citation." Average 2.1 model calls on the happy path, 4.4 when the evaluator rejects once. Cheaper and stabler than one agent that "figures it out."
Frameworks are fine when they implement these shapes. They hurt when they force every problem into a graph of autonomous peers.
Common mistakes
- One open loop for every intent. You pay agent cost on journeys you can draw by hand.
- An LLM judge for valid JSON. Use a parser.
- Spawning worker agents when a function plus a narrow prompt would do.
Check yourself
- Billing, outage and cancel each need different tools. Which pattern first? Routing, so each lane stays small.
- Why chain extract → validate → draft instead of one call? Failures localize, and cheap models can do the early stages.
Key takeaways
- Compose chaining, routing, parallelization, orchestrator–workers and evaluator–optimizer before you invent a framework.
- Route the common paths. Reserve an open loop for the tail.
- Use code checks for schemas and JSON. Use a model judge for style and citations.
- Start workers as functions. Promote them to agents only when they need their own tools and loop.
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
When the path cannot be enumerated, use the ReAct loop.
Related
Agents and agent architectures
Workflows vs agents, the core patterns, ReAct loops, planning and knowing when to stop.
Tool use and function calling
Letting models call your code: tool schemas, the tool loop, and designing tools models use well.
Multi-agent systems
When multiple agents beat one: orchestrator-subagent designs, context isolation and the cost of coordination.