Agent Pattern Catalog and Diagram Gallery
One page to find a pattern, draw it, document it and practice it, one week at a time.
A pattern is a reusable solution with known trade-offs. Start from the need, pick the simplest pattern that meets it, add controls such as state, retrieval or approval only where required, then draw and document the result. The gallery below shows common shapes; each is a starting point to test, not a guarantee.
What you will learn: a catalog of agent patterns, how to choose and combine them, a diagram gallery and templates, a design document template and a one-pattern-a-week study plan.
Prerequisites: The Agent Loop: Observe, Reason, Plan, Act, Reflect. The other architecture pages add detail.
Anatomy of a catalog entry
Every pattern worth reusing answers the same questions. Use them to read the table below and any pattern you meet elsewhere.
- Problem: which need does it meet, in what setting?
- Control: does code or the model decide the next step?
- Cost: how many calls, how much waiting and how much to operate?
- Failure: how does it go wrong, and how would you notice?
- Controls: which limits, checks and approvals does it need?
- Test: which case would prove it is working, or not?
Pattern catalog
| Pattern | Use when | Watch for | Learn more |
|---|---|---|---|
| Single model call | One transformation or classification | No facts beyond the input | Agent Tools, Function Calling and Tool Registries |
| Prompt chain | Fixed stages with checks between | Errors passing downstream | Orchestration |
| Router | Distinct request types | Misrouting | Single-Agent, Router and Retrieval Patterns |
| Retrieval | Answers need documents | Weak or forbidden evidence | RAG Explained and Agentic RAG |
| Tool-calling agent | Next step depends on results | Loops and wrong actions | ReAct Agents: Reasoning and Acting |
| Plan and execute | Longer tasks that benefit from a plan | Stale plans | Plan-and-Execute and Dynamic Planning |
| Parallel workers | Independent parts | Cost and merging conflicts | Topologies, Specialist Teams and Debate |
| Evaluator and improver | A clear quality test exists | Endless revision | Agent Decisions: Confidence, Stopping, Loops and Budgets |
| Supervisor and workers | Specialists with separate tools | Coordination overhead | Supervisor and Orchestrator-Worker Patterns |
| Durable workflow | Waiting and recovery | Unsafe repeated effects | Stateful and Long-Running Agent Architecture |
| Approval gate | Consequential actions | Reviewer overload | Human-in-the-Loop and Approval Gates |
| Event-driven agent | Work starts from events | Duplicates and storms | Event-Driven and Background Agents |
Five questions before picking
- Can ordinary code do it? If rules are known and inputs structured, write the code.
- Is one model call enough? Try it on real examples before adding anything.
- What is missing: knowledge, live data, the ability to act or the ability to plan?
- What could go wrong if each step misbehaved, and can it be undone?
- Who will operate it at night and after the people who built it move on?
The answers usually narrow the table to two candidates. Build the smaller one first and keep its test cases to judge the other.
Choose by need
This small function encodes the idea of adding only what a requirement justifies.
"""Suggest the simplest pattern that satisfies stated needs."""
def suggest(needs):
plan = []
if needs.get("steps_known"):
plan.append("fixed workflow")
elif needs.get("next_step_depends_on_results"):
plan.append("single agent with tools")
else:
plan.append("single model call")
if needs.get("distinct_request_types"):
plan.insert(0, "router")
if needs.get("private_knowledge"):
plan.append("retrieval")
if needs.get("longer_than_one_request"):
plan.append("durable state")
if needs.get("consequential_actions"):
plan.append("approval gate")
if needs.get("separate_permissions") and needs.get("independent_parts"):
plan.append("split into multiple agents")
return " + ".join(plan)
examples = {
"classify an email": {},
"nightly invoice matching": {"steps_known": True,
"longer_than_one_request": True},
"policy questions": {"private_knowledge": True},
"support desk": {"next_step_depends_on_results": True,
"distinct_request_types": True,
"private_knowledge": True,
"consequential_actions": True},
"vendor onboarding": {"next_step_depends_on_results": True,
"longer_than_one_request": True,
"consequential_actions": True,
"separate_permissions": True,
"independent_parts": True},
}
for name, needs in examples.items():
print(f"{name}:\n {suggest(needs)}")
Output:
classify an email:
single model call
nightly invoice matching:
fixed workflow + durable state
policy questions:
single model call + retrieval
support desk:
router + single agent with tools + retrieval + approval gate
vendor onboarding:
single agent with tools + durable state + approval gate + split into multiple agents
Classification needs nothing more than a call, nightly matching becomes a durable workflow and the support desk collects three additions around its agent. Vendor onboarding suggests splitting because it declares both separate permissions and independent parts. The function is a conversation starter with deliberately crude rules; real choices need evaluation results, constraints and judgment.
Who controls the flow?
The quickest way to compare patterns is to ask how much freedom the model has. More freedom handles more variety and needs stronger limits and testing.
| Control | Examples | Test emphasis |
|---|---|---|
| Code decides every step | Single call, prompt chain, durable workflow | Each step's output and checks |
| Model picks among fixed routes | Router | Route accuracy and fallback |
| Model picks steps within limits | Tool-calling agent, plan and execute | Task outcomes, stop rules, forbidden actions |
| Models delegate to models | Supervisor and workers | Handoffs, permissions, total cost |
Approval gates, state and retrieval are additions that can sit on any row. Move down a row only when cases from your own work show that the row above cannot handle them.
Diagram gallery
Prompt chain
Router
Tool-calling agent
Parallel workers
Evaluator and improver
Supervisor and workers
Event-driven agent
Published descriptions use somewhat different names for these shapes. When you discuss one, describe what controls the flow, since that matters more than the label.
Anti-patterns to recognize
| Anti-pattern | Symptom | Better shape |
|---|---|---|
| Everything agent | One prompt, dozens of tools, unpredictable results | Router with small paths |
| Committee | Agents repeat and approve one another | One agent with a code-based check |
| Endless polisher | Revision continues without measurable gain | Fixed criteria and a round limit |
| Paper gate | Approval requested in text but not enforced | Execution service verifies approval |
| Amnesiac worker | Restart repeats actions | Durable state and operation keys |
| Shared master key | Every agent can do everything | Separate, narrow identities |
| Hidden fallback | Quality drops silently when a service fails | Visible degraded mode |
An anti-pattern often begins as a reasonable shortcut. Reviews and traces help you notice when it has outlived its purpose.
Diagram templates
Draw a few views, each answering one question. The C4 model suggests levels of context, containers, components and code; for most agent designs the first two plus a sequence view are enough.
| View | Answers | Include |
|---|---|---|
| Context | Who and what interacts with the system? | Users, external systems, trust edges |
| Container | What runs and stores data? | Services, queues, stores, gateways |
| Sequence | What happens in one task? | Calls, approvals, failures |
| State | How does a task progress? | Statuses and allowed moves |
| Data flow | Where does sensitive data go? | Classes, boundaries, retention |
- Label every arrow with what moves.
- Mark trust boundaries and outside content.
- Show where policy, approval and logging happen.
- Do not rely on color alone, and describe the diagram in text.
- Date it and name its maintainer.
Keeping diagrams as text makes changes reviewable. This program checks one list of nodes and edges, then prints it in Mermaid flowchart syntax.
"""Generate a Mermaid diagram from one list, and check the list first."""
NODES = {"user": "User", "api": "API", "agent": "Agent runtime",
"policy": "Policy check", "tool": "Business tool",
"audit": "Audit log"}
EDGES = [("user", "api", "request"), ("api", "agent", "task"),
("agent", "policy", "proposed action"),
("policy", "tool", "allowed action"),
("policy", "audit", "decision")]
def problems():
found = [f"unknown node in {a} -> {b}" for a, b, _ in EDGES
if a not in NODES or b not in NODES]
used = {n for a, b, _ in EDGES for n in (a, b)}
found += [f"unconnected node {n}" for n in NODES if n not in used]
if any(a == "agent" and b == "tool" for a, b, _ in EDGES):
found.append("agent reaches the tool without a policy check")
return found
assert not problems(), problems()
print("flowchart LR")
for key, label in NODES.items():
print(f' {key}["{label}"]')
for source, target, label in EDGES:
print(f" {source} -->|{label}| {target}")
EDGES.append(("agent", "tool", "shortcut"))
print("after adding a shortcut:", problems())
Output:
flowchart LR
user["User"]
api["API"]
agent["Agent runtime"]
policy["Policy check"]
tool["Business tool"]
audit["Audit log"]
user -->|request| api
api -->|task| agent
agent -->|proposed action| policy
policy -->|allowed action| tool
policy -->|decision| audit
after adding a shortcut: ['agent reaches the tool without a policy check']
The added shortcut from agent to tool is reported. The check catches only what you declare and the rules you write; verify the real system separately.
A worked sequence view
A sequence view is easy to write as numbered steps, which also serves readers who cannot see a picture. Here is one for a refund request.
- The signed-in user asks for a refund on an order.
- The router sends the request to the refunds path.
- The agent reads the order and the policy, using the user's permissions.
- It proposes an amount with the evidence.
- The policy check requires approval because the amount exceeds a limit.
- An authorized reviewer approves the exact amount.
- The execution service rechecks the order and pays once, using an operation key.
- The agent confirms the recorded result, or reports that the outcome is unknown.
Add the failure branches beside it: order not found, reviewer rejects, order changed, payment timed out. Those branches become evaluation cases.
Design document template
| Section | Content |
|---|---|
| 1. Summary | Problem, users, proposed pattern, decision needed |
| 2. Goals and non-goals | Measurable success and what is excluded |
| 3. Task examples | Normal, edge, refusal and hostile cases |
| 4. Architecture | Context and container diagrams; pattern choice and alternatives |
| 5. Model and context | Models, instructions, retrieval, memory |
| 6. Tools | Contract, permission, risk level, owner |
| 7. State and failure | Storage, retries, recovery, stop rules |
| 8. Safety and privacy | Threats, data classes, approvals, retention |
| 9. Evaluation | Cases, measures, thresholds |
| 10. Operations | Targets, tracing, alerts, cost, rollback, support |
| 11. Rollout | Stages, exit criteria, fallback |
| 12. Open questions | Risks, assumptions, owners and dates |
Delete sections that truly do not apply and say why. Record significant choices separately, as in Architecture Decision Records and Reviews.
Review a design document quickly
| Check | Warning sign |
|---|---|
| Success measure | Only words such as "helpful" or "smart" |
| Alternatives | No simpler option considered |
| Tool table | No owner or risk level |
| Failure section | "The model will handle it" |
| Evaluation | A demonstration instead of cases and thresholds |
| Rollout | No way back |
Combine with care
Patterns stack: router, then retrieval, then an agent with an approval gate. Each addition brings a new failure and a new test. Add one at a time, compare with the previous version on the same cases and remove it if the gain does not justify the cost.
One pattern every week
A twelve-week practice plan. Spend a few hours each week: draw the pattern, build a tiny version with a scripted model, break it on purpose and write one paragraph on when you would not use it.
| Week | Pattern | Break it by |
|---|---|---|
| 1 | Single model call | Sending ambiguous input |
| 2 | Prompt chain | Corrupting the first stage |
| 3 | Router | Mixing two request types |
| 4 | Retrieval | Removing the key document |
| 5 | Tool-calling agent | Returning errors from a tool |
| 6 | Plan and execute | Changing facts mid-plan |
| 7 | Evaluator and improver | Making the test impossible |
| 8 | Parallel workers | Delaying one worker |
| 9 | Durable workflow | Crashing between effect and save |
| 10 | Approval gate | Changing the action after approval |
| 11 | Event-driven agent | Delivering an event twice |
| 12 | Supervisor and workers | Asking a worker to exceed its rights |
Keep each week's diagram, code, failing case and notes together. After twelve weeks you have a personal catalog backed by experience. Multi-Agent Systems continues from there.
How to know a week was worthwhile
At the end of each week, answer three questions in writing. Could you draw the pattern from memory, including its failure path? Did your deliberately broken case get detected by code and not only by your own reading? Can you name a task where a simpler pattern would be better? If any answer is no, repeat the week with a smaller example. Share the notes with a colleague and ask them to find an input you did not try. Later, replace the scripted model with a real one, keep the same cases and run each several times to see how much behavior varies.
Add your own entry
When your team solves the same problem twice, write it down: name, problem, when to use, when not to, diagram, controls, failure modes, tests and a working example. Mark whether it is used in production, tried in a pilot or only proposed. Review entries periodically and retire those that mislead.
Using the catalog in a team
Bring the table to a design discussion and ask each person to name the pattern they would choose and the failure they fear most. Differences reveal hidden assumptions about users, data or risk. Agree on a first version, the cases that would show it is insufficient and the date you will look at the results. Record the choice and link the entry, the diagram and the tests together, so that the next team can start from your evidence instead of from a blank page.
How a design usually evolves
Many useful systems begin as one call with a good prompt and a person checking the result. Retrieval is added when answers need your documents, a read tool when facts change often and a write tool behind approval once the proposals prove dependable. Durable state arrives when waiting appears, and a second agent only when permissions or context truly need separating. Movement also goes the other way: after traces show a predictable path, replace the agent's choices on that path with plain code. Keep the test cases through every change, because they are what lets you simplify with confidence.
Common mistakes
- Choosing a pattern because it is fashionable.
- Stacking several at once.
- Diagrams without trust boundaries or failure paths.
- Documents that describe only the successful route.
- Copying a pattern without tests.
- Never removing a part that adds nothing.
Checklist
- The need is stated before the pattern.
- A simpler alternative was compared.
- Controls sit on action and data paths.
- Diagrams show boundaries, failures and a text description.
- The design document covers evaluation and operations.
- Each added part has a test and a reason.
Frequently asked questions
Which pattern should a beginner learn first?
A single model call, then one tool call inside a bounded loop. Most other patterns build on those ideas.
Are these official standard patterns?
No single standard defines them. Names and boundaries differ between authors and tools, so describe the behavior you mean.
May I reuse these diagrams in my documents?
Use them as ideas and redraw them for your system. Check the site's terms of use before copying content.
When is a multi-agent pattern justified?
When parts need different permissions or context, or can run independently, and measured results beat a simpler design.
References and further reading
Next steps
Architecture and Blueprints
Return to the architecture hub.
Single-Agent vs Multi-Agent Systems
Decide how many agents.
Multi-Agent Systems
Explore cooperating agents.