The 21 agentic AI design patterns from Antonio Gulli's book, explained in Egyptian Arabic — with framework-free, runnable Python examples.
Every pattern gets: a plain-Arabic explanation built on analogies, a Mermaid diagram of the mechanism, when-to-use guidance and trade-offs verified against the book, and a self-contained Python example that demonstrates the real mechanism with nothing but the OpenAI SDK — no LangChain, no CrewAI, no magic.
ليه بالمصري؟ لأن أنماط تصميم الـ AI Agents هي أساس أي نظام ذكي حقيقي، والمحتوى العربي التقني الجاد فيها شبه معدوم. الريبو ده شرح كامل للـ 21 pattern من كتاب Antonio Gulli بلغة بسيطة وأمثلة كود تشتغل فعلاً.
git clone https://github.com/Muhannad-Khaled/agentic-design-patterns.git
cd agentic-design-patterns
pip install -r requirements.txt
cp .env.example .env # add your API key (OpenAI, Groq, Ollama — anything OpenAI-compatible)
python examples/01_prompt_chaining.py| # | Pattern | TL;DR | Guide | Code |
|---|---|---|---|---|
| 1 | Prompt Chaining | Split a complex task into a pipeline of focused, validated LLM calls | 📖 | 🐍 |
| 2 | Routing | Classify each request and dispatch it to the right specialist | 📖 | 🐍 |
| 3 | Parallelization | Run independent sub-tasks concurrently and merge the results | 📖 | 🐍 |
| 4 | Reflection | Producer/critic loop — draft, critique, refine until quality passes | 📖 | 🐍 |
| 5 | Tool Use | Let the model call external functions and APIs to act on the world | 📖 | 🐍 |
| 6 | Planning | Generate a step-by-step plan before executing, adapt as things change | 📖 | 🐍 |
| 7 | Multi-Agent Collaboration | A team of specialized agents coordinated by an orchestrator | 📖 | 🐍 |
| 8 | Memory Management | Short-term vs long-term memory — what to store, compress, and recall | 📖 | 🐍 |
| 9 | Learning & Adaptation | Improve behavior over time from feedback and outcomes | 📖 | 🐍 |
| 10 | Model Context Protocol (MCP) | The open standard for discovering and calling external tools | 📖 | 🐍 |
| 11 | Goal Setting & Monitoring | Define measurable goals (KPIs) and self-correct on drift | 📖 | 🐍 |
| 12 | Exception Handling & Recovery | Classify failures, retry with backoff, fall back, escalate | 📖 | 🐍 |
| 13 | Human-in-the-Loop | Pause for human approval on high-stakes or ambiguous decisions | 📖 | 🐍 |
| 14 | Knowledge Retrieval (RAG) | Ground answers in your own documents via retrieval | 📖 | 🐍 |
| 15 | Inter-Agent Communication (A2A) | Structured messaging protocols between agents | 📖 | 🐍 |
| 16 | Resource-Aware Optimization | Route easy tasks to cheap models, hard ones to strong models | 📖 | 🐍 |
| 17 | Reasoning Techniques | CoT, ToT, self-correction, debate — structured thinking before answering | 📖 | 🐍 |
| 18 | Guardrails / Safety Patterns | Screen inputs and outputs for harm, PII leaks, and prompt injection | 📖 | 🐍 |
| 19 | Evaluation & Monitoring | Golden test sets, quality gates, and drift detection in production | 📖 | 🐍 |
| 20 | Prioritization | Score and order tasks by value, urgency, effort, and dependencies | 📖 | 🐍 |
| 21 | Exploration & Discovery | Open-ended research — explore, cluster, dig deeper, synthesize | 📖 | 🐍 |
flowchart TD
START{"What's your main challenge?"} --> BIG["Task too big for<br/>one prompt"]
START --> VARIED["Many different<br/>request types"]
START --> WORLD["Needs external<br/>data / actions"]
START --> QUALITY["Output quality<br/>is critical"]
START --> SCALE["Multiple specialists<br/>working together"]
START --> PROD["Running safely<br/>in production"]
BIG --> B1{"Steps depend<br/>on each other?"}
B1 -- yes --> P01["01 Prompt Chaining"]
B1 -- no --> P03["03 Parallelization"]
BIG --> P06["06 Planning"]
VARIED --> P02["02 Routing"]
VARIED --> P16["16 Resource-Aware<br/>Optimization"]
VARIED --> P20["20 Prioritization"]
WORLD --> W1{"What kind?"}
W1 -- "APIs & actions" --> P05["05 Tool Use"]
W1 -- "standard tool protocol" --> P10["10 MCP"]
W1 -- "your documents" --> P14["14 RAG"]
QUALITY --> P04["04 Reflection"]
QUALITY --> P17["17 Reasoning<br/>Techniques"]
QUALITY --> P19["19 Evaluation &<br/>Monitoring"]
SCALE --> P07["07 Multi-Agent<br/>Collaboration"]
SCALE --> P15["15 A2A<br/>Communication"]
SCALE --> P08["08 Memory<br/>Management"]
PROD --> P12["12 Exception<br/>Handling"]
PROD --> P13["13 Human-in-<br/>the-Loop"]
PROD --> P18["18 Guardrails"]
PROD --> P11["11 Goal Setting &<br/>Monitoring"]
Cross-cutting patterns you'll layer on top: 09 Learning & Adaptation (systems that improve with feedback) and 21 Exploration & Discovery (open-ended research agents).
| Appendix | About | |
|---|---|---|
| A | Advanced Prompting Techniques | The prompting toolbox underneath every pattern |
| B | From GUI to Real-World Environments | Agents that see screens and act in the physical world |
| C | Overview of Agentic Frameworks | LangChain, LangGraph, CrewAI, Google ADK & friends |
| D | Building an Agent with AgentSpace | UI-based agent building |
| E | AI Agents on the CLI | Claude Code, Gemini CLI & terminal-native agents |
| F | Under the Hood: Reasoning Engines | How the thinking actually happens |
| G | Coding Agents | Agents that write software |
├── patterns/ # 21 pattern guides (Egyptian Arabic, one per book chapter)
├── appendices/ # 7 appendix summaries
├── examples/ # 21 runnable Python scripts — plain OpenAI SDK, no frameworks
├── requirements.txt
└── .env.example # works with OpenAI, Groq, Ollama, or any OpenAI-compatible API
This repository is an original Egyptian-Arabic study guide of:
Antonio Gulli — Agentic Design Patterns: A Hands-On Guide to Building Intelligent Systems, Springer, 2025. 📚 Springer edition · Free official version (Google Docs) · 100% of the author's royalties go to Save the Children
It summarizes and explains the book's concepts in a different language and style — it does not reproduce the book's text. All example code here is written from scratch. If this material helps you, please support the original book.
Built by Muhannad Khaled · Contributions and corrections are welcome — open an issue or PR.