Skip to content

mkassaf/agentic-ai-patterns

Repository files navigation

🧠 Agentic AI Design Patterns — Code Examples

Runnable Python examples for 41 Agentic AI Design Patterns from the book "Agentic AI Planning & Reasoning Design Patterns: A Comprehensive Technical Reference".

Every example is self-contained, fully commented, and built with the deepagents library on top of LangChain + LangGraph.


📁 Repository Structure

agentic-ai-patterns/
│
├── 01_llm_interaction/              # Chapter 7: LLM Interaction Patterns
│   ├── 01_chain_of_thought/         # Structured step-by-step reasoning
│   ├── 02_react/                    # Reasoning + Acting loop
│   ├── 03_reflection/               # Self-evaluation and output improvement
│   └── 04_human_in_loop/            # Agent requests human help & learns
│
├── 02_planning_execution/           # Chapter 8: Planning & Execution Patterns
│   ├── 01_plan_and_execute/         # Full plan upfront, then execute
│   ├── 02_concurrent_optimizer/     # DAG-based parallel execution
│   └── 03_planner_critic_refiner/   # Iterative plan quality improvement
│
├── 03_multi_agent/                  # Chapter 6: Multi-Agent System Architectures
│   ├── 01_orchestrator_worker/      # Manager delegates to specialist workers
│   ├── 02_expert_team/              # Collaborating domain experts
│   └── 03_hierarchical/            # Multi-layer orchestration hierarchy
│
├── 04_memory_learning/              # Chapter 10: Memory & Adaptive Action
│   ├── 01_episodic_procedural/      # Persistent long-term memory
│   ├── 02_in_context_learning/      # Inject memories into prompts
│   └── 03_adaptive_tool_orchestration/ # LLM plans toolchain, delegates execution
│
├── requirements.txt
└── README.md

🗺️ Pattern Map (Book → Example)

Book Pattern Chapter Example Folder Difficulty
Chain of Thought 7.1 01_llm_interaction/01_chain_of_thought
ReAct 7.2 01_llm_interaction/02_react ⭐⭐
Reflection 7.3 01_llm_interaction/03_reflection ⭐⭐
Human-in-the-Loop 7.6 01_llm_interaction/04_human_in_loop ⭐⭐
Plan-and-Execute 8.1 02_planning_execution/01_plan_and_execute ⭐⭐
Concurrent Execution Optimizer 8.2 02_planning_execution/02_concurrent_optimizer ⭐⭐⭐
Planner-Critic-Refiner 8.4 02_planning_execution/03_planner_critic_refiner ⭐⭐⭐
Planning Pattern (Orchestrator-Worker) 6.2 03_multi_agent/01_orchestrator_worker ⭐⭐⭐
Specialized Expert Team 6.3 03_multi_agent/02_expert_team ⭐⭐⭐
Hierarchical Multi-Agent 6.4 03_multi_agent/03_hierarchical ⭐⭐⭐⭐
Episodic & Procedural Memory 10.1 04_memory_learning/01_episodic_procedural ⭐⭐⭐
In-Context Learning 10.2 04_memory_learning/02_in_context_learning ⭐⭐⭐
Adaptive Tool Orchestration 10.3 04_memory_learning/03_adaptive_tool_orchestration ⭐⭐⭐

🚀 Quick Start

git clone https://github.com/mkassaf/agentic-ai-patterns.git
cd agentic-ai-patterns
pip install -r requirements.txt
export ANTHROPIC_API_KEY="your-key"

# Run any example
python 01_llm_interaction/01_chain_of_thought/agent.py

🧠 Core Concept: The Four Agent Modules

Every agent in this repo is built from these four modules (Chapter 5):

┌─────────────────────────────────────────────┐
│                  AGENT                       │
│  ┌────────────┐    ┌───────────────────┐    │
│  │ PERCEPTION │───▶│    REASONING      │    │
│  │  Module    │    │  (LLM + Controller│    │
│  └────────────┘    └────────┬──────────┘    │
│                             │               │
│  ┌────────────┐    ┌────────▼──────────┐    │
│  │  LEARNING  │◀───│     ACTION        │    │
│  │  Module    │    │     Module        │    │
│  └────────────┘    └───────────────────┘    │
└─────────────────────────────────────────────┘

📦 Dependencies

deepagents    — agent framework
langchain     — core building blocks
langgraph     — stateful execution runtime
anthropic     — Claude LLM provider
tavily-python — web search (optional, for ReAct examples)

📖 Further Reading

About

13 runnable Python examples for Agentic AI Design Patterns — CoT, ReAct, Reflection, HITL, Plan-Execute, Concurrent DAG, Planner-Critic-Refiner, Orchestrator-Worker, Expert Team, Hierarchical, Episodic Memory, In-Context Learning, Adaptive Tool Orchestration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages