Workflow patterns
Five patterns cover most useful systems that are not full agents.
Words on this page (2)
- agent
- : A model run in a loop that chooses its own tools and steps until the task is done.
- prompt
- : The input text you give a model, including instructions, examples and data.
The patterns
chaining: break a task into steps where each output feeds the next, with checks between. Routing: classify the input and send it to a specialized prompt or model. Parallelization: run independent subtasks at once, or run the same task several times and vote. Orchestrator-workers: a lead model splits an unpredictable task and delegates pieces to workers. Evaluator-optimizer: one model drafts, another critiques, and the loop repeats until the criteria are met.
Choosing
Chain when the task splits cleanly. Route when inputs differ in kind. Parallelize for speed or confidence. Use orchestrator-workers when subtasks are not known beforehand. Use evaluator-optimizer when you have clear criteria and revision helps. Each pattern adds calls, so add one only when it improves a measured result.
A worked example: prompt chaining
Task: write a product page. Step 1: extract key facts from the spec as bullets. Step 2: draft copy from the bullets. Step 3: check the copy against the bullets and list any claim not supported. Step 4: fix those. Each step is small and checkable, so errors are caught early.
A worked example: routing
An incoming message is classified as billing, technical or sales. Each category goes to a prompt (or model) tuned for it. A cheap model does the classification, a stronger one handles the technical cases.
Parallelization with a vote
Ask the model three times to label a message. The labels come back bug, bug, billing. The majority is bug. That costs three calls instead of one.
Invented math: if one call is right 80 percent of the time and the three runs make independent mistakes, the majority is right when at least two are right. That is 3 × 0.8 × 0.8 × 0.2 + 0.8³ = 0.384 + 0.512 = 0.896, about 90 percent. The catch is the word independent. If the model misreads a kind of message the same way every time, three votes give the same wrong answer.
How evaluator-optimizer stops
The loop needs an exit. A common version is: draft, then a critic checks the draft against written criteria, then the writer revises. It stops when every criterion passes or after three rounds, whichever comes first.
Two failures to watch for. A critic with vague criteria always finds something to improve, so the loop runs to the cap. Or the revisions flip back and forth between two versions. Confirm either one by saving every round and comparing round 2 with round 4. If they are near identical, cut the loop and fix the criteria.
When one prompt beats all of them
Before adding a pattern, run the single plain call on your test set. If it gets 90 of 100 right, a three-step chain has to beat 90 to justify three times the calls. Often the better fix is a clearer prompt, not more structure.
Common mistake
Adding patterns without measuring. Each extra call adds cost, time and failure points.
A newsroom has an assembly line: a reporter drafts, an editor checks facts, a copy editor polishes. Nobody decides the order each time. Workflow patterns are assembly lines made of model calls, for tasks where the steps are known.
Check yourself
Which pattern fits "different inputs need different handling"?
Not quite. Routing classifies the input and sends it to a specialized handler.
Which pattern needs clear criteria to work well?
Not quite. The evaluator needs something concrete to judge against.
A product page needs facts extracted, copy drafted, then checked against the facts. Which pattern is this?
Not quite. A fixed sequence where each step feeds the next is a chain.
You got 0 of 3 right.
Go deeper
- ArticleBuilding effective agentsArticle
Anthropic · Defines and illustrates all five patterns.
- Repo
Anthropic · Runnable notebooks for each pattern.
- CourseAgentic AICourse
Andrew Ng, DeepLearning.AI · Reflection, tool use, planning and multi-agent, with evals.
Spotted a mistake or something unclear? Report it on GitHub.