An open-source AI agent textbook where every chapter runs
This repo open-sources a full Chinese textbook on AI agent engineering—complete with Markdown source, compiled PDF, and runnable Python demos for every chapter.

What it does
This is the master repository for 《深入理解 AI Agent:设计原理与工程实践》, a Chinese technical book by Li Bojie on designing and building AI agents. It hosts the complete book text in Markdown, a compiled PDF, and runnable Python projects organized across ten chapters. The material treats agent building as a systematic engineering discipline rather than folklore.
The interesting bit
Most AI books give you prose or isolated snippets; this one treats every concept—from KV Cache layout to MCP servers to GraphRAG—as a standalone, executable project. The author frames the entire field around the formula Agent = LLM + Context + Tools, then systematically builds out each term with working code.
Key highlights
- Ten chapters span the full stack: context engineering, memory/RAG, tool use (MCP), coding agents, evaluation, RL/post-training, self-evolution, multimodal interaction, and multi-agent collaboration.
- Each chapter contains independent, runnable Python examples: attention visualization, BM25 sparse retrieval built from scratch, Agentic RAG with ReAct loops, and a local-LLM serving demo showing that even a 0.6B model can handle tool calls with the right system design.
- Includes advanced indexing implementations: RAPTOR recursive trees, GraphRAG knowledge graphs, and Anthropic-style contextual retrieval (reducing retrieval failure rates by 49–67% in the included demo).
- Book source is fully open: Markdown files, build scripts for PDF generation (via pandoc/XeLaTeX), and figure-generation scripts.
- Some demos rely on free public APIs (DuckDuckGo, Open-Meteo) to lower the barrier to entry.
Caveats
- The book text and code comments are in Chinese, which limits accessibility for non-Chinese readers.
- PDF compilation requires a specific LaTeX toolchain (pandoc, XeLaTeX, the ElegantBook document class, and Chinese fonts) that may not be trivial to set up.
- Several demos require API keys for commercial LLM providers, though some chapters use free public APIs.
Verdict
Worth bookmarking if you want a structured, code-first curriculum covering the modern agent stack end-to-end. Skip it if you are looking for a single deployable framework or need English-language documentation.
Frequently asked
- What is bojieli/ai-agent-book?
- This repo open-sources a full Chinese textbook on AI agent engineering—complete with Markdown source, compiled PDF, and runnable Python demos for every chapter.
- Is ai-agent-book open source?
- Yes — bojieli/ai-agent-book is an open-source project tracked on heatdrop.
- What language is ai-agent-book written in?
- bojieli/ai-agent-book is primarily written in Python.
- How popular is ai-agent-book?
- bojieli/ai-agent-book has 524 stars on GitHub.
- Where can I find ai-agent-book?
- bojieli/ai-agent-book is on GitHub at https://github.com/bojieli/ai-agent-book.