ai-agent-book
《深入理解 AI Agent:设计原理与工程实践》(李博杰 著)开源主仓库:全书正文、编译版 PDF 与按章配套代码
Install / Use
claude mcp add bojieli -- npx -y github:bojieli/ai-agent-bookIf the server publishes to npm under a different name, use that package instead — check the repo README.
MCP Server
Model Context Protocol server
Quality Score
Category
AI & Machine LearningSupported Platforms
Our assessment of ai-agent-book
ai-agent-book scores 92/100 on our quality scale, 264th of 965 AI & Machine Learning skills we index (top 28%).
Its MCP Server is 35 KB long, well organised into 20 sections with 3 code examples: a thorough specification that gives an agent plenty to work with.
With 57,258 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated 28 days ago, so ai-agent-book is actively maintained.
- Our last check on 2026-10-20 found the source still online.
- It is released under the Apache-2.0 license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 95/100, with 1 caution from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.
AI review by kimi-k2.7-code on 2026-09-24. Automated pattern scan on 2026-09-24. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
ai-agent-book compared with similar skills
All 4 of these similar skills score higher than ai-agent-book; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| ai-agent-book (this skill)by bojieli | 92 | 57.3k | 28d ago | MCP Server |
| claude-memby thedotmack | 100 | 113.5k | today | CLAUDE.md |
| Agent-Reachby Panniantong | 100 | 109.2k | today | CLAUDE.md |
| Understand-Anythingby Egonex-AI | 100 | 90.9k | 10d ago | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 78.9k | today | CLAUDE.md |
Frequently asked questions
- How do I install ai-agent-book?
- Run
claude mcp add bojieli -- npx -y github:bojieli/ai-agent-book. The install tabs above show the steps for each supported agent. - Which AI agents does ai-agent-book work with?
- It is written for Claude Code and Claude Desktop, as a MCP Server file. Other agents that read the same format can often use it too.
- Is ai-agent-book safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It is Apache-2.0-licensed and scores 95/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is ai-agent-book still maintained?
- The repository was last updated 28 days ago, so ai-agent-book is actively maintained.
Skill content
View source on GitHub深入理解 AI Agent:设计原理与工程实践
中文 ← 当前 · English · Español · Bahasa Indonesia · العربية · 繁體中文(台灣) · Русский · Tiếng Việt · தமிழ் · 日本語 · Türkçe · 한국어 · Magyar · עברית · Português (Brasil)
📥 下载 PDF / EPUB(推荐)— 推荐使用 PDF / EPUB 离线阅读,排版最佳;也可在线阅读(支持多语言切换、章节折叠、高亮与笔记,每次推送自动更新)。
Agent = LLM + 上下文 + 工具——本书围绕这个核心公式,用 10 章把 AI Agent 从原理讲到工程实战。全书正文、配图、109 个配套实验全部开源,欢迎亲手把实验跑一遍。
📚 姊妹篇《深入理解 AI Infra:量化分析与系统设计》已开源发布,欢迎阅读:github.com/bojieli/ai-infra-book
要开发好基于模型的应用,还需要理解这类应用赖以运行的基础设施。姊妹篇讨论的就是支撑模型训练与推理的 AI Infra:参数和上下文状态存在哪里,计算怎样执行,多个加速器怎样协作。
📢 2.0 版变更(相较 1.4 版):本仓库书稿版本已由 1.4 升级为 2.0。2.0 版将原第四章中的“异步交互”部分与原第九章中关于“多模态 Agent”的内容合并,重组为新的第六章“交互:观察与动作空间的扩展”。原第六章“Agent 的评估”、第七章“模型后训练”和第八章“Agent 的持续进化”依次后移一章,现分别为第七、八、九章。
如果你看到的是旧版 PDF,建议下载最新版 PDF。新版还包含许多内容修正与调整,请以最新版为准。
| 📚 10 章 正文,从基础到生产 | 📂 109 个 配套实验(含本地项目与外部复现轨道) | 🌐 15 种 语言:中 / 英 / 西 / 印尼 / 阿 / 繁體中文(台灣) / 俄 / 泰米尔 / 越 / 日 / 土耳其 / 韩 / 匈牙利 / 希伯来 / 葡萄牙语(巴西) | | :---: | :---: | :---: |
📖 电子书
📥 离线下载(推荐,全书正文,开源免费)。以下链接始终指向 main 分支的最新构建;固定版本见 Releases:
- 中文(原版):PDF · EPUB
- 英文(社区翻译,by @nsdevaraj、@whanyu1212):PDF · EPUB
- 西班牙语(社区翻译,by @santhreal):PDF · EPUB
- 印度尼西亚语(社区翻译,by @jojixyz666):PDF · EPUB
- 繁體中文(台灣)(社区翻译,by @tigercosmos):PDF · EPUB
- 俄语(社区翻译,by @ui99ru):PDF · EPUB
- 泰米尔语(社区翻译,by @nsdevaraj):PDF · EPUB
- 越南语(社区翻译,by @toanalien):PDF · EPUB
- 日语(社区翻译,by @eltociear):PDF · EPUB
- 阿拉伯语(社区翻译,by @TheSyBuilder):PDF · EPUB
- 土耳其语(社区翻译,by @memisemre):PDF · EPUB
- 韩语(社区翻译,by @JeongJaeSoon):PDF · EPUB
- 匈牙利语(Magyar)(社区翻译,by @barmivalami0-ux):PDF · EPUB
- 希伯来语(עברית)(社区翻译,by @itzikwo):PDF · EPUB
- 葡萄牙语(巴西)(社区翻译,by @leofn,配图翻译 by @LibnaRaffaely):PDF · EPUB
🌐 也可在线阅读 — 支持多语言切换、章节折叠、高亮与笔记、配套实验直达,每次 main 分支推送后自动重新构建。
中文正文源码位于 book/;英文/西班牙语/印度尼西亚语/阿拉伯语/繁體中文(台灣)/俄语/泰米尔/越南语/日语/土耳其语/韩语/匈牙利语/希伯来语/葡萄牙语(巴西)版本为社区贡献(可能滞后于中文原版),分别位于 book-en/、book-es/、book-id/、book-ar/、book-zhtw/、book-ru/、book-ta/、book-vi/、book-ja/、book-tr/、book-ko/、book-hu/、book-he/、book-ptbr/。
-
EPUB:使用统一的构建脚本,详情请参阅 EPUB 构建说明
-
正文源码:
book/introduction.md(引言)、book/chapter1.md~book/chapter10.md(第一至第十章)、book/afterword.md(后记) -
编译:安装 pandoc、xelatex、ElegantBook 文档类与相关字体后,运行
cd book && bash build_pdf.sh图表以 SVG 文件存于
book/images/,编译时直接使用;排版细节见book/preamble.tex与book/*.lua。
📑 内容速览(第 1–10 章)
全书围绕核心公式 Agent = LLM + 上下文 + 工具 展开,十章层层递进:
| 章 | 主题 | 一句话核心 | 正文 | 实验 | | :--: | --- | --- | :--: | :--: | | 1 | 🚀 AI Agent 入门 | Agent = LLM + 上下文 + 工具;Harness 工程才是竞争力 | 读 | 4 | | 2 | 🎯 上下文工程 | 上下文决定能力上限:KV Cache、提示工程、Agent Skills、上下文压缩 | 读 | 10 | | 3 | 📚 用户记忆和知识库 | 跨会话记住用户、接入外部知识:用户记忆、RAG、结构化索引、知识图谱 | 读 | 12 | | 4 | 🛠️ 工具 | 工具是 Agent 的双手:MCP 协议、感知/执行/协作三类工具与主动工具发现 | 读 | 5 | | 5 | 💻 Coding Agent 与通用 Agent | 代码是「能创造新工具的工具」,生产级 Coding Agent 全景 | 读 | 16 | | 6 | 🎙️ 交互:观察与动作空间的扩展 | 从模态与时序两个维度扩展 Agent 的观察与动作空间:异步与事件驱动、语音交互、Computer Use 和机器人操作 | 读 | 14 | | 7 | 🎯 Agent 的评估 | 把表现变成可比较信号:评估环境、指标、统计显著性、评估驱动选型 | 读 | 14 | | 8 | 🧠 模型后训练 | 预训练/SFT/RL 三阶段:何时选 SFT、何时选 RL,工具调用内化、样本效率 | 读 | 19 | | 9 | 🔄 Agent 的持续进化 | 从运行轨迹获得学习信号,更新知识、指令、程序与参数 | 读 | 9 | | 10 | 🤝 多 Agent 协作 | 群体智能高于个体:协作框架、上下文共享/隔离、涌现的「Agent 社会」 | 读 | 6 |
💡 读 = 在 GitHub 网页直接读章节正文(markdown);N = 该章正文实验数,点击查看实现与复现说明。项目类型说明(✅ 可运行 / 📖 复现 / 🚧 设计)见各章 README。
📚 如何高效阅读本书?详见 学习建议(核心理念、学习路径、难度分级、实践建议)。
💻 运行配套实验
项目统一支持 Python 3.11–3.13。请在仓库根目录按章节安装依赖;将 ch1 替换为 ch2 ~ ch10 即可安装对应章节:
# 推荐:使用提交到仓库的 uv.lock,获得可复现的章节环境
uv sync --locked --extra ch1
# 未安装 uv 时:使用 pip 从 pyproject.toml 重新解析
python -m pip install -e ".[ch1]"
运行会调用模型的实验前,请按该实验 README 配置凭据:支持根目录配置的实验可复制 .env.example 为 .env 并填入至少一个提供商 Key;有些实验要求在自身目录放 .env 或直接导出环境变量。只有在实验 README 或 CLI 明确列出 ollama 时,才可启动本地 Ollama 并添加 --provider ollama。
安装后可从仓库根目录运行实验,例如:
uv run python chapter1/context/main.py
# 使用 pip 安装时也可直接运行:python chapter1/context/main.py
uv安装方法见 官方文档;pip仍受支持,但不会使用锁文件。- 各实验现有的
requirements.txt在迁移期间继续有效,适合只运行单个项目或需要特殊版本约束的情况。 all是不含本地训练栈的 CPU 友好组合,并不代表每个实验;uv sync每次都会精确同步当前选择,使用特殊 extra 时请合并到同一条命令,例如uv sync --locked --extra ch2 --extra vllm或uv sync --locked --extra ch7 --extra unsloth;pip 对应为python -m pip install -e ".[ch2,vllm]"。- 浏览器、CUDA、FFmpeg、Ollama、Playwright 浏览器及外部仓库等系统依赖,请继续参考各实验 README。第 8 章部分内置第三方组件需要 Python 3.12+。
🔑 API 密钥
建议申请下面几个平台的 API Key 方便学习。模型选型可参考 这篇指南。
| 平台 | 链接 | 特色 | 访问节点 | | --- | --- | --- | --- | | Kimi(月之暗面) | https://platform.moonshot.cn/ | Kimi 系列,Coding、Agent 能力强 | 中国大陆 | | 智谱 GLM | https://open.bigmodel.cn/ | GLM-5.2 等,Coding、Agent 能力强 | 中国大陆 | | Siliconflow | https://siliconflow.cn/ | 各种开源模型(DeepSeek、Qwen 等),中国大陆访问速度快 | 中国大陆 | | DeepSeek | https://platform.deepseek.com/ | DeepSeek 官方 API | 全球 + 中国大陆 | | Atlas Cloud | https://www.atlascloud.ai/ | 通过 OpenAI 兼容接口访问多个厂商的模型 | 全球 | | Krill AI | www.krill-code.com | 一站式访问全球及国内主流模型(OpenAI、Claude、Gemini、Grok、Kimi、GLM、DeepSeek、Qwen、Minimax) | 全球 + 中国大陆 | | OpenRouter | https://openrouter.ai/ | 一站式访问全球及国内主流模型(GPT、Claude、Gemini、Kimi、GLM、DeepSeek、Qwen 等) | 全球 |
❓ 常见问题
Q:有 PDF / EPUB 吗?需要自己编译吗? 不需要。电子书一节列出了 15 种语言的 PDF / EPUB 下载链接,始终指向 main 分支的最新构建;也可以在线阅读。只有想修改书稿并重新排版时才需要自行编译。
Q:阅读本书需要哪些前置知识? 引言的“前置知识”一节有完整说明:能读懂并修改中等复杂度的 Python 代码;用过 ChatGPT、Claude 等 LLM 产品;熟悉至少一款 AI 辅助编程工具(Claude Code、Codex、Cursor 等);了解命令行、Git、JSON、REST API 等软件工程常识。除第八章后训练外,全书对数学和机器学习的要求很低。
Q:知识点多、读完就忘,怎么消化? 不要只读正文。推荐的方式是结合每章实验自己动手——不是看配套代码,而是读懂书中的设计原则后,借助 coding agent 从头实现一遍,观察输出、排查不符合预期的地方;每章末尾的思考题也是很好的自测。更系统的路径见学习建议。一位读者的总结很贴切:先把书看薄,再把书看厚,再把书看薄。
Q:实验代码需要逐行弄明白吗? 不需要。本书的配套代码全部由 coding agent 根据书稿生成,作者也不会逐行阅读。关键是把架构、核心组件和设计原则想清楚,然后让 AI 去写代码、跑测试、修 bug,人负责最初的设计和最终的验收。
Q:思考题有参考答案吗?
有:book/reference-answers.md(在线版)。它们只是参考,不是标准答案,欢迎在 Discussions 里讨论你的不同看法。
Q:读完之后有什么可以落地的实践项目? 推荐从头做一个像 Claude Code、Codex 那样的 coding agent:第 1–5 章足以做出一个可用的 coding agent;第 7、9 章帮它建立评估集并从失败案例中持续改进;第 8 章介入模型本身;第 6、10 章为它增加语音、Computer Use 等交互方式和多 Agent 协作。评测、观测、可靠性这些工程环节,可以从第 7 章的评估实验入手:先为自己的 agent 建一个十几条任务的小评估集,再围绕失败用例做改进。
Q:哪里提问和讨论?
- 书稿勘误、实验 bug、翻译问题:开 [Issue](https://github.com/bojiel
Truncated for display — read the full file on GitHub.
Related Skills
claude-mem
113.5kPersistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
Agent-Reach
109.2kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
Understand-Anything
90.9kGraphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
headroom
78.9kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
