Build agent systems by studying design principles and 109 experimental code examples
You can examine how models read context and use tools through code, and build agent systems yourself. The book centers on the formula 'agent = LLM + context + tools,' showing step by step how to move from theory to working systems. Version 2.0 integrates multimodal and asynchronous processing content to restructure the material, and provides the latest PDF and translations in 15 languages.
Version 2.0 structural changes and latest content
The repository was recently updated from version 1.4 to version 2.0. The major change is the reorganization of the former Chapter 4 'Asynchronous Interaction' and Chapter 9 'Multimodal Agents' into a new Chapter 6 'Interaction: Expanding the Space of Observation and Action.' Consequently, the chapters on evaluation, model post-training, and continuous evolution were renumbered to 7, 8, and 9, respectively. If you are reading an older PDF, it is advisable to switch to the latest version, as this update includes content revisions and adjustments. A companion book on AI infrastructure is also available, which helps in understanding the infrastructure of model-based applications.
A learning path across 10 chapters
The entire content is divided into 10 chapters, covering agent fundamentals through production environment application. Chapter 1 defines the core components of an agent, and Chapter 2 discusses how to raise model capability limits through context engineering. Chapter 3 explains how to connect external knowledge using user memory and RAG (Retrieval-Augmented Generation), while Chapter 4 describes the MCP protocol and tool discovery mechanisms. Chapter 5 emphasizes the role of tools that create tools, focusing on coding agents, and Chapter 6 covers methods for broadening the scope of observation and action, such as voice, computer use, and robot manipulation. Chapter 7 details evaluation systems for measuring agent performance, Chapter 8 covers model post-training strategies using SFT and RL, Chapter 9 explains how to obtain learning signals from execution trajectories to evolve agents, and Chapter 10 describes multi-agent collaboration and social phenomena.
Setting up and running the experimental environment
All experiments support Python 3.11 through 3.13. uv is recommended for installing dependencies, and the uv sync --locked --extra ch1 command sets up the environment for the corresponding chapter. If uv is not available, you can use python -m pip install -e ".[ch1]". Experiments requiring model calls need you to copy .env.example to .env and enter your API key. Some experiments are specified to use local Ollama, in which case you must add the --provider ollama option.
Pre-execution checks and requirements
The book does not require deep knowledge of mathematics or machine learning, but you should be able to read and modify intermediate-level Python code. Experience using LLM products like ChatGPT or Claude and familiarity with AI-assisted coding tools (such as Claude Code and Codex) are helpful. The post-training experiments in Chapter 8 may require Python 3.12 or higher and a GPU environment, and some external repositories (such as robot simulators and browser automation tools) must be cloned separately. Since all experimental code was generated by coding agents, it is better to focus on understanding the architecture and design principles rather than trying to understand every line. The license is Apache License 2.0, and some sub-projects may have separate licenses, so verification is necessary.