Skip to content

Shridhar7-8/agentic_design

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

75 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– Agentic Design Patterns

A Comprehensive Guide to Building Robust, Scalable, and Intelligent AI Agents

Python Google ADK License


πŸ“– Overview

This repository is a comprehensive collection of Agentic Design Patterns implemented using the Google Agent Development Kit (ADK). It provides production-ready implementations, detailed documentation, and practical examples for building sophisticated AI agent systems.

Each pattern addresses specific challenges in agent designβ€”from simple task chaining to complex multi-agent orchestrationβ€”enabling developers to build reliable, maintainable, and scalable AI applications.


πŸš€ Quick Start

Prerequisites

  • Python 3.10+
  • uv (recommended) or pip

Installation

Using uv (recommended):

# Clone the repository
git clone <repository-url>
cd agentic-design

# Create virtual environment and install dependencies
uv venv
uv pip install -e .

# Set up environment variables
cp .env.example .env
# Edit .env with your API keys

Using pip:

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -e .

Environment Setup

Create a .env file with your API credentials:

GOOGLE_API_KEY=your_google_api_key_here
# Add other API keys as needed for specific patterns

πŸ“š Design Patterns Included

Pattern Description Module
πŸ”— Prompt Chaining Sequential LLM calls for multi-step workflows prompt-chaining/
🧭 Routing Dynamic decision-making for adaptive systems routing/
⚑ Parallelization Concurrent execution for performance optimization Parallelization/
πŸ”„ Reflection Self-correction and iterative improvement Reflection/
πŸ› οΈ Tool Use External tool integration via function calling Tool_use/
🀝 Multi-Agent Cooperative ensembles of specialized agents Multi_Agent/
πŸ“‹ Planning Strategic goal decomposition for complex tasks Planning/
πŸ‘€ Human-in-the-Loop Strategic human-AI collaboration Human_in_the_loop/
πŸ›‘οΈ Guardrails & Safety Content policy enforcement and safety controls Guardrails_Safety_Patterns/
πŸ“Š Evaluation & Monitoring Performance assessment and continuous monitoring Evaluation_and_Monitoring/
🎯 Prioritization Task scheduling and importance-based execution Prioritization/
πŸ” Exploration & Discovery Information gathering and knowledge expansion Exploration_and_Discovery/
πŸ“ Goal Setting & Monitoring Objective definition and progress tracking Goal_setting_monitoring/
🧠 Learning & Adaptation Continuous improvement from feedback Learning_and_adaptation/
πŸ“‘ Inter-Agent Communication Standardized agent interaction protocols Inter_Agent_Communication/
πŸ”§ Resource-Aware Optimization Efficient resource utilization and cost management Resource_aware_optimisation/
🧩 Model Context Protocol Context management and state handling Model_context_protocol/
⚠️ Exception Handling Recovery and resilience patterns Exception_handling_recovery/

πŸ—οΈ Pattern Categories

Control Flow Patterns

These patterns define how agents make decisions and orchestrate tasks:

  • Prompt Chaining β†’ Sequential execution for multi-step processes
  • Routing β†’ Dynamic path selection based on context
  • Parallelization β†’ Concurrent execution of independent tasks
  • Reflection β†’ Iterative self-improvement through critique

Capability Enhancement Patterns

These patterns extend agent capabilities through external integration:

  • Tool Use β†’ Function calling and external API integration
  • Multi-Agent β†’ Specialized agent collaboration
  • Planning β†’ Strategic goal decomposition

Safety & Governance Patterns

These patterns ensure reliable and safe agent operation:

  • Guardrails & Safety β†’ Content filtering and policy enforcement
  • Human-in-the-Loop β†’ Strategic human oversight
  • Evaluation & Monitoring β†’ Performance tracking and assessment
  • Exception Handling β†’ Recovery from failures

Optimization Patterns

These patterns improve efficiency and effectiveness:

  • Prioritization β†’ Importance-based task scheduling
  • Resource-Aware Optimization β†’ Efficient resource utilization
  • Learning & Adaptation β†’ Continuous improvement

🎯 Core Patterns Deep Dive

πŸ”— Prompt Chaining

Divide complex tasks into sequential steps where each step refines the output.

Input β†’ Step 1 β†’ Step 2 β†’ Step 3 β†’ Output

When to use: Multi-stage workflows requiring progressive refinement

Example: Content generation (ideation β†’ outline β†’ draft β†’ edit)

Learn more β†’


🧭 Routing

Dynamically route requests to specialized handlers based on intent.

Input β†’ Router β†’ Handler A / Handler B / Handler C

When to use: Different input types requiring specialized processing

Example: Customer support (billing, technical, sales)

Learn more β†’


⚑ Parallelization

Execute independent tasks concurrently to reduce latency.

       β”Œβ†’ Task A →┐
Input ─┼→ Task B β†’β”Όβ†’ Synthesize β†’ Output
       β””β†’ Task C β†’β”˜

When to use: Multiple independent operations (API calls, data processing)

Example: Research agent (search multiple sources simultaneously)

Learn more β†’


πŸ”„ Reflection

Generate β†’ Critique β†’ Refine for high-quality outputs.

Generate β†’ Evaluate β†’ Refine β†’ Final Output

When to use: Quality-critical applications requiring accuracy

Example: Code generation with self-review

Learn more β†’


πŸ› οΈ Tool Use

