Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Jungjun Hur, Younghee Song

Build a working AI agent that can reason, plan, and execute multi-step tasks! LLM-powered AI agents are the next leap in applied AI, capable of reasoning and collaboration to achieve even complex, multi-step goals. Using new protocols like MCP and A2A, agents can use software tools, retrieve relevant knowledge, and adapt to feedback. This book guides you step by step in creating an AI agent from the ground up, with clear, detailed explanations you can follow to build your own custom assistants! In Build an AI Agent (From Scratch) you will learn how to: Implement a ReAct (Thought → Action → Observation) loop Use MCP to integrate tools calls into your agent’s workflow Agentic RAG for relevant responses Create memory modules that store facts, context, and evolving goals Enable agents to plan, reflect, and self-correct Build specialized agents, including a code execution agent Design multi-agent systems In Build an AI Agent (From Scratch), bestselling author Jungjun Hur and AI expert Younghee Song guide you through creating a complete research assistant agent framework. You’ll learn how agents function under the hood—all without hidden abstractions, black boxes, or framework lock-in. You will implement each piece as you develop a mental model of how agents really work. about the reader For Python developers and AI practitioners. All examples run on a standard laptop. about the authors 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.

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A hands-on guide to building a working LLM-powered AI agent from first principles in Python—no frameworks, no black boxes. Best for Python developers and AI practitioners who want to understand how agents reason, use tools, and plan under the hood. 【Book Arc】 - **Opening (~0%–9%)**: Frames what an agent actually is—an LLM plus a loop—and distinguishes workflows from agents, showing how the two combine in production pipelines. Introduces context engineering as the organizing lens for everything that follows. - **Early (~9%–28%)**: Builds the LLM foundation: choosing closed vs. open models, managing conversation history manually, structured output, and prompt design for autonomous tool use. Motivates tools via the GAIA benchmark finding that most problems need external capabilities. - **Early–Middle (~28%–44%)**: Implements tool calling end to end—defining schemas, executing tools, and running the control loop—then introduces MCP as a standardized interface for tool discovery and delivery, including building your own MCP server. - **Middle (~44%–50%)**: Assembles the first complete ReAct agent (Thought → Action → Observation), tested against the GAIA benchmark, serving as the foundation for later chapters. - **Late**: Extends the base agent with memory modules, agentic RAG for knowledge retrieval, and planning/reflection/self-correction strategies. - **Ending**: Moves toward specialized agents (including code execution) and multi-agent system design, plus evaluation concerns like rate limiting and parallel execution. 【Key Takeaways】 - **The loop is what makes a tool user into an agent** (Opening): an agent repeatedly assesses state, acts, observes, and decides when to stop—enabling tasks of unpredictable complexity. - **Context engineering is the real design discipline** (Opening): the book organizes strategies into generation, retrieval, write, reduce, and isolate—each mapped to later chapters on planning, tools, knowledge, and memory. - **Agents and workflows are complementary, not competing** (Opening): the most effective production architectures embed agents as flexible nodes inside predictable workflow stages. - **Start with closed LLMs, migrate selectively to open ones** (Early): validate design first, then port to self-hosted models for cost, stability, or data-residency reasons—often in a hybrid configuration. - **Structured output is non-negotiable for tool use** (Early): agents must emit machine-parseable tool names and arguments, not just readable prose. - **Tool design lives in the system prompt** (Early): vague guidance like "use when necessary" underperforms clear directives to act proactively and autonomously. - **MCP standardizes tool discovery and delivery** (Middle): tool developers define schemas once, and any MCP-compatible client can consume them—removing per-tool manual wiring. - **ReAct is the foundational pattern** (Middle): alternating reasoning and action, with observations fed back into context, underpins memory, planning, and multi-agent extensions. 【Reading Tips】 - Deep-read the ReAct chapter and the tool-execution control loop—these are the conceptual and code backbone of everything later. - Skim the LLM-selection material if you already have a model strategy; return to it when optimizing cost or latency. - Treat the MCP chapter as a hands-on lab: build the server yourself rather than only consuming community servers, so you can debug and extend tools. - Watch for the recurring context-engineering thread—it ties tools, memory, RAG, and planning together and is easy to lose across chapters. - Keep the GAIA benchmark framing in mind as a reality check on what agents can and cannot do without tools. 【Coverage Limits】 The excerpts cover roughly the first half of the book in detail (foundations through ReAct and MCP); later chapters on memory, agentic RAG, planning, specialized agents, and multi-agent systems are referenced but not substantively excerpted, so this guide's treatment of those topics is thinner than the book's.
Page 8
ommon foundation: they are powered by Large Language Models. Understanding how LLMs work and how they enable agent capabilities is essential for anyone who w...
View in text
Excerpt 2
sponse1 = completion(model="gpt-5-mini", messages=messages) assistant_message1 = response1.choices[0].message.content messages.append({"role": "assistant", "...
View in text
Excerpt 3
it can synthesize the final response from relevant sources. This loop of call → execute → return → reason is essential to consistent tool use. 3.2.2 How can...
View in text
Excerpt 4
tion into an MCP-compatible tool by adding just a decorator. Let's transform the search_web function we built in section 3.3 into a fully functional MCP serv...
View in text
Excerpt 5
recording it in the context. If the response contains tool calls, the method calls act() to execute them and record the results as another Event. Finally, it...
View in text
Excerpt 6
le system like a human developer. When given a zip file, it extracts the archive, examines the folder structure, reads relevant files, and finds the answer....
View in text
Excerpt 7
these components into our existing agent architecture. The integration involves two parts: extending ExecutionContext to reference a session and modifying th...
View in text
Excerpt 8
cess_llm_request() without appearing in the LLM's tool list. MemoryTool uses this pattern: it sets tool_definition=None so the LLM cannot call it, but its pr...
View in text
Tags
AI categories
Artificial IntelligenceProgrammingPython
Publish Year: 2026
Language: English
Pages: 390
File Format: PDF
File Size: 15.3 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…