Agents that reason, plan, and act autonomously
Jungjun Hur, Younghee Song

#AI_Agent
#LLM
#MCP
#Pydantic
#OpenAI
#Python
🤖 ساخت AI Agentهای خودمختار از پایه با Python
🚀 این کتاب یک مسیر مرحلهبهمرحله برای طراحی، توسعه و استقرار سیستمهای Agentic AI ارائه میده. در طول کتاب، یک Research Agent پیشرفته با Python ساخته میشه که میتونه مسائل پیچیده و چندمرحلهای Benchmark سختگیرانه GAIA یا General AI Assistants را حل کنه؛ آن هم بدون تکیه بر Libraryها و Frameworkهای Black Box.
✨ ویژگیهای کلیدی
🛠️ یک AI Agent خودمختار و بدون Framework را از ابتدا تا انتها با Python طراحی و پیادهسازی میکنی.
🧠 مفاهیم Agent Loop، Context Engineering، Structured Output، Dynamic Tool-Calling، Planning و Reflection را با مثالهای عملی یاد میگیری.
🔎 قابلیتهایی مثل Web Search سفارشی، جستوجوی Local File System، Vector-Based RAG و Long-Term Memory را به Agent اضافه میکنی.
🔌 با استفاده از MCP، ابزارها و Serverهای خارجی را به Agent متصل میکنی و با Code-Act، اجرای امن Code و CLI Commandها را در محیطهای Cloud Sandboxed پیادهسازی میکنی.
🤝 یک سیستم تکعاملی را با A2A Protocol به معماری Multi-Agent تبدیل میکنی و برای آن Pipeline کامل Observability و ارزیابی LLM-as-a-Judge میسازی.
📘 توضیح کتاب
🧭 این کتاب سفری مرحلهبهمرحله در طراحی، توسعه و استقرار مجموعهای از AI Agentهای خودمختاره. جونگجون هور و یونگهی سونگ مفاهیم را بهترتیب معرفی میکنن و همزمان یک Research Agent پیشرفته با Python میسازن که برای حل وظایف پیچیده و چندمرحلهای Benchmark سختگیرانه GAIA طراحی شده است. مشاهده ساخت کامل سیستم کمک میکنه سازوکارهای زیرین آن را بدون پوشش Libraryها و Frameworkهای Black Box درک کنی.
📊 کتاب شامل ده فصل پربار و یک Appendix کاربردی درباره دریافت OpenAI API Key است. توضیحات فنی با نمودارهای متعدد روشنتر شدن و به گفته یکی از Reviewerها، حتی برای کسی که اولین Agent خود را میسازه، «بعد از چند فصل اول، دیگر هیچچیز شبیه جادو یا معما به نظر نمیرسه.»
🔄 در فصلهای ابتدایی، Blueprint پایه Agent شکل میگیره و تفاوت میان Workflowهای ثابت و تعریفشده توسط Developer با Agent Loopهای واقعی و هدایتشده توسط LLM بررسی میشه. همچنین یاد میگیری Stateless APIها را مدیریت کنی، با Pydantic خروجیهای Structured را اعمال کنی و Dynamic Tool-Calling را پیادهسازی کنی.
🧠 یکی از محورهای اصلی کتاب Context Engineering است؛ روشی منظم برای ساختاربندی اطلاعات با هدف جلوگیری از Context Rot و پدیده Lost in the Middle. یکی از Reviewerهای فنی کتاب هم تأکید کرده که مفاهیم پایهای مثل Agent Loop، Context Engineering و Evaluation با انگیزه روشن و مثالهای عملی توضیح داده میشن، نه بهعنوان مفاهیمی جدا و انتزاعی.
🔎 بعد از ساخت Agent اولیه، قابلیتهای آن بهتدریج با Web Search سفارشی، جستوجوی Local File System و Vector-Based RAG گسترش پیدا میکنه تا بتونه در دادههای پیچیده حرکت کنه. سپس با Hierarchical Context Optimization و Long-Term Memory، امکان یادآوری شکستهای گذشته و سازگارکردن State Persistence به Agent اضافه میشه. در همین مسیر، Model Context Protocol یا MCP برای اتصال یکپارچه Agent به ابزارها و Serverهای خارجی به کار میره.
⚙️ فصلهای پیشرفته برای جلوگیری از Hallucination یا گرفتارشدن Agent در Loopهای تکراری، Explicit Planning و Procedural Reflection را معرفی میکنن. سپس با الگوی Code-Act، Agent در محیطهای Cloud Sandboxed توانایی نوشتن Script، اجرای CLI Command و ترکیب پویای ابزارها را به دست میاره. پروژه در ادامه با A2A Protocol از یک Agent واحد به معماری مشارکتی Multi-Agent گسترش پیدا میکنه که وظایف تخصصی را برای افزایش Token Efficiency به Sub-Agentهای ایزوله میفرسته.
🎯 از آنجا که Agentهای بسیار خودمختار میتونن خطرهای واقعی ایجاد کنن، کتاب با ساخت یک Pipeline دقیق برای Observability و Evaluation به پایان میرسه. در این بخش، یک سیستم خودکار LLM-as-a-Judge مبتنی بر Open Telemetry پیادهسازی میکنی تا مسیر حرکت و خروجیهای Agent را Trace، امتیازدهی و بهطور مداوم اصلاح کنی. ساخت تمام لایهها از پایه باعث میشه درک عمیق و عملی از سازوکارهای AI به دست بیاری.
🎯 چیزهایی که یاد میگیری
🔄 یاد میگیری تفاوت Workflowهای ثابت با Agent Loopهای واقعی و هدایتشده توسط LLM را تشخیص بدی.
🧩 میتونی Stateless APIها، Structured Outputهای مبتنی بر Pydantic و Dynamic Tool-Calling را پیادهسازی کنی.
🧠 با Context Engineering، Hierarchical Context Optimization و روشهای جلوگیری از Context Rot و Lost in the Middle آشنا میشی.
📚 یاد میگیری Knowledge Baseهای مبتنی بر Vector RAG بسازی و Web Search و Local File System را به Agent متصل کنی.
💾 میتونی Long-Term Memory و State Persistence را برای یادآوری شکستهای گذشته و بهبود رفتار Agent طراحی کنی.
🔌 با MCP، ابزارها و Serverهای خارجی را به سیستم Agentic متصل میکنی.
💻 یاد میگیری با Code-Act، اجرای Sandboxed کد، Scriptها و CLI Commandها را بهشکل امن در اختیار Agent قرار بدی.
🤝 میتونی با A2A Protocol معماری Multi-Agent بسازی و با Open Telemetry و LLM-as-a-Judge عملکرد Agentها را Trace، ارزیابی و اصلاح کنی.
👤 این کتاب برای چه کسانیه؟
🐍 این کتاب برای Python Developerهایی نوشته شده که مقداری دانش Machine Learning دارن و میخوان سیستمهای Agentic را بسازن و سازوکار آنها را عمیقا درک کنن.
🧠 مطالب برای افرادی مناسبه که میخوان بدون وابستگی به Libraryها و Frameworkهای انتزاعی، تمام لایههای یک AI Agent را از Agent Loop و RAG تا Memory، MCP، Code Execution، Multi-Agent Orchestration و Evaluation پیادهسازی کنن.
📝 نقد و بررسی
💭 «راهنمایی عملی برای هر کسی که میخواد از Demoها فراتر بره و سیستمهای Agentic را با اطمینان بسازه.»
— الیوت کیم، Coupang Inc.
📖 فهرست مطالب
بخش اول. ساخت اولین LLM Agent
فصل ۱. AI Agent چیست؟
فصل ۲. مغز AI Agentها؛ LLMها
فصل ۳. فعالکردن Actionها؛ استفاده از ابزارها
فصل ۴. پیادهسازی یک ReAct Agent پایه
بخش دوم. توسعه قابلیتهای پیشرفته Agent
فصل ۵. ساخت Knowledge Base با RAG
فصل ۶. اضافهکردن Memory به Agent
فصل ۷. Planning و Reflection برای وظایف پیچیده
فصل ۸. توانمندسازی Agentها با Code Execution
فصل ۹. هماهنگسازی سیستمهای Multi-Agent
فصل ۱۰. ارزیابی Agentها
ضمیمه. OpenAI API Key
👥 درباره نویسندگان
🧠 جونگجون هور مهندس AI و Data است و در صنایع E-Commerce و AI تجربه فعالیت داره. او در این حوزهها برنامههای AI آماده Production و قابلیتهای مبتنی بر LLM ساخته است.
📚 جونگجون هور نویسنده کتاب پرفروش Practical AI Application Development Using LLMs است.
💼 یونگهی سونگ مشاور AI در PwC است. او مدرک کارشناسی خود را در رشته Economics and Finance از Hanyang University دریافت کرده است.
🎓 یونگهی سونگ همچنین مدرک Master در رشته Human Factors Engineering از Seoul National University داره.
"A practical guide for anyone who wants to move beyond demos and create agentic systems with confidence.”
—Elliot Kim, Coupang Inc.
This book is a fascinating step-by-step journey through design, development, and deployment of a system of autonomous AI agents. Authors Jungjun Hur and Younghee Song guide you concept-by-concept as you build a sophisticated research agent in Python, designed to solve complex, multi-step tasks from the rigorous GAIA (General AI Assistants) benchmark. By seeing the construction of the system end to end, you’ll understand how the underlying mechanics unobstructed by any existing blackbox libraries and frameworks.
This book includes ten meaty chapters and a handy appendix (about how to get an OpenAI API key). The technical explanations throughout the book are made crystal clear by the use of many helpful diagrams. As one reviewer remarked, even for someone building their first agent, “nothing feels like magic or a mystery after the first few chapters!”
Early on, you’ll establish the foundational blueprint for your agent by distinguishing rigid developer-defined workflows from true, LLM-directed agent loops. You’ll learn how to manage stateless APIs, enforce structured outputs using Pydantic, and implement dynamic tool-calling. Crucially, the book centers on “Context Engineering”—the discipline of systematically structuring information to prevent context rot and the “Lost in the Middle” effect. One technical reviewer particularly appreciated that core concepts like agent loops, context engineering, and evaluation are introduced with clear motivation and practical examples rather than as isolated abstractions.
After you build the basic agent, you’ll progressively expand its capabilities by integrating custom web search, local file system exploration, and vector-based RAG to navigate complex data. You’ll also enable the agent to recall past failures and adapt state persistence through hierarchical context optimization and longterm memory. Along the way, you’ll see how to use the Model Context Protocol (MCP) to seamlessly connect your agent to external tools and servers.
Later chapters push into advanced territory. To prevent the agent from hallucinating or looping during complex tasks, you’ll implement explicit planning and procedural reflection. Then, you’ll explore the Code-Act paradigm, empowering the agent with sandboxed cloud environments to securely write scripts, run CLI commands, and compose tools dynamically. Finally, you’ll up-scale your project from a single agent into a collaborative, multi-agent architecture using the A2A protocol, where specialized tasks are routed to isolated sub-agents to maximize token efficiency.
Because highly autonomous agents carry real-world risks, the book culminates in a rigorous observability and evaluation pipeline. You’ll implement an automated LLM-as-a-judge system—powered by Open Telemetry—to trace, grade, and continuously refine the agent’s trajectory and outputs. By building every layer from the ground up, the book ensures that readers are left with a deep, practical understanding of AI mechanics.
What's inside
• End-to-end construction of a framework-free, autonomous AI agent in Python
• Advanced practical integrations including MCP, vector-based RAG, long-term memory, and sandboxed code execution
• Multi-agent orchestration and automated LLM-as-a-judge evaluation pipelines
About the reader
For Python developers with some knowledge of machine learning who want to build and deeply understand agentic systems without relying on abstract libraries.
Table of Contents
Part 1. Building Your First LLM Agent
1. What Is an AI Agent?
2. The Brain of AI Agents: LLMs
3. Enabling Actions: Tool Use
4. Implementing a Basic ReAct Agent
Part 2. Developing Advanced Agent Capabilities
5. Building Knowledge Bases with RAG
6. Adding Memory to Your Agent
7. Planning and Reflection for Complex Tasks
8. Empowering Agents with Code Execution
9. Orchestrating Multi-Agent Systems
10. Evaluating Agents
Appendix. OpenAI API Key
Jungjun Hur is an AI and data engineer with experience in e-commerce and AI industries, where he has built production-ready AI applications and LLM-powered features. He is the author of the bestselling book Practical AI Application Development Using LLMs.
Younghee Song is an AI consultant at PwC. She graduated from Hanyang University with a degree in Economics and Finance and holds a Master’s in Human Factors Engineering from Seoul National University.









