Choose a Pattern: Pick by Failure, Not by Name
Read this after the first six chapters.
This page does not explain how a chatbot becomes an agent; Start Here does that. This page only routes failures to patterns.
First Decide Who Controls the Next Step
flowchart TD
A["Task arrives"] --> B{"Can one model call solve it?"}
B -->|yes| ONE["Stay with a plain chatbot"]
B -->|no| C{"Are the steps known upfront?"}
C -->|yes| WF["Workflow: code controls the path"]
C -->|no| D{"Does the next step depend on observations?"}
D -->|yes| LOOP["Agent loop: model proposes, Python executes and limits"]
D -->|no| PLAN["Planning / Search: design or search the path first"]
LOOP --> E{"Is one agent overloaded?"}
E -->|yes| MA["Multi-Agent: split roles or transfer ownership"]
E -->|no| RISK["Add reliability, retrieval, safety, and eval as needed"]
The map is about control:
- Workflow: code fixes the next step.
- Agent Loop: the model chooses the next action from state.
- Planning / Search: generate or search a path before executing.
- Multi-Agent: stop making one agent own every responsibility.
Symptom Table
| Failure you see | Start with | Why |
|---|---|---|
| A large task drifts | Prompt Chaining | Split one big task into controlled steps. |
| Different inputs need different paths | Routing | Classify first, then run the right workflow. |
| Tool-call count is unknown | ReAct | Let observations decide the next action. |
| Answers sound plausible but are often wrong | Maker-Checker | Generate first, then critique. |
| You want several candidates to calibrate each other | Voting | Sample multiple answers and aggregate. |
| Long answers need claim-level fact checks | CoVe | Extract claims, then verify them one by one. |
| One retrieval pass misses evidence | Retrieval Loop | Read evidence, improve the query, search again. |
| Answers need citations and an evidence ledger | Agentic RAG | Let the agent decide what to retrieve and whether evidence is enough. |
| Failure lessons should affect the next attempt | Reflexion | Write task reflections back into memory. |
| A long report needs section-wise research | STORM | Gather by perspective or section, then synthesize. |
| The task needs an explicit plan | Plan & Solve | Plan first, then execute. |
| New information can invalidate the plan | Planner-Executor-Replanner | Make replanning explicit and budgeted. |
| Tool calls can run in parallel or depend on each other | ReWOO / LLM Compiler | Lay out tool steps before observing or executing. |
| There are many possible paths to try | LATS | Treat trajectories as a search tree. |
| The model needs to choose a reasoning strategy | Self-Discovery | Select reasoning modules before solving. |
| One agent owns too much work | Manager-Worker | A manager assigns owned subtasks. |
| A specialist agent should be callable as a capability | Agents-as-Tools | Put the specialist behind a tool boundary. |
| Ownership should change mid-conversation | Handoff | Transfer the task to a better owner. |
| Several roles need to challenge each other | Group Chat | Put agents in a governed discussion. |
| A long task stalls or repeats delegation | Magentic Orchestration | Use a task ledger and stall detection. |
| Tools affect the real world | Policy, Guardrails, HITL | Limit permissions and require approval for risky actions. |
| You cannot tell whether a change helped | Eval Harness | Run fixed tasks as regression checks. |
Cost Rule
Every pattern buys something and charges something.
| Pattern family | Buys | Charges |
|---|---|---|
| Workflow | predictability and testability | more fixed steps |
| Agent Loop | adaptation from observations | latency, cost, loop failures |
| Reliability | more trust | extra model calls and validators |
| Retrieval & Memory | external knowledge and experience | source quality and context management |
| Planning & Search | longer task horizon | state, budget, search space |
| Multi-Agent | role separation and parallelism | coordination and debugging cost |
| Safety & Evaluation | deployability and regression checks | rules, logs, test sets |
If a simpler structure solves the failure, stop there.