Skip to content

ColtMercer/agentic-design-patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

🤖 Agentic Design Patterns

A consumable reference distilled from Agentic Design Patterns by Antonio Gulli (424 pages).
Use the README to orient yourself. Click into any pattern for the full cheat sheet.


📖 About the Book

Agentic Design Patterns is a hands-on handbook for engineers and architects building autonomous AI systems. It distills 21 reusable patterns — from prompt pipelines to multi-agent coordination to safety guardrails — and pairs each with runnable code examples in LangChain/LangGraph, CrewAI, and Google ADK.

The book's thesis: raw LLM calls are unreliable at scale. Patterns are how you make agents predictable, maintainable, and production-ready.


🤖 What Makes an AI System an Agent?

An agent is a goal-oriented software entity that perceives its environment, reasons about objectives, executes actions via tools or APIs, and adapts from feedback.

┌─────────────────────────────────────────────────────────────────────┐
│                      THE 5-STEP AGENT LOOP                          │
│                                                                     │
│   ┌──────────┐    ┌──────────────────┐    ┌─────────┐              │
│   │  PERCEIVE │───▶│ GOAL ASSESSMENT  │───▶│  PLAN   │              │
│   │          │    │                  │    │         │              │
│   │ Ingest   │    │ Interpret        │    │ Generate│              │
│   │ inputs & │    │ objectives &     │    │ ordered │              │
│   │ API state│    │ constraints      │    │ steps   │              │
│   └──────────┘    └──────────────────┘    └────┬────┘              │
│                                                │                   │
│   ┌──────────────────────┐    ┌───────────────▼──────────┐        │
│   │   OBSERVE & LEARN    │◀───│    ACT / EXECUTE         │        │
│   │                      │    │                          │        │
│   │ Update memory/state  │    │ Call tools, services,    │        │
│   │ Reflect & adapt      │    │ or perform actions       │        │
│   └──────────────────────┘    └──────────────────────────┘        │
└─────────────────────────────────────────────────────────────────────┘

🗺️ Pattern Relationships

                        ┌─────────────────────────────────────────────┐
                        │           FOUNDATION PATTERNS               │
                        │                                             │
                        │  Prompt Chaining → Routing → Planning       │
                        │         ↕              ↕                    │
                        │  Parallelization   Reflection               │
                        │         ↕              ↕                    │
                        │    Multi-Agent  ←  Tool Use                 │
                        └──────────────┬──────────────────────────────┘
                                       │
              ┌───────────────────────▼────────────────────────┐
              │                 STATE LAYER                     │
              │  Memory Management · MCP · Learning · Goals     │
              └───────────────────────┬────────────────────────┘
                                      │
              ┌───────────────────────▼────────────────────────┐
              │               RELIABILITY LAYER                 │
              │   Exception Handling · Human-in-Loop · RAG      │
              └───────────────────────┬────────────────────────┘
                                      │
              ┌───────────────────────▼────────────────────────┐
              │                ADVANCED LAYER                   │
              │  A2A · Resources · Reasoning · Guardrails       │
              │     Evaluation · Prioritization · Exploration   │
              └────────────────────────────────────────────────┘

⚡ Quick Reference

# Pattern Part One-Liner
1 Prompt Chaining Core Chain LLM calls so each output feeds the next
2 Routing Core Dispatch requests to the best specialist model or agent
3 Parallelization Core Run independent subtasks concurrently and merge results
4 Reflection Core Let the agent critique and iteratively improve its outputs
5 Tool Use Core Give the agent deterministic external capabilities
6 Planning Core Generate an explicit, executable plan before acting
7 Multi-Agent Collaboration Core Compose specialized agents to solve complex tasks
8 Memory Management State Manage short-term context and long-term persistence
9 Learning & Adaptation State Continuously improve from interaction data and feedback
10 Model Context Protocol (MCP) State Standardize how LLMs discover and call external resources
11 Goal Setting & Monitoring State Define, track, and revise agent objectives dynamically
12 Exception Handling Reliability Detect failures and restore stable operation
13 Human-in-the-Loop Reliability Gate high-risk decisions on targeted human judgment
14 Knowledge Retrieval (RAG) Reliability Ground generation in retrieved, up-to-date knowledge
15 Inter-Agent Comms (A2A) Advanced Standardize messaging between heterogeneous agents
16 Resource Optimization Advanced Adapt to cost, latency, and compute constraints
17 Reasoning Techniques Advanced CoT, ToT, self-consistency for multi-step reasoning
18 Guardrails / Safety Advanced Layered safety architecture for production agents
19 Evaluation & Monitoring Advanced Measure correctness, cost, and safety continuously
20 Prioritization Advanced Decide what the agent works on first
21 Exploration & Discovery Advanced Actively seek new information while managing risk

