中文

In-Depth AI Agent: Design Principles and Engineering Practice

An open-source book in 10 chapters with 109 companion experiments, under the Apache License 2.0.

Verified

Core facts

Read by a script from the official API, not rewritten by a model.

License
Apache-2.0
Languages
Python
Maintainer
bojieli
Verified

What it is

The title of this project is In-Depth AI Agent: Design Principles and Engineering Practice. The book is built around one core formula and covers AI Agent from principles to engineering practice in 10 chapters. The full text, the figures and the 109 companion experiments are all open source. The project uses the Apache License 2.0 open-source license.

Main features

  1. Chapter 2 is about context engineering, covering that context determines the capability ceiling, along with KV Cache, prompt engineering, Agent Skills and context compression.

  2. Chapter 3 is about user memory and knowledge bases, covering remembering users across sessions and connecting external knowledge, including user memory, RAG, structured indexes and knowledge graphs.

  3. Chapter 4 is about tools, covering the MCP protocol, three kinds of tools for perception, execution and collaboration, and proactive tool discovery.

  4. Chapter 5 is about Coding Agent and general-purpose Agent, covering code as a tool that can create new tools, and an overview of production-grade Coding Agents.

  5. Chapter 7 is about Agent evaluation, covering evaluation environments, metrics, statistical significance and evaluation-driven selection.

  6. Chapter 8 is about model post-training, covering the three stages of pre-training, SFT and RL, when to choose SFT, when to choose RL, internalizing tool calls and sample efficiency.

Getting started

  1. The project uniformly supports Python 3.11–3.13.

  2. Install dependencies by chapter from the repository root directory.

  3. After installation, experiments can be run from the repository root directory.

  4. Before running an experiment that calls a model, configure credentials according to that experiment's README.

  5. For system dependencies such as browsers, CUDA, FFmpeg, Ollama, Playwright browsers and external repositories, keep consulting each experiment's README.

  6. Some bundled third-party components in chapter 8 require Python 3.12+.

From the README · bash
# 推荐:使用提交到仓库的 uv.lock,获得可复现的章节环境
uv sync --locked --extra ch1

# 未安装 uv 时:使用 pip 从 pyproject.toml 重新解析
python -m pip install -e ".[ch1]"
From the README · bash
uv run python chapter1/context/main.py
# 使用 pip 安装时也可直接运行:python chapter1/context/main.py

Who it is for

Apart from the eighth chapter on post-training, the whole book places very low demands on mathematics and machine learning. The companion code of the book is entirely generated by a coding agent from the manuscript. Chapter 6 is about interaction, expanding the observation and action space of an Agent along the two dimensions of modality and timing.

Chapter 9 is about the continuous evolution of Agents, obtaining learning signals from run trajectories and updating knowledge, instructions, programs and parameters. The manuscript version in this repository has been upgraded from 1.4 to 2.0. Version 2.0 merges the asynchronous interaction part of the original fourth chapter with the multimodal Agent content of the original ninth chapter, and reorganizes them into the new sixth chapter, Interaction: Expanding the Observation and Action Space.

The original sixth chapter on Agent evaluation, seventh chapter on model post-training and eighth chapter on continuous evolution of Agents each moved back by one chapter and are now the seventh, eighth and ninth chapters. Compiling it yourself is needed only when you want to modify the manuscript and re-typeset it. Some sub-projects may contain their own license information, and the notes in the sub-project take precedence.

The companion book In-Depth AI Infra: Quantitative Analysis and System Design has been released as open source. The companion book discusses the AI Infra that supports model training and inference.

Sources

This page is written from the official sources below. Open them to check the original text.

Verified ·

This page is written by AI from the official sources above and checked automatically. This site has not tested it. Found a mistake? Tell us.