This repository contains complete, production-ready implementations of all 21 design patterns from the Agentic Design Patterns book. Each project demonstrates a specific pattern with a practical, runnable application.
Note: This is an educational resource for learning AI agent design patterns. All code is MIT licensed and ready for experimentation.
- 🚀 All 21 Patterns Implemented
- 🛠️ Quick Start
- 🏗️ Project Structure
- 📊 Pattern Categories
- 📦 Requirements
- 💻 Usage Examples
- 📚 Learning Path
- 🔧 Integration
- 📈 Status
- 🤝 Contributing
- 📄 License
| # | Pattern | Project | Description |
|---|---|---|---|
| 1 | Prompt Chainingprompt_chaining/ |
Document Analysis Pipeline | Sequential multi-step processing 📝 Extract → Entities → Summary → JSON |
| 2 | Routingrouting/ |
Smart Request Router | Request classification and delegation 🔀 Route to specialized handlers |
| 3 | Parallelizationparallelization/ |
Parallel Document Processor | Concurrent task execution ⚡ 5 parallel analysis tasks with synthesis |
| 4 | Reflectionreflection/ |
Self-Improving Content Generator | Generate → Critique → Refine 🔄 Iterative content improvement |
| 5 | Tool Usetool_use/ |
Research Assistant with Tools | Function calling and tool integration 🛠️ Search, calculate, analyze with tools |
| 6 | Planningplanning/ |
Task Planning System | Goal decomposition and execution 📋 Break goals into actionable tasks |
| 7 | Multi-Agentmulti_agent/ |
Collaborative Team System | Multiple specialized agents working together 👥 Research → Write → Edit → Coordinate |
| 8 | Memorymemory/ |
Conversation Memory System | State persistence and context management 🧠 Maintain conversation history |
| # | Pattern | Project | Description |
|---|---|---|---|
| 9 | Adaptationadaptation/ |
Adaptive Agent | Learning from feedback 📈 Improve over time based on experience |
| 10 | MCPmcp/ |
Model Context Protocol Integration | Standardized agent communication 🔗 Tool sharing and resource access |
| 11 | Goal Settinggoal_setting/ |
Goal-Oriented Agent | Goal breakdown and progress tracking 🎯 Set goals, track progress, achieve objectives |
| 12 | Exception Handlingexception_handling/ |
Robust Agent with Fallback | Error handling and recovery 🛡️ Graceful failure handling |
| 13 | Human-in-the-Loophuman_in_loop/ |
Interactive Agent | Human escalation and feedback 👤 Customer support with escalation |
| 14 | RAGrag/ |
Knowledge Retrieval System | Retrieval-Augmented Generation 📚 Document-based Q&A |
| # | Pattern | Project | Description |
|---|---|---|---|
| 15 | Inter-Agent Communicationinter_agent/ |
Agent Communication System | Agent-to-agent messaging 💬 Agents collaborating via messages |
| 16 | Resource Optimizationresource_optimization/ |
Resource Optimizer | Efficient resource usage ⚡ Caching, batching, cost optimization |
| 17 | Reasoningreasoning/ |
Chain-of-Thought Agent | Step-by-step reasoning 🧠 Complex problem solving |
| 18 | Guardrailsguardrails/ |
Safety Agent | Content validation and filtering 🔒 Safety and compliance checking |
| 19 | Evaluationevaluation/ |
Agent Evaluation System | LLM-as-a-Judge 📊 Quality assessment and monitoring |
| 20 | Prioritizationprioritization/ |
Task Prioritization System | Priority-based task management 📋 Rank and order tasks |
| 21 | Explorationexploration/ |
Exploration Agent | Experimental discovery 🔍 Multiple approach testing |
Getting started with any project is straightforward:
# 1. Navigate to the project you want to explore
cd agentic_patterns_projects/prompt_chaining/
# 2. Install the dependencies
pip install -r requirements.txt
# 3. Set up your environment variables
cp .env.example .env
# Edit .env and add your GEMINI_API_KEY
# 4. Run the example
python example.py # Note: Use example.py, not main_file.pyEach project follows a consistent structure that makes it easy to understand and extend:
📁 prompt_chaining/
├── 🔧 document_analyzer.py # Core implementation
├── 📝 example.py # Usage examples
├── 📖 README.md # Project documentation
├── 📦 requirements.txt # Python dependencies
└── ⚙️ .env.example # Environment template
I've organized the patterns into categories to help you understand how they relate:
| Category | Patterns | Description |
|---|---|---|
| 🔄 Sequential Patterns | Prompt Chaining, Planning | Linear workflows and goal decomposition |
| ⚡ Parallel Patterns | Parallelization | Concurrent task execution |
| 🎯 Decision Patterns | Routing, Reflection, Prioritization | Request routing and iterative improvement |
| 🔗 Integration Patterns | Tool Use, Multi-Agent, Inter-Agent Communication, MCP | Agent coordination and tool integration |
| 🧠 State Patterns | Memory Management, Goal Setting | State persistence and goal tracking |
| 🛡️ Quality Patterns | Exception Handling, Guardrails, Evaluation | Error handling and quality assurance |
| 🚀 Advanced Patterns | Adaptation, RAG, Reasoning, Human-in-the-Loop, Resource Optimization, Exploration | Cutting-edge agent capabilities |
Most projects share similar requirements:
- 🐍 Python 3.8 or higher
- 🔑 Gemini API key (set in your
.envfile) - 📚 LangChain libraries (installed via requirements.txt)
To get started, install the common dependencies:
# Install common dependencies
pip install langchain langchain-google-genai langchain-community python-dotenv
# For specific projects, check their requirements.txt for any additional packagesNote: Make sure you have a valid Gemini API key. You can get one from Google AI Studio.
Here are some quick examples to get you started:
from document_analyzer import DocumentAnalyzer
analyzer = DocumentAnalyzer()
result = analyzer.analyze("Your document text...")
print(result) # Returns structured JSON with extracted entities and summaryfrom smart_router import SmartRouter
router = SmartRouter()
result = router.route("Book me a flight to Paris next week")
print(result) # Routes to travel booking handlerfrom collaborative_team import CollaborativeTeam
team = CollaborativeTeam()
result = team.collaborate("Create a blog post", "Requirements...")
print(result) # Coordinated output from research, writing, and editing agentsIf you're new to agentic design patterns, here's a suggested learning path:
Focus: Fundamentals of agent workflows
- Learn sequential and parallel processing
- Understand basic agent coordination
- Build foundation for advanced patterns
Focus: Production-ready capabilities
- Master adaptation and memory systems
- Implement RAG and human interaction
- Build on core concepts with real-world features
Focus: Enterprise-grade agent systems
- Resource optimization and cost management
- Safety, evaluation, and quality assurance
- Advanced techniques for production deployment
One of the coolest things about these patterns is that you can combine them:
| Pattern Combination | Use Case |
|---|---|
| Routing + Multi-Agent | Complex workflow orchestration |
| RAG + Tool Use | Enhanced knowledge retrieval with external tools |
| Guardrails + Any Agent | Safety and compliance across all systems |
| Evaluation + Planning | Quality monitoring of goal execution |
| Memory + Adaptation | Learning systems with persistent state |
Feel free to experiment and mix patterns to solve your specific problems!
✅ All 21 patterns are complete and ready to use
Every pattern has been implemented as a production-ready project with:
- Comprehensive documentation and examples
- Proper error handling and type hints
- Architecture diagrams and explanations
- Ready-to-run code with minimal setup
We welcome contributions! Each project is self-contained and can be extended independently.
- 📝 Add more examples and use cases
- 🔧 Integrate with your own systems
- 🔗 Combine patterns in new ways
- 🚀 Extend functionality and add new features
- 🐛 Report bugs and suggest improvements
- 📖 Improve documentation
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and test thoroughly
- Submit a pull request with a clear description
These are educational examples, so feel free to experiment and build on them!
This project is licensed under the MIT License - see the LICENSE file for details.
These projects are educational examples demonstrating agentic design patterns. Use them to learn, experiment, and build your own systems.
- 🐛 Issues: Report bugs or request features
- 💬 Discussions: Join community discussions
- 📧 Questions: Open an issue with the "question" label
Happy building! 🚀