🎯 Patterns by Use Case

Not sure which pattern to reach for? Start here.

🏗️ "I'm building something new"

Goal Start With
Simple multi-step task Prompt Chaining
Different requests need different handling Routing
Big task that needs a blueprint Planning
Need external data or API calls Tool Use
Want to analyze multiple documents fast Parallelization

🔒 "I'm making it production-ready"

Goal Start With
Handle API failures gracefully Exception Handling
Add safety filters Guardrails / Safety
Know if it's working Evaluation & Monitoring
Escalate edge cases to a human Human-in-the-Loop
Reduce hallucinations with real data RAG

🧠 "I'm improving quality"

Goal Start With
Outputs aren't good enough Reflection
Need better multi-step reasoning Reasoning Techniques
Agent should remember context Memory Management
System should improve over time Learning & Adaptation
Multiple specialists would do better Multi-Agent Collaboration

💰 "I'm optimizing for cost/scale"

Goal Start With
Reduce latency or API spend Resource Optimization
Triage what gets compute first Prioritization
Share tools across multiple agents MCP
Connect agents from different systems A2A
Track long-running goals Goal Setting & Monitoring

🚀 "I'm going advanced"

Goal Start With
Agent needs to find unknowns Exploration & Discovery
Connect to third-party agents A2A
Balance cost vs. accuracy dynamically Resource Optimization
Agent must work across frameworks MCP

📦 Part One: Core Patterns (Ch. 1–7)

Foundational patterns every agentic system needs.

Pattern Summary
1 Prompt Chaining Pipeline where each LLM output is the next step's input
2 Routing Smart dispatch to the right specialist
3 Parallelization Concurrent execution with deterministic merge
4 Reflection Producer/Critic loop for iterative self-improvement
5 Tool Use Ground agents in external APIs, search, databases
6 Planning Generate structured plans, then execute and replan
7 Multi-Agent Orchestrate specialized agents with defined roles

🧠 Part Two: State & Learning (Ch. 8–11)

Patterns for persistence, adaptation, and goal tracking.

Pattern Summary
8 Memory Management Short-term context + long-term vector storage
9 Learning & Adaptation Fine-tuning, RL, and feedback loops
10 MCP Open protocol for tool/resource interoperability
11 Goal Setting Track and revise objectives at runtime

🛡️ Part Three: Reliability (Ch. 12–14)

Making agents resilient and trustworthy.

Pattern Summary
12 Exception Handling Retries, fallbacks, rollbacks, escalation
13 Human-in-the-Loop Gating, review UIs, correction feedback
14 RAG Retrieval stack, chunking, vector search, citations

🚀 Part Four: Advanced Patterns (Ch. 15–21)

Scaling, safety, and optimization for production.

Pattern Summary
15 A2A Open protocol for heterogeneous agent ecosystems
16 Resource Optimization Cost/latency-adaptive routing and execution
17 Reasoning Techniques CoT, ToT, self-consistency, verifier agents
18 Guardrails Defense-in-depth safety architecture
19 Evaluation & Monitoring Model CI, telemetry, regression detection
20 Prioritization Schedulers, preemption, budget caps
21 Exploration & Discovery Curiosity-driven agents with safe exploration

📎 Appendices


🔑 Key Takeaways

  1. Patterns > prompts — raw LLM calls break at scale; reusable patterns give you reliability, debuggability, and maintainability
  2. Separate concerns — always decouple Planning from Execution, Producer from Critic, Routing from Implementation
  3. Treat memory explicitly — context window management, long-term storage, and retrieval are engineering problems, not LLM magic
  4. Tools are the bridge to reality — ground your agents in deterministic tool calls, not model imagination
  5. Safety is layered — input sanitization + policy models + output filters + human review; no single guardrail is enough
  6. Evaluate like production software — offline test suites, live telemetry, regression detection, and human spot-checks
  7. Composition is the goal — the real skill is knowing which patterns to combine (e.g., RAG + Reflection + Guardrails for a production Q&A agent)

Based on "Agentic Design Patterns" by Antonio Gulli (424 pages).
All author royalties donated to Save the Children.

About

Consumable summaries of Agentic Design Patterns by Antonio Gulli — 21 patterns, cheat sheets, and implementation guides

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

No contributors