Contents
TL;DR
- The difference between a workflow and an agent is who decides the next step. If your code decides, it's a workflow. If the LLM decides, it's an agent.
- Start with the simplest approach. Move up to a workflow or an agent only when you need to.
- There are five common workflow patterns, and you can mix them. See the table below.
- An agent needs to see real results (such as test output) and fix its work based on them.
- Tool design matters as much as prompt design.
| Pattern | What it does | Like | When to use |
|---|---|---|---|
| Augmented LLM | An LLM with search, tools, and memory | An open-book exam | The building block of every system |
| Prompt Chaining | Splits a task into steps run in order | An assembly line with quality checks | Fixed steps in a set order |
| Routing | Sorts requests, then sends each to its own flow | A hospital front desk | Different requests need different handling |
| Parallelization | Runs several calls at once, then combines them | A health checkup; a panel of judges | Independent subtasks, or you want several opinions |
| Orchestrator-workers | A lead splits up the work on the fly | A project manager | You can't know the subtasks ahead of time |
| Evaluator-optimizer | One writes, another reviews | A writer and an editor | Clear grading rules, and feedback actually helps |
| Agent | The LLM decides every step | Telling a driver where to go | Open-ended tasks |
1. Workflows vs. Agents
Anthropic calls all LLM-based systems "agentic systems," then splits them into two kinds by who controls the flow. In a workflow, your code sets the path ahead of time, and the LLM handles only some steps. It's like cooking from a recipe. In an agent, the LLM decides the next step as it goes. It's like hiring a chef and letting them improvise.
Take refunds as an example. "Look up the order → the LLM decides if it can be refunded → refund or decline" is a workflow, because your code arranges every step. If you give the LLM three tools, get_order, get_refund_policy, and request_refund, and let it decide what to check first and whether to ask the user a follow-up question, that's an agent.
Calling tools doesn't make something an agent. If your code only lets the LLM pick one of two lookup tools, and your code still decides what happens next, it's still a workflow.
2. When to Use an Agent
Start simple, and add complexity only when you need it. Agentic systems are slower and cost more. You're paying time and money for better results.
Many tasks need only one LLM call. For example, to answer questions about documents, search for the relevant ones, then send them to the LLM with the question. To get better results, try these first:
- Retrieval: find the data for the LLM ahead of time. SQL and keyword search count. You don't need a vector database.
- In-context examples: put a few examples in the prompt to show the answer you want.
- Structured outputs: when the output format must be right, use them to lock it in.
If that's not enough, move up:
| Approach | Good for | Cost |
|---|---|---|
| One LLM call | One question gets a good answer | Can only do so much |
| Workflow | You can list the steps ahead of time | Less flexible |
| Agent | You don't know how many steps it will take | Most expensive, hardest to control |
3. About Frameworks
Frameworks help you build something fast, but they add a layer that hides what's going on underneath. It's like driving an automatic car: easy day to day, but when something breaks, you won't know where to start if you don't know how it works.
For example, a single create_agent(model, tools) call hides prompt building, tool selection, tool execution, conversation history, the loop, and error handling. If your agent keeps calling the same tool over and over, you need to know which layer is causing it.
So Anthropic suggests starting with the LLM API directly. Many patterns take only a few dozen lines of code. If you use a framework, at least understand what it does underneath.
4. Building Blocks, Workflows, and Agents
4.1 The Building Block: Augmented LLM
An LLM plus retrieval (finding data), tools (calling APIs, running code), and memory (keeping information) is the basic building block. Think of a student who can bring a textbook, a calculator, and a notebook into the exam.
Input → LLM → Output
The LLM can use:
├─ Retrieval: find data
├─ Tools: call APIs, run code
└─ Memory: keep informationOn its own, it isn't an agent yet. Put it in a fixed flow and it becomes one step of a workflow. Let it control the flow and it becomes an agent.
The LLM can't see a tool's code. It only sees the name, description, and parameters. So get_order_by_id(order_id) works much better than get_data(id). The original post also mentions MCP, a standard way to connect tools and data sources, but you don't need it.
4.2 Prompt Chaining
Split a task into steps, with one LLM call per step. Each step's output becomes the next step's input. It's like a factory assembly line, and you can add quality checks (gates) in between.
Request → LLM 1: write an outline → Gate: check the outline → LLM 2: write the full text → DoneFor example, write an outline, check it, then write the full text from it. If the outline fails the gate, stop there. If the gate can be checked with code (required sections, format), use code. It's fast and reliable. Only use an LLM when the check needs to understand meaning.
This pattern fits tasks with fixed steps in a set order. It's slower, but the results are more accurate.
4.3 Routing
First figure out what the user wants, then send them to the right flow. It's like a hospital front desk that asks about your symptoms and sends you to the right department.
User message
↓
Router: decide the category
├─ Refund: refund flow with order and refund tools
├─ Order: order lookup flow
├─ Technical: support flow with knowledge base and log search
└─ Simple question: a cheaper, smaller modelAfter routing, each path can have its own prompt and tools, and even its own model. For the router itself, an LLM with structured outputs is enough. You don't need to train a classifier:
class Route(BaseModel):
intent: Literal["refund", "order", "technical", "other"]Note that structured outputs only guarantee the format, not the right answer. A user may want a refund and the LLM may still answer order. Test accuracy separately.
4.4 Parallelization
Run several LLM calls at once, then combine the results. The original post describes two kinds. Sectioning gives different tasks to different LLMs at the same time, like getting a blood test and an X-ray at the same checkup. Voting asks the same question several times, like a panel of judges each giving a score.
Sectioning: different tasks at the same time
Code
├─ LLM A: check security
├─ LLM B: check performance
└─ LLM C: check maintainability
↓
Combine the three results
Voting: the same question several times
User post
├─ LLM A: violates rules
├─ LLM B: safe
└─ LLM C: violates rules
↓
Decide by a rule, e.g. take it down if two vote "violates"Voting doesn't have to be majority rule. For a security check, you can say "if any one flags a problem, send it to a human." You can also set a higher bar to cut down on false alarms.
But asking more times doesn't always mean more accurate. If every LLM has the same blind spot, asking ten times still gets the same thing wrong.
4.5 Orchestrator-workers
This looks like parallelization, but the subtasks aren't fixed ahead of time. A lead LLM decides them on the spot based on the request. It's like a project manager: each request is different, so the work they hand out is different too. After the workers finish, one more step combines their results into one (the original post calls this the synthesizer). This is usually one more LLM call, and the lead can do it.
Request: add a Redis cache to the API
↓
Orchestrator: decide how to split the work
├─ Worker 1: update the service layer
├─ Worker 2: handle cache invalidation
└─ Worker 3: add tests
↓
Combine: merge the three results into oneIf the request changes to "fix slow queries," the split looks completely different. The original post suggests this for coding tasks that touch many files, or search tasks that pull from many sources.
This is still a workflow, because the flow is always "split → assign → combine." If the lead can look at the results and decide to run another round, it's closer to an agent.
4.6 Evaluator-optimizer
One LLM produces the work, and another grades it and gives feedback. They go back and forth until it passes. It's like a writer sending a draft to an editor and revising until the editor approves.
Generator: write a draft
↓
Evaluator: check against the pass criteria
├─ Pass: done
├─ Hit the round limit: hand off to a human
└─ Fail: send feedback back to the generatorTo use this pattern, the grading rules must be clear, and the feedback must actually make the result better. The original post's examples are literary translation and search tasks that need to judge whether they've found enough.
The hardest part is knowing when to stop. First write down specific pass criteria (a rubric), such as "all required tests pass, and no security issues rated High or above." "The code should be good quality" is too vague. Set two stop conditions: stop when everything passes, and stop at the round limit. If it hits the limit without passing, hand it to a human. Don't count it as a success.
You can also have the evaluator only list problems, and let your code decide when to stop. This makes debugging easier.
4.7 Agent
In the five patterns above, the flow is mostly designed ahead of time. An agent hands the steering wheel to the LLM: you tell the driver where to go and let them choose the route based on traffic.
User gives a task
↓
┌→ LLM decides the next step
│ ↓
│ Run a tool, e.g. edit code, run tests
│ ↓
└─ Check the result; if not done, go back up
↓
Done, or stop at a limitIn code, it's just a loop: the LLM picks the next step, a tool runs, and the result goes back to the LLM. Repeat until it's done or stopped.
The key is letting it see real results. After editing code, the LLM may think it's done when the code doesn't even compile. Let it run tests, read the errors, and fix them, like a chef tasting the food. These real results are what the original post calls ground truth. But passing tests doesn't mean all requirements are met. An agent might even change a test to make it pass. Important logic still needs acceptance tests or a human check.
Agents fit open-ended tasks, where you can't know how many steps it will take. Coding agents and computer use are examples. The cost is high, and mistakes can build up round after round. So before going to production, add a few guardrails:
- Limit the number of rounds, the run time, and the cost
- Control tool permissions, and ask a human before important actions
- Run it in a sandbox
- Enforce required steps (permission checks, required tests) in code. The agent may do things differently each time, so reminders in the prompt aren't enough.
- Log every LLM call and tool call: what went in, what came back, and why the agent stopped
5. Combining Patterns
You can combine these patterns. For example, a code review system can use routing to sort the task, parallelization to run several checks at once, and an evaluator-optimizer to fix the result.
But you don't need all of them. Before adding complexity, check with numbers that it's worth it. Say you add an evaluator to an agent (example numbers):
| Metric | Before | With evaluator |
|---|---|---|
| Success rate | 85% | 94% |
| P95 latency | 5 s | 12 s |
| Cost per run | $0.02 | $0.06 |
The success rate went up, but it's slower and more expensive. Whether it's worth it depends on whether someone is waiting. In live customer support, the user is waiting, so 7 more seconds may not be worth it. For code analysis running in the background, no one is watching, so a few more seconds and a bit more money for a higher success rate is a good deal.
6. Real Uses: Customer Support and Coding Agents
Customer support needs both conversation and actions, like looking up orders and issuing refunds. It also has a clear measure of success: was the problem solved? The original post mentions that some companies now charge only when the problem is solved.
Coding agents can check their work automatically with tests, type checking, and real output. Anthropic's coding agent can solve real GitHub issues in SWE-bench Verified from the pull request description alone. But passing every test doesn't mean the code follows team conventions or meets business needs. A human should still review it.
7. Tool Design Matters as Much as Prompts
Spend as much effort on your tools as on your prompts.
Format affects how often the LLM makes mistakes. When writing a diff, the header has to state how many lines changed before the LLM has written them. When code is wrapped in JSON, every newline and quote has to be escaped. It's like the difference between speaking and tapping out Morse code: the content is the same, but the second one leads to more mistakes. Stick to formats the LLM has seen a lot, like plain code or Markdown.
When designing a tool, imagine a new teammate seeing it for the first time:
- Can they tell what it does from the name?
- Does the description say when to use it, with an example?
- Can they tell two similar tools apart?
- When it fails, is the error message clear?
After writing it, run real examples through the LLM, see where it uses the tool wrong, and fix it.
An example from the original post: their file tool first accepted relative paths, and the agent edited the wrong files after it changed folders. Once the tool required absolute paths, the problem went away. This is called poka-yoke (mistake-proofing). It's like USB-C: it fits either way, so no one needs to be reminded which side is up. Instead of adding reminders to the prompt, change the design so the mistake can't happen.
Two more examples of my own (not from the original post):
- Make parameters clear:
search_logs(time_range: str)will get inputs likelast hourandyesterdayin all kinds of formats. Change it to twodatetimeparameters,start_timeandend_time, and there's nothing to guess. - A tool like "submit order" can be limited to one call per task. That's different from idempotency (sending the same request several times has the same result as sending it once). The first stops the agent from calling it twice. The second stops the system from sending it twice on retries. You need both.
Wrap-Up
Anthropic sums up its principles for building agents in three points:
- Simplicity: keep it as simple as you can. You don't have to use every feature a framework offers.
- Transparency: let people see what the agent planned, which tools it used, and why it stopped.
- Design the ACI (agent-computer interface) carefully: a tool's name, description, parameters, and return value all affect whether the LLM uses it correctly.
More useful than memorizing five patterns is knowing how much freedom to give the LLM for a task. If a fixed flow can do it, write code. If one LLM call is enough, don't add a workflow. Use an agent only when the task needs adjusting along the way.
From a backend point of view, the usual engineering rules still apply: API design, error handling, monitoring, and reliability all still matter. The difference is that part of the system's decisions now belong to an LLM, and an LLM won't always give the same result. A good split is to let the LLM understand and decide, and keep control and checks in code.