Extend agent capabilities through function calling and external APIs.

User Request β†’ Agent β†’ Tool Call β†’ Execution β†’ Response

When to use: Access to real-time data, calculations, or external systems

Example: Weather queries, database lookups, calculations

Learn more β†’


🀝 Multi-Agent Collaboration

Coordinate multiple specialized agents to solve complex problems.

          β”Œβ†’ Specialist A β†’
User ──→ Coordinator β”Όβ†’ Specialist B β†’ Synthesis β†’ Output
          β””β†’ Specialist C β†’

When to use: Complex tasks requiring diverse expertise

Example: Software development team (requirements, coding, testing, docs)

Learn more β†’


πŸ› οΈ Running Examples

Each pattern includes a runnable agent.py file. Execute any example:

# Using uv
uv run python prompt-chaining/agent.py

# Using Python directly
python prompt-chaining/agent.py

πŸ“ Repository Structure

agentic-design/
β”œβ”€β”€ README.md                    # This file
β”œβ”€β”€ pyproject.toml              # Project configuration
β”œβ”€β”€ .python-version             # Python version specification
β”œβ”€β”€ agent.py                    # Main demo: Farm Management System
β”œβ”€β”€ main.py                     # Entry point placeholder
β”‚
β”œβ”€β”€ prompt-chaining/            # Sequential pattern implementation
β”œβ”€β”€ routing/                    # Dynamic routing pattern
β”œβ”€β”€ Parallelization/            # Concurrent execution pattern
β”œβ”€β”€ Reflection/                 # Self-correction pattern
β”œβ”€β”€ Tool_use/                   # Function calling pattern
β”œβ”€β”€ Multi_Agent/                # Agent collaboration pattern
β”œβ”€β”€ Planning/                   # Goal decomposition pattern
β”œβ”€β”€ Human_in_the_loop/          # Human-AI collaboration
β”œβ”€β”€ Guardrails_Safety_Patterns/ # Safety and policy enforcement
β”œβ”€β”€ Evaluation_and_Monitoring/  # Performance tracking
β”œβ”€β”€ Prioritization/             # Task scheduling
β”œβ”€β”€ Exploration_and_Discovery/  # Information gathering
β”œβ”€β”€ Goal_setting_monitoring/    # Objective management
β”œβ”€β”€ Learning_and_adaptation/    # Continuous improvement
β”œβ”€β”€ Inter_Agent_Communication/  # Agent interaction protocols
β”œβ”€β”€ Resource_aware_optimisation/ # Resource management
β”œβ”€β”€ Model_context_protocol/     # Context handling
└── Exception_handling_recovery/ # Resilience patterns
β”‚
└── assets/                     # Documentation images and diagrams

πŸ§ͺ Development

Running Tests

# Run all tests
uv run pytest

# Run specific pattern tests
uv run pytest Evaluation_and_Monitoring/

Code Quality

# Format code
uv run ruff format .

# Lint code
uv run ruff check .

πŸ“– Framework: Google ADK

This repository uses the Google Agent Development Kit (ADK)β€”a comprehensive framework for building production-grade AI agents.

Key ADK Features Used

  • Agents: LLM-powered agents with structured instructions
  • Tools: Function calling for external integrations
  • Sessions: State management for multi-turn conversations
  • Runners: Orchestration and execution management
  • Callbacks: Before/after model hooks for guardrails and personalization
  • MCP Integration: Model Context Protocol for external tool access

Google ADK Documentation β†’


πŸŽ“ Learning Path

Beginner

  1. Start with Prompt Chainingβ€”understand sequential workflows
  2. Explore Tool Useβ€”add external capabilities
  3. Study Reflectionβ€”learn self-correction

Intermediate

  1. Implement Routingβ€”build decision-making agents
  2. Master Parallelizationβ€”optimize performance
  3. Design Multi-Agent systemsβ€”coordinate specialists

Advanced

  1. Add Guardrails & Safetyβ€”ensure reliability
  2. Implement Evaluation & Monitoringβ€”production readiness
  3. Explore Human-in-the-Loopβ€”strategic collaboration

πŸ’‘ Key Insights

When to Use Each Pattern

Use Case Recommended Pattern
Multi-stage processing Prompt Chaining
Intent classification Routing
Multiple API calls Parallelization
Quality-critical outputs Reflection
External data access Tool Use
Complex collaborative tasks Multi-Agent
Step-by-step goal achievement Planning
High-stakes decisions Human-in-the-Loop
Content safety Guardrails
Production monitoring Evaluation & Monitoring

Design Principles

  1. Decompose complex tasks into smaller, focused agents
  2. Compose patterns together for sophisticated behaviors
  3. Validate outputs at critical transition points
  4. Monitor performance in production environments
  5. Iterate based on real-world feedback


πŸ™ Acknowledgments

This repository is built upon the foundational work presented in Antonio Gulli's book on Agentic Design Patterns. The concepts, patterns, and architectural insights are drawn from his comprehensive research and expertise in the field.

  • Antonio Gulli β€” For the foundational book on Agentic Design Patterns that inspired this implementation
  • Google ADK Team β€” For the excellent agent framework
  • Anthropic β€” For pioneering agentic AI patterns
  • LangChain/LangGraph β€” For workflow orchestration concepts

Ready to build intelligent agents?

Start with prompt-chaining/ β†’ Tool_use/ β†’ Multi_Agent/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages