Skip to content

Complete Implementation of 21 Agentic Design Patterns A comprehensive collection of production-ready AI agent patterns, each as a runnable project. Master agentic design through practical examples covering prompt chaining, multi-agent systems, RAG, and more. Perfect for AI developers, researchers, and teams building complex AI workflows

License

Notifications You must be signed in to change notification settings

josephsenior/Agentic-Design-Patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸš€ Agentic Design Patterns - Complete Real-World Projects

License: MIT Python 3.8+ Stars Issues

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.

πŸ“‹ Table of Contents

πŸš€ All 21 Patterns Implemented

πŸ—οΈ Core Patterns (Chapters 1-8)

# Pattern Project Description
1 Prompt Chaining
prompt_chaining/
Document Analysis Pipeline Sequential multi-step processing
πŸ“ Extract β†’ Entities β†’ Summary β†’ JSON
2 Routing
routing/
Smart Request Router Request classification and delegation
πŸ”€ Route to specialized handlers
3 Parallelization
parallelization/
Parallel Document Processor Concurrent task execution
⚑ 5 parallel analysis tasks with synthesis
4 Reflection
reflection/
Self-Improving Content Generator Generate β†’ Critique β†’ Refine
πŸ”„ Iterative content improvement
5 Tool Use
tool_use/
Research Assistant with Tools Function calling and tool integration
πŸ› οΈ Search, calculate, analyze with tools
6 Planning
planning/
Task Planning System Goal decomposition and execution
πŸ“‹ Break goals into actionable tasks
7 Multi-Agent
multi_agent/
Collaborative Team System Multiple specialized agents working together
πŸ‘₯ Research β†’ Write β†’ Edit β†’ Coordinate
8 Memory
memory/
Conversation Memory System State persistence and context management
🧠 Maintain conversation history

⚑ Advanced Patterns (Chapters 9-14)

# Pattern Project Description
9 Adaptation
adaptation/
Adaptive Agent Learning from feedback
πŸ“ˆ Improve over time based on experience
10 MCP
mcp/
Model Context Protocol Integration Standardized agent communication
πŸ”— Tool sharing and resource access
11 Goal Setting
goal_setting/
Goal-Oriented Agent Goal breakdown and progress tracking
🎯 Set goals, track progress, achieve objectives
12 Exception Handling
exception_handling/
Robust Agent with Fallback Error handling and recovery
πŸ›‘οΈ Graceful failure handling
13 Human-in-the-Loop
human_in_loop/
Interactive Agent Human escalation and feedback
πŸ‘€ Customer support with escalation
14 RAG
rag/
Knowledge Retrieval System Retrieval-Augmented Generation
πŸ“š Document-based Q&A

🎯 Specialized Patterns (Chapters 15-21)

# Pattern Project Description
15 Inter-Agent Communication
inter_agent/
Agent Communication System Agent-to-agent messaging
πŸ’¬ Agents collaborating via messages
16 Resource Optimization
resource_optimization/
Resource Optimizer Efficient resource usage
⚑ Caching, batching, cost optimization
17 Reasoning
reasoning/
Chain-of-Thought Agent Step-by-step reasoning
🧠 Complex problem solving
18 Guardrails
guardrails/
Safety Agent Content validation and filtering
πŸ”’ Safety and compliance checking
19 Evaluation
evaluation/
Agent Evaluation System LLM-as-a-Judge
πŸ“Š Quality assessment and monitoring
20 Prioritization
prioritization/
Task Prioritization System Priority-based task management
πŸ“‹ Rank and order tasks
21 Exploration
exploration/
Exploration Agent Experimental discovery
πŸ” Multiple approach testing

πŸ› οΈ Quick Start

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.py

πŸ—οΈ Project Structure

Each 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

πŸ“Š Pattern Categories

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

πŸ“¦ Requirements

Most projects share similar requirements:

  • 🐍 Python 3.8 or higher
  • πŸ”‘ Gemini API key (set in your .env file)
  • πŸ“š LangChain libraries (installed via requirements.txt)

πŸ’» Installation

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 packages

Note: Make sure you have a valid Gemini API key. You can get one from Google AI Studio.

πŸ’» Usage Examples

Here are some quick examples to get you started:

πŸ“ Example 1: Prompt Chaining

from document_analyzer import DocumentAnalyzer

analyzer = DocumentAnalyzer()
result = analyzer.analyze("Your document text...")
print(result)  # Returns structured JSON with extracted entities and summary

πŸ”€ Example 2: Routing

from smart_router import SmartRouter

router = SmartRouter()
result = router.route("Book me a flight to Paris next week")
print(result)  # Routes to travel booking handler

πŸ‘₯ Example 3: Multi-Agent Collaboration

from collaborative_team import CollaborativeTeam

team = CollaborativeTeam()
result = team.collaborate("Create a blog post", "Requirements...")
print(result)  # Coordinated output from research, writing, and editing agents

πŸ“š Learning Path

If you're new to agentic design patterns, here's a suggested learning path:

πŸ—οΈ Phase 1: Core Patterns (Chapters 1-8)

Focus: Fundamentals of agent workflows

  • Learn sequential and parallel processing
  • Understand basic agent coordination
  • Build foundation for advanced patterns

⚑ Phase 2: Advanced Patterns (Chapters 9-14)

Focus: Production-ready capabilities

  • Master adaptation and memory systems
  • Implement RAG and human interaction
  • Build on core concepts with real-world features

🎯 Phase 3: Specialized Patterns (Chapters 15-21)

Focus: Enterprise-grade agent systems

  • Resource optimization and cost management
  • Safety, evaluation, and quality assurance
  • Advanced techniques for production deployment

πŸ”§ Integration

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!

πŸ“ˆ Status

βœ… 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

🀝 Contributing

We welcome contributions! Each project is self-contained and can be extended independently.

Ways to Contribute

  • πŸ“ 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

Getting Started

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and test thoroughly
  4. Submit a pull request with a clear description

These are educational examples, so feel free to experiment and build on them!

πŸ“„ License

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.


πŸ“ž Contact & Support

Happy building! πŸš€

About

Complete Implementation of 21 Agentic Design Patterns A comprehensive collection of production-ready AI agent patterns, each as a runnable project. Master agentic design through practical examples covering prompt chaining, multi-agent systems, RAG, and more. Perfect for AI developers, researchers, and teams building complex AI workflows

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages