Skip to content
 
 

Repository files navigation

Deep Understanding of AI Agents: Design Principles and Engineering Practice

This repository is the open-source main repository for the book Deep Understanding of AI Agents: Design Principles and Engineering Practice, containing the full text and accompanying example code. The full text, illustrations, and accompanying experimental code are all open source. You are welcome to run the experiments yourself, submit issues, and PRs.

📖 E-Book

The full text and compiled PDF are located in the book/ directory:

  • Source text: book/introduction.md (Introduction), book/chapter1.md ~ book/chapter10.md (Chapters 1–10), book/afterword.md (Afterword)

  • Compiled PDF: book/Deep-Understanding-of-AI-Agents-Li-Bojie-v1.1.pdf

  • Self-compilation: After installing pandoc, xelatex, the ElegantBook document class, and related fonts, run

    cd book && bash build_pdf.sh

    Figures are generated by book/gen_*_figs.py and stored in book/images/. Typesetting details are in book/preamble.tex and book/*.lua.

📑 Content Overview (Chapters 1–10)

The book revolves around the core formula Agent = LLM + Context + Tools, with ten chapters as follows:

  • Chapter 1 · Agent Fundamentals: Starting from the new paradigm of "Model as Agent," establishes the core formula Agent = LLM + Context + Tools, and introduces Harness engineering—all engineering capabilities beyond the model are the true competitive advantage.
  • Chapter 2 · Context Engineering: Context determines the upper bound of Agent capabilities. Delves into the context structure of LLM APIs, KV Cache-friendly design, prompt engineering, dynamic prompts and Agent Skills, status bar meta-information, and context compression strategies.
  • Chapter 3 · User Memory and Knowledge Bases: Enables Agents to remember users across sessions and access external knowledge. Covers user memory systems, basic RAG pipelines, and knowledge organization and retrieval beyond flat text (structured indexes, knowledge graphs, etc.).
  • Chapter 4 · Tools: Tools are the hands of an Agent. Discusses tool classification and general design principles, the MCP protocol and challenges of tool selection, three types of tools (perception, execution, collaboration), and event-driven asynchronous Agents.
  • Chapter 5 · Coding Agent and Code Generation: Code is a "tool that can create new tools" and is the meta-capability of a general-purpose Agent. Uses a production-grade Coding Agent as an example to demonstrate the complete implementation of this most powerful general tool.
  • Chapter 6 · Agent Evaluation: Turns Agent performance into comparable signals. Covers evaluation environments, dataset design, metric systems, statistical significance, observability, evaluation-driven selection, and production-grade internal evaluation and simulation environments.
  • Chapter 7 · Model Post-Training: A comprehensive view of the three stages: pre-training, SFT, and RL. When to choose SFT vs. RL, RLHF, algorithm comparison, data and environments, and cutting-edge exploration into teaching models tool calling and improving sample efficiency.
  • Chapter 8 · Agent Self-Evolution: Growth without changing weights. Three learning paradigms, learning from experience, active tool discovery, and the journey from "tool user" to "tool creator," allowing Agents to progress from "smart" to "skilled."
  • Chapter 9 · Multimodal and Real-Time Interaction: Extends perception and action from text to voice, GUI, and the physical world. Three voice paradigms (cascaded/end-to-end full-modal/full-duplex), streaming voice perception and synthesis, Computer Use, and robotic manipulation.
  • Chapter 10 · Multi-Agent Collaboration: Collective intelligence can surpass individual intelligence. Multi-Agent classification framework, when it truly outperforms a single Agent, collaboration with and without shared context, failure modes, and the emergent "Agent Society."

💻 Accompanying Code

All projects are organized by chapter, corresponding one-to-one with the ten chapters of the book, covering a complete learning path from basic concepts to advanced techniques, in the directory chapterN/project_name/. Most experiments in Chapters 5, 8, 9, and 10 now provide independently runnable demos that have been verified with real LLM APIs.

Project Type Description

Accompanying projects are divided into three types. Please refer to the icons below to understand the "out-of-the-box" readiness of each project:

  • Independently Runnable: This repository contains the complete code. Just configure the API Key (see the end of this document) and run.
  • 📖 Reproduction Guide: The project itself is a detailed reproduction document. It depends on external repositories (training frameworks, evaluation benchmarks, etc.) that need to be git cloned separately. See Obtaining External Repositories below.
  • 🚧 Design Document: Currently contains only the architecture and implementation plan design document. Runnable code is still being refined.

The following projects are not ✅ independently runnable. Please take note when cloning this repository:

Project Type Description
chapter7/AdaptThink · AWorld-train · MiniMind-pretrain · retool · SpatialReasoning 📖 Reproduction Guide Training-type experiments, dependent on external frameworks. Reproduce by following the README.
All benchmarks in Chapter 6 · Most training frameworks in Chapter 7 · browser-use/claude-quickstarts in Chapter 9 · use-computer-while-calling in Chapter 10 📖 Reproduction Guide Dependent on external repositories. See Obtaining External Repositories.

Obtaining External Repositories (Brief)

Some experiments in Chapters 6, 7, 9, and 10 depend on external repositories such as evaluation benchmarks, training frameworks, and robot platforms (not included in this repository due to size and licensing). To avoid information overload upfront, complete clone commands, upstream addresses, and commits verified by the book are provided in the Appendix · Obtaining External Repositories at the end of this document. It is recommended to start with the independently runnable projects from the earlier chapters. When you need to reproduce training/evaluation/robot experiments, follow the instructions at the end to quickly obtain the necessary resources.

🚀 Chapter 1 · Agent Fundamentals

learning-from-experience - Reinforcement Learning vs LLM Comparison

chapter1/learning-from-experience/

Compares traditional reinforcement learning (Q-learning) with LLM-based in-context learning, reproducing key insights from Shunyu Yao's "The Second Half" blog post. Demonstrates how LLMs can surpass traditional RL with 250-400x sample efficiency through a treasure hunt game.

Core Concepts: Reinforcement Learning, In-Context Learning, Sample Efficiency, Prior Knowledge

web-search-agent - Kimi K2 Model as Agent

chapter1/web-search-agent/

Implements an Agent with basic deep search capabilities, capable of multi-round searching and information integration.

Core Concepts: Web Search, Model-Native Agent

search-codegen - GPT-5 Native Tool Integration

chapter1/search-codegen/

Builds an Agent with basic deep search and code sandbox capabilities, utilizing tools like web search and code execution for complex analysis.

Core Concepts: Web Search, Code Generation, Model-Native Agent

context - Context Ablation Study

chapter1/context/

Demonstrates the importance of various Agent context components through systematic ablation experiments. Supports multiple LLM providers (SiliconFlow Qwen, ByteDance Doubao, Moonshot Kimi), allowing configuration of different context modes to observe changes in Agent behavior.

Core Concepts: Context Management, Tool Calling, ReAct Loop, Ablation Study

🎯 Chapter 2 · Context Engineering

local_llm_serving - Local LLM Deployment and Tool Calling

chapter2/local_llm_serving/

A cross-platform local LLM deployment solution that automatically selects the best backend (vLLM or Ollama). Demonstrates that even a 0.6B small model can achieve excellent tool calling capabilities through good system design. Supports streaming responses for real-time thought process display.

Core Concepts: Model Deployment, Chat Template, Streaming, Tool Calling

attention_visualization - Attention Mechanism Visualization

chapter2/attention_visualization/

Visualizes the complete input/output token sequence and attention weight distribution of an LLM, providing deep insight into how the model processes context, performs reasoning, and calls tools.

Core Concepts: Attention Mechanism, Token Analysis, Reasoning Process Visualization

kv-cache - KV Cache-Friendly Context Design

chapter2/kv-cache/

Explores the impact of different context management modes on KV Cache, demonstrating how common error patterns destroy cache efficiency. Shows through experiments how proper context design can significantly reduce latency and cost.

Core Concepts: KV Cache, Context Optimization, Performance Tuning

context-compression - Context Compression Strategies

chapter2/context-compression/

Implements and compares multiple context compression strategies, including summarization, key information extraction, and semantic compression. Reduces token usage while maintaining Agent capabilities.

Core Concepts: Context Compression, Token Optimization, Information Density

prompt-engineering - Prompt Engineering Ablation Study

chapter2/prompt-engineering/

Extends the Tau-Bench framework to quantify the impact of different prompt engineering factors on Agent performance through systematic ablation experiments. Shows how factors like tone, instruction organization, and tool descriptions affect task completion rates.

Core Concepts: Prompt Engineering, Ablation Study, Performance Benchmarking

system-hint - System Prompt Optimization

chapter2/system-hint/

Studies the impact of System Hints on Agent behavior, exploring how to improve performance by optimizing system prompts.

Core Concepts: System Prompt, Behavior Guidance, Prompt Optimization

log-sanitization - Log Sanitization

chapter2/log-sanitization/

Implements an intelligent log sanitization system that protects sensitive data while preserving debugging information.

Core Concepts: Privacy Protection, Log Processing, Data Security

prompt-injection - Prompt Injection Attack and Defense Experiment

chapter2/prompt-injection/

Constructs a controlled experiment with 3 attack scenarios (direct injection, indirect injection, memory injection) × 4 defense configurations (no defense, prompt hardening, source tagging, combined defense). Uses deterministic rules to calculate attack success rates, visually demonstrating how layered defenses significantly reduce injection success rates.

Core Concepts: Prompt Injection, Indirect Injection, Data/Instruction Separation, Runtime Validation

agent-skills-ppt - Agent Skills Progressive Disclosure for PPT Generation

chapter2/agent-skills-ppt/

Reproduces the "progressive disclosure" concept of Agent Skills: the Agent initially sees only a thin Skill directory. Only after identifying that the task requires the pptx Skill does it progressively load its complete workflow, detailed documentation, and bundled scripts, ultimately generating a real .pptx file using python-pptx.

Core Concepts: Agent Skills, Progressive Disclosure, On-Demand Loading, Tool Orchestration

📚 Chapter 3 · User Memory and Knowledge Bases

user-memory - User Memory System

chapter3/user-memory/

Builds a long-term user memory system, enabling the Agent to remember user preferences and historical interactions to provide personalized services.

Core Concepts: Long-Term Memory, Personalization, User Modeling

mem0 / memobase - Open-Source Memory Framework Comparison

chapter3/mem0/ and chapter3/memobase/

Implements a version of user memory using each of the two open-source memory frameworks, mem0 and Memobase, serving as a comparative implementation for Experiment 3-2 "Memory Strategy Comparison," facilitating horizontal comparison of extraction forms and answer quality across different memory solutions.

Core Concepts: Memory Framework, mem0, Memobase, Solution Comparison

user-memory-evaluation - User Memory Evaluation Framework

chapter3/user-memory-evaluation/

Systematically evaluates the accuracy, relevance, and effectiveness of user memory systems, including multiple test scenarios and evaluation metrics.

Core Concepts: Evaluation Framework, Test Cases, Performance Metrics

dense-embedding - Dense Embedding Vector Retrieval Service

chapter3/dense-embedding/

Builds a vector similarity search service, comparing ANNOY (tree-based) and HNSW (graph-based) approximate nearest neighbor index algorithms. Demonstrates the trade-offs between different indexing strategies in terms of performance, memory usage, and update capability.

Core Concepts: Dense Embedding, Vector Retrieval, ANN Algorithm, Semantic Search

sparse-embedding - Sparse Retrieval Engine

chapter3/sparse-embedding/

Implements a sparse vector search engine based on the BM25 algorithm from scratch. Provides rich logging and visualization interfaces to understand the internal workings of the search engine, including term frequency weight calculation and inverted index principles.

Core Concepts: Sparse Embedding, BM25, TF-IDF, Exact Match

retrieval-pipeline - Hybrid Retrieval Pipeline

chapter3/retrieval-pipeline/

Builds a complete retrieval pipeline combining dense retrieval, sparse retrieval, and neural re-ranking. Systematically demonstrates the complementary advantages of hybrid retrieval in different scenarios through carefully designed test cases.

Core Concepts: Hybrid Retrieval, Neural Re-Ranking, Cross-Encoder, Retrieval Fusion

multimodal-agent - Multimodal Information Extraction

chapter3/multimodal-agent/

Compares three multimodal processing strategies: native multimodal processing, extraction to text, and tool-based analysis. Reveals the trade-offs in fidelity, cost, and flexibility among different technical paths through ablation studies within a unified framework.

Core Concepts: Multimodal, Visual Understanding, OCR, End-to-End Processing

structured-index - Structured Index

chapter3/structured-index/Implement and compare two advanced indexing strategies: RAPTOR (Recursive Abstractive Processing Tree) and GraphRAG (Knowledge Graph). Demonstrate how to build structured indexes that reflect the inherent hierarchy and relationships within knowledge through an indexing techniques manual.

Core Concepts: RAPTOR, GraphRAG, Hierarchical Summarization, Knowledge Graph

agentic-rag - Agentic RAG

chapter3/agentic-rag/

Compare the performance differences between traditional Non-Agentic RAG and Agentic RAG. Show how an Agent, using the ReAct pattern, leads iterative information retrieval, significantly improving answer quality when handling complex judicial Q&A.

Core Concepts: Agentic RAG, ReAct Loop, Iterative Retrieval, Active Exploration

agentic-rag-for-user-memory - Building User Memory with Agentic RAG

chapter3/agentic-rag-for-user-memory/

Apply the Agentic RAG framework to manage user conversation history. Leverage multi-turn iterative search capabilities to handle memory retrieval across sessions, enabling basic recall and cross-session retrieval capabilities.

Core Concepts: User Memory, Conversation History Indexing, Cross-Session Retrieval

contextual-retrieval - Contextual Retrieval

chapter3/contextual-retrieval/

Implement the contextual retrieval technique proposed by Anthropic. By generating prefix summaries containing core context for text chunks, it addresses the context loss problem of traditional chunking methods, reducing retrieval failure rates by 49-67%.

Core Concepts: Context Augmentation, Prefix Generation, Semantic Anchoring, Retrieval Optimization

contextual-retrieval-for-user-memory - Contextual Retrieval for User Memory System

chapter3/contextual-retrieval-for-user-memory/

Apply contextual retrieval techniques to user memory construction. Combine Advanced JSON Cards with Contextual RAG to form a dual-layer memory structure, enabling higher-level proactive service capabilities.

Core Concepts: Dual-Layer Memory, Structured Facts, Contextual Retrieval, Proactive Service

structured-knowledge-extraction - Structured Knowledge Extraction

chapter3/structured-knowledge-extraction/

Using judicial precedents as an example, implement a three-stage pipeline: "Bottom-up factor discovery → Case prototype clustering → Conversational advisory Agent". Without predefined rigid fields, the LLM autonomously discovers factors from a large number of cases and summarizes them into a modular schema (core factors + charge-specific extension factors). Cases are then clustered into several prototypes, and the importance of each factor for each prototype is calculated. The Agent matches new case facts to the most similar prototype, asks for missing information based on factor importance, and provides evidence-based advice (with a legal disclaimer).

Core Concepts: Bottom-up Knowledge Discovery, Modular Factors, Clustering Prototypes, Explainable Decision Making

🛠️ Chapter 4 · Tools

perception-tools - Perception Tools MCP Server

chapter4/perception-tools/

Build a comprehensive set of perception tools, providing capabilities for web search, multimodal understanding, file system operations, and access to public data sources. Most features are based on free, open APIs (DuckDuckGo, Open-Meteo, Yahoo Finance, OpenStreetMap, etc.) and require no API key.

Core Concepts: MCP Protocol, Multimodal Parsing, Public Data Sources, Document Understanding, Geospatial Services

execution-tools - Execution Tools MCP Server

chapter4/execution-tools/

Implement a set of execution tools with safety mechanisms, including file operations, a code interpreter, a virtual terminal, and external system integration. Prevent dangerous operations through a secondary LLM approval mechanism, automatically summarize complex outputs, and perform syntax validation on code.

Core Concepts: MCP Protocol, Execution Safety, LLM Approval, Result Summarization, Automatic Validation

collaboration-tools - Collaboration Tools MCP Server

chapter4/collaboration-tools/

Provide comprehensive collaboration capabilities, including browser automation (browser-use framework), Human-in-the-Loop, multi-channel notifications (Email, Telegram, Slack, Discord), and timer management. Supports admin approval for sensitive operations and scheduled task dispatching.

Core Concepts: MCP Protocol, Browser Automation, HITL Mode, Multi-Channel Notification, Scheduled Tasks

agent-with-event-trigger - Event-Triggered Agent with MCP Integration

chapter4/agent-with-event-trigger/

A modern event-driven Agent built with FastAPI, integrating all tools from the first three MCP servers by default. It uses a native asynchronous architecture for clean MCP tool loading and receives multi-source events (Web, Instant Messaging, GitHub, Timers, etc.) via HTTP API. Provides automatic API documentation (Swagger UI) and background monitoring capabilities.

Core Concepts: FastAPI, Native Async, MCP Integration, Event-Driven, Automatic API Documentation, Tool Orchestration

active-tool-selection - Active Tool Selection

chapter4/active-tool-selection/

Implement an intelligent tool selection mechanism that allows the Agent to actively choose the most suitable combination of tools based on task requirements, rather than passively accepting a predefined tool set.

Core Concepts: Tool Selection, Dynamic Tool Loading, Task Analysis

async-agent - Asynchronous Agent with Parallel Execution and Interruption

chapter4/async-agent/

Implement the core of an event-driven asynchronous Agent framework (Flux) based on a single-threaded asyncio model: an inbox event queue dispatches tasks by urgency (interrupt/immediate/queue), supports parallel execution of asynchronous tools, allows interrupting the current turn during execution, and provides cancellation and status querying for simulated long-running tasks. Decision-making is performed by a real LLM (function calling).

Core Concepts: Asynchronous Programming, Event Queue, Interruption Mechanism, Parallel Tool Cancellation, Non-blocking I/O

Additionally, chapter4/docker-compose.yml and chapter4/DOCKER_DEPLOYMENT.md provide a reference solution for containerizing and deploying the aforementioned MCP tool servers.

💻 Chapter 5 · Coding Agent & Code Generation

coding-agent - Production-Grade Coding Agent

chapter5/coding-agent/

A production-grade AI coding assistant built on Claude, implemented entirely in pure Python with no command-line dependencies. Includes 17 fully implemented tools covering file operations, search, shell operations, and project management. Features a pure Python Grep tool fully compatible with ripgrep's functionality.

Key Features:

  • Pure Python implementation, no command-line dependencies, especially suitable for Mac users
  • Complete tool suite: file read/write/edit, pure Python regex search, directory listing, shell session management
  • System prompt techniques: timestamps, tool call counting, TODO list management, detailed error messages
  • Persistent shell environment, automatic lint detection, streaming response support
  • Supports multiple LLM providers (Anthropic, OpenAI, OpenRouter)

Core Concepts: Code Generation, File Editing, Pure Python Tools, System Prompts, Lint Detection, Multi-Provider Support

code-for-math - Enhancing Math Problem Solving with Code

chapter5/code-for-math/

Compare "pure chain-of-thought" vs. "code-assisted" modes using the same model on the same set of competitive math problems. In the latter mode, problems are formalized into Python (sympy/numpy/scipy) and executed via function calling in a subprocess sandbox, replacing error-prone mental calculation with precise computation, resulting in significantly higher accuracy.

Core Concepts: Code Interpreter, Symbolic Computation, Chain-of-Thought Comparison, Tool-Augmented Reasoning

code-for-logic - Enhancing Logical Reasoning with Code

chapter5/code-for-logic/

Transform "Knights and Knaves" logic puzzles into Constraint Satisfaction Problems (CSP). The Agent uses python-constraint to define variables and biconditional constraints, then invokes the solver. Compare the accuracy of pure natural language reasoning vs. code-assisted modes on a set of K&K puzzles.

Core Concepts: Constraint Solving, CSP Modeling, Formalized Reasoning, Code Assistance

small-model-codified-rules - Codified Rules for Small Models

chapter5/small-model-codified-rules/

A controlled experiment based on the τ-bench airline customer service scenario: after moving complex business policies (refund rules) from natural language prompts into code/tools, the task success rate and policy adherence of a small model improved dramatically. In-tool code validation can intercept the model's erroneous beliefs in real-time.

Core Concepts: Codified Business Rules, Policy Enforcement, In-Tool Validation, Small Model Reliability

paper-to-ppt - Automatic Paper-to-PPT Generation (Proposer-Reviewer)

chapter5/paper-to-ppt/

Reframe "making a PPT" as a code generation problem: The Proposer writes Slidev (Markdown+HTML) code, the Reviewer renders each page into a PNG and uses a Vision LLM to check for layout issues, iterating on revisions based on structured feedback. This dual-agent division of labor results in a significantly lower peak context size.

Core Concepts: Code Generation, Slidev, Proposer-Reviewer, Visual Quality Control

paper-to-video - Automatic Paper Explanation Video Generation

chapter5/paper-to-video/

Building on "Paper → PPT", generate colloquial narration scripts for each slide, synthesize speech using TTS, and then use ffmpeg to synchronize each slide's screenshot with its audio, page by page, to create a narrated explanation video.

Core Concepts: Multimedia Generation, Narration Script Generation, TTS, ffmpeg Audio-Video Sync

video-edit - API-Based Intelligent Video Editing

chapter5/video-edit/

Given a multi-scene video and a natural language request, the Agent uses a "two-step Vision localization" process (coarse-to-fine frame extraction and reading) to determine the target scene's time boundaries. After cutting the segment, the Reviewer extracts keyframes from the resulting clip for verification, iterating if the result is unsatisfactory.

Core Concepts: Video Editing, Vision Localization, Coarse-to-Fine, Proposer-Reviewer

adaptive-log-parser - Adaptive Log Parsing System

chapter5/adaptive-log-parser/

A self-evolving log parsing system: when encountering a new, unparseable format, it doesn't raise an error. Instead, it feeds the failed sample and error message to a code generation Agent to produce a parse function. After automatic testing passes, the function is hot-updated and registered into the parsing engine, requiring no human intervention throughout the entire process.

Core Concepts: Code as System Adapter, Self-Healing Loop, Code Hot Update, Automatic Testing

log-diagnosis - Production Log Intelligent Diagnosis System

chapter5/log-diagnosis/

A diagnostic Agent reads production trace logs, architecture documents, and PRDs. It automatically locates problems and root causes, generates structured reports and regression test cases, uses a replay framework for actual execution verification, and (mocked) creates Issues on GitHub via MCP integration.

Core Concepts: Trace Diagnosis, Root Cause Localization, Regression Test Generation, Replay Verification

dynamic-form - Dynamic Form for Intent Clarification

chapter5/dynamic-form/

When faced with an incomplete request, the Agent doesn't ask questions one by one. Instead, it dynamically generates a self-contained HTML form with cascading logic, allowing the user to fill in all missing information at once. The frontend aggregates the form data into JSON and returns it to the Agent to continue the task.

Core Concepts: Code Generation, Intent Clarification, Dynamic Form, Cascading Logic

erp-agent - Natural Language ERP Agent (NL → SQL)

chapter5/erp-agent/

Translate Chinese natural language queries into SQL for database execution, directly presenting the resulting table. The core is the artifact pattern: the LLM only generates the SQL artifact without moving the data itself, saving tokens and avoiding manual calculation errors. Even result sets with tens of thousands of rows can be returned instantly.

Core Concepts: NL2SQL, Artifact Pattern, Database Execution, Cost & Accuracy

conversational-ui - Conversational UI Customization System

chapter5/conversational-ui/

Users propose UI customization requests (color/font/text/layout) in natural language. The Agent autonomously locates and modifies the React frontend source code. Leveraging Vite's Hot Module Replacement (HMR), changes take effect instantly, supporting multi-turn iterative customization.

Core Concepts: Code Modification, Frontend Customization, Hot Reloading, Multi-Turn Iteration

🎯 Chapter 6 · Agent Evaluation

terminal-bench - Terminal Environment Benchmark

chapter6/terminal-bench/

Terminal-Bench is a benchmark for testing AI Agent performance in real terminal environments. From compiling code to training models and setting up servers, it evaluates how Agents handle real end-to-end tasks. Includes a dataset of ~100 tasks and an execution framework, supporting various Agent implementations.

Core Concepts: Terminal Automation, Task Evaluation, Docker Sandbox, Benchmarking

SWE-bench - Software Engineering Benchmark

chapter6/SWE-bench/

SWE-bench is a benchmark for evaluating the ability of large language models to solve real GitHub issues. Given a codebase and an issue description, the model must generate a patch that resolves the problem. Includes multiple versions: SWE-bench, SWE-bench Lite, SWE-bench Verified, and SWE-bench Multimodal.

Core Concepts: Code Repair, GitHub Issues, Patch Generation, Docker Evaluation

GAIA - General AI Assistants Benchmark

chapter6/GAIA/

GAIA aims to evaluate next-generation LLMs (those with tool augmentation, efficient prompting, search access, etc.). It contains 450+ non-trivial questions requiring varying degrees of tool use and autonomy, with unambiguous answers. Divided into 3 difficulty levels.

Core Concepts: Tool Use, Multi-Step Reasoning, Autonomy Evaluation

OSWorld - Operating System-Level Agent Benchmark

chapter6/OSWorld/``chapter6/OSWorld/

Evaluates the ability of agents to perform complex tasks within a complete operating system environment, including file management, application operation, and system configuration.

Core Concepts: Operating system automation, multi-application collaboration, system-level tasks

android_world - Android Environment Benchmark

chapter6/android_world/ (📖 External repository, see "Obtaining External Repositories")

Evaluates agent performance in an Android mobile environment, including app navigation, UI interaction, and task completion capabilities.

Core Concepts: Mobile automation, Android UI, application interaction

chapter6/android-world/ (hyphenated naming) is not the benchmark code, but rather the book's analysis notes (t3a*.md) on T3A Agent failure cases on android_world, which can be used as reference reading material.

tau2-bench - Tool-Augmented Reasoning Benchmark

chapter6/tau2-bench/

Focuses on evaluating an agent's ability to use tools for complex reasoning, including scenarios such as computation, search, and data processing.

Core Concepts: Tool-augmented reasoning, multi-step tasks, tool composition

elo-leaderboard - ELO Leaderboard System

chapter6/elo-leaderboard/

Implements an agent performance leaderboard based on the ELO rating system, evaluating the relative abilities of different agents through pairwise comparisons.

Core Concepts: ELO rating, relative evaluation, leaderboard system

model-benchmark - Multi-Dimensional Model Performance Benchmark

chapter6/model-benchmark/

Conducts a horizontal benchmark of multiple OpenAI-compatible LLM API providers. It uses a streaming interface to precisely measure Time to First Token (TTFT), calculates end-to-end latency percentiles (p50/p95), throughput, and success rate under concurrency. A single command produces a multi-dimensional comparison table, illustrating that model selection is a multi-faceted trade-off rather than just looking at a leaderboard.

Core Concepts: TTFT, latency percentiles, throughput, concurrency stress testing, model selection

agent-cost-analysis - End-to-End Agent Task Cost Analysis

chapter6/agent-cost-analysis/

Performs a full-chain cost breakdown for a typical multi-turn agent task (customer service refund): uses a custom lightweight tracing system to record input/output/cache tokens, latency, and cost for each LLM call, aggregates to identify "which step is the most expensive," and then uses A/B testing to quantify the real savings from KV-cache-friendly design and context compression.

Core Concepts: Observability, cost breakdown, prompt caching, A/B comparison

tts-quality-eval - Fully Automated TTS Quality Evaluation Pipeline

chapter6/tts-quality-eval/

Synthesizes the same set of challenging texts using various TTS configurations (different model/voice/speed), then uses a multimodal LLM-as-a-Judge to score each dimension (clarity, naturalness, etc.) according to a Rubric, aggregating the results into a reproducible configuration comparison table.

Core Concepts: LLM-as-a-Judge, Rubric scoring, TTS evaluation, multi-dimensional comparison

🧠 Chapter 7 · Model Post-Training

This chapter contains several model post-training projects, covering various techniques and application scenarios for Supervised Fine-Tuning (SFT) and Reinforcement Learning (RL).

AdaptThink - Adaptive Reasoning Depth

chapter7/AdaptThink/ and chapter7/AdaptThink-original/

Teaches reasoning models to adaptively choose their reasoning mode (Thinking vs NoThinking) based on problem difficulty. Through constrained optimization and importance sampling, it significantly reduces reasoning costs (45-69%) while improving accuracy. Based on the DeepSeek-R1-Distill-Qwen model, trained using the DAPO algorithm.

Core Concepts: Adaptive reasoning, reasoning cost optimization, constrained optimization, importance sampling

retool - Tool-Augmented Mathematical Reasoning

chapter7/retool/

Uses multi-turn dialogue and a code sandbox to enhance the mathematical reasoning ability of large language models. Through a two-stage training process of SFT and RL, the model learns to use a code execution environment to assist in solving mathematical problems. Based on Qwen2.5-32B-Instruct, trained on the AIME 2024 dataset, using the DAPO algorithm and SandboxFusion sandbox.

Core Concepts: Tool use, code execution, mathematical reasoning, multi-turn dialogue, DAPO algorithm

AWorld / AWorld-train - Embodied Agent Training

chapter7/AWorld/ and chapter7/AWorld-train/

Trains embodied agents based on the AWorld framework, enabling agents to perform complex tasks in a virtual environment and learn from experience.

Core Concepts: Embodied intelligence, environment interaction, experiential learning

SFTvsRL - SFT vs RL Comparative Study

chapter7/SFTvsRL/

Systematically compares the effectiveness of Supervised Fine-Tuning (SFT) and Reinforcement Learning (RL) on different tasks, analyzing the strengths, weaknesses, and suitable application scenarios of both methods.

Core Concepts: SFT vs RL, training method comparison, performance analysis

verl - Efficient RL Training Framework

chapter7/verl/

verl is an efficient reinforcement learning framework specifically designed for RLHF training of large language models, supporting various algorithms such as PPO, GRPO, and DAPO.

Core Concepts: RLHF, PPO, distributed training, efficient optimization

Intuitor - Intuitive Reasoning Training

chapter7/Intuitor/

Trains the intuitive reasoning ability of models, enabling them to make quick, reasonable judgments without requiring detailed chains of thought.

Core Concepts: Intuitive reasoning, rapid decision-making, chain-of-thought optimization

MultilingualReasoning - Multilingual Reasoning

chapter7/MultilingualReasoning/

Trains the reasoning ability of models in multiple language environments, improving performance on cross-lingual tasks.

Core Concepts: Multilingualism, cross-lingual reasoning, language generalization

SpatialReasoning - Spatial Reasoning Training

chapter7/SpatialReasoning/

Focuses on training the spatial reasoning ability of models to handle problems involving spatial relationships such as position, direction, and distance.

Core Concepts: Spatial reasoning, geometric understanding, positional relationships

SimpleVLA-RL - Vision-Language-Action RL

chapter7/SimpleVLA-RL/

Combines vision, language, and action in reinforcement learning training, enabling models to understand visual input and execute corresponding actions.

Core Concepts: Vision-Language-Action, multimodal RL, embodied intelligence

continued-pretraining - Continued Pretraining

chapter7/continued-pretraining/

Performs continued pretraining on domain-specific data to improve model performance in the target domain.

Core Concepts: Continued pretraining, domain adaptation, knowledge injection

MiniMind-pretrain - Small Model Pretraining

chapter7/MiniMind-pretrain/

Pretrains a small language model from scratch to understand the complete pretraining process and key technologies.

Core Concepts: Pretraining, small models, training pipeline

sesame - Sequence Modeling and Evaluation

chapter7/sesame/

Focuses on training and evaluation methods for sequence modeling tasks.

Core Concepts: Sequence modeling, evaluation methods, performance optimization

orpheus - Music Generation and Understanding

chapter7/orpheus/

Trains models for music generation and understanding.

Core Concepts: Music generation, audio understanding, creative AI

tinker-cookbook - Training Tips Collection

chapter7/tinker-cookbook/

Collects various practical tips and best practices for model training.

Core Concepts: Training tips, best practices, tuning methods

🔄 Chapter 8 · Agent Self-Evolution

This chapter focuses on enabling agents to continuously grow from experience without modifying weights: distilling successful trajectories into reusable experiences, externalizing repetitive operations as tools, and distilling prompts and observations into the model.

gaia-experience - Learning from Successful Experiences

chapter8/gaia-experience/

Based on the AWorld framework and GAIA benchmark, implements a complete "learn-apply" loop. The agent automatically summarizes successful task trajectories into structured experiences and retrieves and applies them in new tasks, achieving self-evolution.

Core Concepts: Experiential learning, strategy summarization, trajectory summarization, self-evolution

browser-use-rpa - Workflow Recording and Replay

chapter8/browser-use-rpa/

Implements a workflow recording system for browser automation, automatically encapsulating repetitive operation sequences into parameterized tools. By switching from expensive LLM inference to precise automated execution, it achieves a 3-5x speed improvement.

Core Concepts: Workflow recording, RPA, tool generation, externalized learning

prompt-distillation - Prompt Distillation

chapter8/prompt-distillation/

Distills the effectiveness of complex prompts into model parameters, reducing prompt length during inference and solidifying contextual experience into parameterized knowledge.

Core Concepts: Knowledge distillation, prompt optimization, parameterized knowledge

prompt-auto-optimization - Automatic System Prompt Optimization

chapter8/prompt-auto-optimization/

Automated system prompt learning based on human feedback: Using the tau-bench style airline customer service "over-transfer" problem as an example, a Coding Agent reads the system prompt file, identifies problematic rules, generates precise modifications, and actually rewrites the prompt file. It then re-evaluates the changes, forming a "feedback → rewrite → verify" loop.

Core Concepts: Automatic prompt optimization, human feedback, Coding Agent, closed-loop evaluation

active-tool-discovery - Active Tool Discovery

chapter8/active-tool-discovery/

Compares two paradigms: "injecting all 120+ tool schemas" vs. "active on-demand discovery." The latter keeps only a few basic tools and a discover_tools meta-tool in the system prompt, using embedding similarity to retrieve the 3-5 most relevant specialized tools from a tool library. This saves tokens and prevents the model from incorrectly selecting or misusing general tools from an overly long list.

Core Concepts: Active tool discovery, embedding retrieval, token optimization, instruction following

self-evolving-tools - Self-Evolution by Finding Tools on the Web

chapter8/self-evolving-tools/

An Alita-style "minimal predefined, maximum self-evolution" approach: The agent has no pre-built domain-specific tools, only five general meta-tools. When encountering a task it cannot perform, it searches the web for open-source libraries/APIs, reads documentation, tests them in a sandbox, encapsulates feasible solutions as new tools, stores them in the tool library for reuse, and emphasizes hallucination control throughout the process.

Core Concepts: Self-evolution, tool creation, tool reuse, hallucination control

self-evolution-eval - Self-Evolving Agent Evaluation Dataset

chapter8/self-evolution-eval/

A dedicated dataset and validation methodology designed to evaluate an agent's "self-evolution" capability (discovering, creating, and reusing tools on its own): 20 cross-domain tasks (without hinting at tool names) + a four-layer hierarchical validation harness + a controllable reference agent. It goes beyond checking "if the result is correct" to assess the quality of discovery, creation, and reuse.

Core Concepts: Evaluation dataset design, hierarchical validation, tool reuse metrics, self-evolution

🎙️ Chapter 9 · Multimodal and Real-Time Interaction

live-audio - Real-Time Voice Dialogue

chapter9/live-audio/

A real-time voice chat demo integrating speech-to-text, AI dialogue, and text-to-speech. Supports multiple AI service providers (OpenAI, OpenRouter, ARK, Siliconflow), providing a low-latency conversational experience.

Key Features:

  • Real-time voice input with VAD (Voice Activity Detection)
  • Multi-provider support: ASR (OpenAI Whisper, SenseVoice), LLM (GPT-4o, Gemini, Doubao), TTS (Fish Audio)
  • WebSocket real-time communication, low-latency audio streaming
  • Real-time latency monitoring and logging

Core Concepts: Speech recognition, real-time dialogue, TTS, WebSocket, multi-provider architecture

browser-use - Browser Automation Agent (Computer Use)

chapter9/browser-use/

Browser-Use is a powerful browser automation framework that enables LLMs to control a browser to complete complex tasks. It supports scenarios like form filling, web navigation, and data extraction, serving as a typical implementation of GUI automation (Computer Use).

Key Features:

  • LLM-driven browser automation
  • Supports various LLMs (ChatBrowserUse, OpenAI, Google, local models)
  • Custom tool extensions, authentication handling
  • Sandbox deployment support, cloud service integration

Core Concepts: Browser automation, Computer Use, visual understanding, tool extension

claude-quickstarts - Claude Quickstarts

chapter9/claude-quickstarts/

Quickstart examples and best practices for the Claude API, covering various use cases.

Core Concepts: Claude API, prompt engineering, best practices

phone-agent - Phone Agent

chapter9/phone-agent/

Demonstrates a voice agent "interacting with the outside world via phone calls on behalf of the user": The upper layer is a standard ReAct agent. Upon receiving a natural language task, it autonomously determines the number and purpose of the call, invokes a make_phone_call tool (based on a telephony API abstraction) to complete the entire conversation, reads the structured call log, asks follow-up questions as needed by making another call, and finally reports back to the user.

Core Concepts: Voice agent, phone interaction, ReAct, tool abstraction

end-to-end-speech - End-to-End Speech Thinking vs. Cascaded Pipeline

chapter9/end-to-end-speech/Corresponding to the end-to-end speech reasoning paradigm of Step-Audio R1 (single model "listen → think → speak"): run through the closed loop of "speech input → thinking → speech output", and intuitively compare the latency and loss of paralinguistic information (emotion/tone/speech rate) with the cascaded ASR→LLM→TTS paradigm.

Core Concepts: End-to-end speech, cascaded comparison, paralinguistic information, thinking while speaking

streaming-speech - Simulating Streaming Speech Perception

chapter9/streaming-speech/

Demonstrates the core trade-off of streaming speech perception: chunk continuous audio into segments of increasing length and feed them to the ASR. Each received segment produces a "current partial recognition result" to achieve extremely low first-chunk latency for early text output. The cost is that early chunks, lacking the context of the latter half of the sentence, may be erroneous, gradually converging as audio accumulates. This contrasts with the high-accuracy/high-latency approach of "waiting for the entire sentence before recognition."

Core Concepts: Streaming perception, chunked recognition, first-chunk latency, cost of premature decisions

controllable-tts - Control-Token-Driven Controllable TTS

chapter9/controllable-tts/

The main LLM's output carries control tokens (emotion/speech rate/style/pause/laughter). The execution layer parses these tokens, maps them to corresponding style profiles in a reference speech library, and then synthesizes speech. This delegates decisions about "where to pause and what tone to use" to the LLM, allowing the same text to be synthesized in different styles and emotions.

Core Concepts: Controllable TTS, control tokens, reference speech library, prosody control

🤝 Chapter 10 · Multi-Agent Collaboration

use-computer-while-calling - Dual-Agent Architecture

chapter10/use-computer-while-calling/ (📖 The complete code has been separated into 19PINE-AI/TalkAct; this directory only retains the documentation)

Implements a dual-agent collaboration architecture with a Phone Call Agent and a Computer Use Agent. The two agents communicate directly via WebSocket without a coordinator. The Phone Agent handles voice interaction, while the Computer Agent performs browser automation, working in parallel to complete complex tasks requiring both voice and web operations.

Core Features:

  • Direct inter-agent communication (no coordinator)
  • Standard tool calls for message passing
  • Parallel operation: voice dialogue + browser automation
  • Simple JSON message protocol

Architecture Components:

  • Phone Call Agent (Node.js): Voice I/O, ASR/TTS, LLM dialogue
  • Computer Use Agent (Python): Browser automation, browser-use, web scraping
  • WebSocket Communication: Direct message passing between agents

Core Concepts: Multi-agent collaboration, inter-agent communication, parallel task processing, voice + browser integration

staged-system-prompt - Switching System Prompts by Execution Stage

chapter10/staged-system-prompt/

The same Coding Agent loads different system prompts and tool sets at different execution stages of a task (requirements clarification → code implementation → code review). This allows it to play different roles and exhibit different behaviors within a single conversation, while the dialogue history and task state are continuously shared between stages. If the review fails, it can fall back to the implementation stage.

Core Concepts: Staged prompts, role switching, shared context, stage pipeline

multi-role-transfer - Multi-Role Transfer and Autonomous Handoff

chapter10/multi-role-transfer/

Demonstrates chained handoff under a shared context: a single session contains multiple specialized role agents, each with its own system prompt and dedicated tool set. Using a transfer_to_agent tool, an agent autonomously decides when to switch to another role based on task progress. Because they share the same dialogue history, the complete context is naturally preserved during handoff.

Core Concepts: Role handoff, handoff, shared context, autonomous switching

book-translation - Book Translation Agent (Orchestrator Mode)

chapter10/book-translation/

Uses the orchestrator mode to decompose long document translation into specialized agents for glossary/translation/proofreading. The Manager only saves tasks, plans, call records, and file indices; the complete translated text is written to disk, keeping the context roughly constant. It compares this with a single-agent approach, using real token counts to illustrate how to control context explosion and ensure consistency across the book with a shared glossary.

Core Concepts: Orchestrator mode, context isolation, context explosion control, shared glossary

parallel-web-research - Parallel Multi-Source Information Gathering Agent

chapter10/parallel-web-research/

Demonstrates parallel search by multiple homogeneous agents with central coordination: the main coordinator simultaneously launches N sub-agents, each accessing one source to find an answer. Once one hits the target, the others gracefully stop. Message bus, parallel dispatch, real-time monitoring, cascading termination, and race condition handling are all implemented realistically (using controllable simulated information sources instead of a real browser).

Core Concepts: Parallel agents, central coordination, message bus, cascading termination

voice-werewolf - Voice Werewolf Agent System

chapter10/voice-werewolf/

Uses a multi-agent werewolf game to demonstrate information access control under "non-shared context": each player is an independent LLM agent with a strictly isolated private context. A code-driven deterministic judge decides which information is delivered to which player's context, registers it for auditing, and automatically verifies isolation correctness at the end of the game. Voice is an optional enhancement.

Core Concepts: Information asymmetry, private context isolation, judge orchestration, audit verification

📖 Learning Suggestions

Core Concept: Agent = Model + Context + Tools

The core framework of this book is Agent = Model + Context + Tools. These three components collaborate to realize the intelligent behavior of an agent:

  • Model: The brain of the agent, providing understanding, reasoning, and decision-making capabilities.
  • Context: The operating system of the agent, containing system instructions, dialogue history, reasoning processes, tool interaction records, etc.
  • Tools: The hands of the agent, enabling it to perceive the environment, execute actions, and interact with the external world.

Learning Path

The learning path corresponds chapter by chapter to the entire book, unfolding layer by layer around the three pillars:

  • Chapter 1 · Foundations: Establish a complete cognitive framework for agent systems—understand the definition of an agent in RL, compare the sample efficiency differences between traditional RL and LLM+RL paradigms, grasp the new paradigm of "model as agent," and master the core framework of Agent = Model + Context + Tools. Key Insight: The importance of prior knowledge surpasses algorithms and environments.

  • Chapters 2–3 · Context: Context is the agent's operating system. Chapter 2 covers system prompts, KV Cache-friendly design, context compression, and prompt engineering ablation. Chapter 3 covers user memory, dense/sparse/hybrid retrieval, Agentic RAG, context-aware retrieval, and structured knowledge extraction. Key Insight: Complete context includes system instructions, dialogue history, reasoning processes, tool interaction records, user memory, and external knowledge.

  • Chapters 4–5 · Tools: Tools are the bridge for the agent to interact with the world. Chapter 4 covers three types of MCP tools (perception/execution/collaboration), event triggering, and asynchronous architecture. Chapter 5 delves into the complete implementation of a production-grade Coding Agent. Key Insight: Tool design should be generalized (a code interpreter is better than a calculator); code is the meta-ability to create new tools.

  • Chapters 6–7 · Model: How to measure and amplify intelligence. Chapter 6 covers evaluation benchmarks like Terminal-Bench, SWE-bench, GAIA, OSWorld, and Tau2-Bench. Chapter 7 covers post-training techniques like SFT, RL, RLHF, and sample efficiency. Key Insight: An independent verification signal is more reliable than "asking the model to think again"; "model as agent" internalizes tool calls as native capabilities through RL.

  • Chapter 8 · Self-Evolution: Enable agents to grow from experience without changing weights—experience learning, externalizing workflows as tools, distilling prompts and observations into parameters. Key Insight: Learning from experience is the key for an agent to move from being "smart" to being "skilled."

  • Chapters 9–10 · Expansion and Collaboration: Chapter 9 expands perception and action from text to speech, GUI, and the physical world. Chapter 10 uses multi-agent division of labor to handle complex tasks. Key Insight: Every design decision in a multi-agent system can find its counterpart in the three elements of a single agent.

Difficulty Levels

  • Beginner (Chapters 1–2): Suitable for beginners, understanding basic concepts.
  • Intermediate (Chapters 3–4): Requires some programming foundation, involves system integration.
  • Advanced (Chapters 5–6): Requires strong programming skills, involves complex system design.
  • Expert (Chapters 7–8): Requires deep learning and training/self-evolution experience.
  • Application (Chapters 9–10): Comprehensive application of previous knowledge to build practical applications.

Practical Suggestions

  1. Hands-on Practice: Each project is designed to be run independently. It is recommended to run and modify the code yourself.
  2. Combine with the Book: Read the corresponding chapters in the manuscript in the book/ directory of this repository to understand the combination of theory and practice.
  3. Experimental Comparison: Many projects include ablation studies and comparative experiments. Deepen understanding through comparison.
  4. Progressive Learning: Start with simple projects and gradually delve into complex systems.
  5. Focus on Protocols: The MCP server project in Chapter 4 demonstrates standardized tool protocols, which are key to building scalable agents.

🔑 API Keys

It is recommended to apply for API keys from several platforms for convenient learning:

  • Kimi: https://platform.moonshot.cn/ Moonshot AI's Kimi series, strong in long context and agent capabilities.
  • Zhipu GLM: https://open.bigmodel.cn/ Zhipu AI's GLM series (GLM-4.6, etc.), strong Chinese language ability, good cost-effectiveness, highly recommended.
  • Siliconflow: https://siliconflow.cn/ Offers various open-source models, including DeepSeek, Qwen, etc.
  • Volcengine: https://www.volcengine.com/product/ark Offers ByteDance's closed-source models (Doubao), low latency for domestic access.
  • OpenRouter: https://openrouter.ai/ Allows access to various overseas closed-source and open-source models from mainland China, including Gemini 2.5 Pro, Claude 4 Sonnet, OpenAI GPT-5, etc. (Official APIs require overseas IP and payment methods; OpenAI also requires overseas identity verification, making registration more cumbersome.)

For model selection, refer to: https://01.me/2025/07/llm-api-setup/

📦 Appendix · Obtaining External Repositories

Due to size and copyright considerations, the evaluation benchmarks and training frameworks used in Chapters 6, 7, and 9 are not included in this repository. You need to clone them into the corresponding directories yourself (the upstream addresses and commits verified for this book are provided below). You can save the following commands as a script and pull them all at once:

# Chapter 6 · Evaluation Benchmarks
git clone https://github.com/google-research/android_world.git         chapter6/android_world
git clone https://huggingface.co/datasets/gaia-benchmark/GAIA          chapter6/GAIA
git clone https://github.com/xlang-ai/OSWorld.git                      chapter6/OSWorld
git clone https://github.com/SWE-bench/SWE-bench.git                   chapter6/SWE-bench
git clone https://github.com/sierra-research/tau2-bench.git            chapter6/tau2-bench
git clone https://github.com/laude-institute/terminal-bench.git        chapter6/terminal-bench

# Chapter 7 · Training Frameworks (bojieli/* are branches adapted for this book)
git clone https://github.com/bojieli/minimind.git                      chapter7/MiniMind-pretrain/minimind      # Experiment 7-3 Train LLM from scratch
git clone https://github.com/bojieli/minimind-v.git                    chapter7/MiniMind-pretrain/minimind-v    # Experiment 7-4 Train VLM from scratch (projection layer)
git clone https://github.com/bojieli/AdaptThink.git                    chapter7/AdaptThink-original
git clone https://github.com/bojieli/AWorld.git                        chapter7/AWorld
git clone https://github.com/bojieli/SFTvsRL.git                       chapter7/SFTvsRL
git clone https://github.com/bojieli/verl.git                          chapter7/verl
git clone https://github.com/thinking-machines-lab/tinker-cookbook.git chapter7/tinker-cookbook
```git clone https://github.com/bojieli/lighteval.git                     chapter7/Intuitor/lighteval
git clone https://github.com/19PINE-AI/rlvp.git                        chapter7/RLVP/rlvp                       # Experiment 7-14 RLVP paper code
git clone https://github.com/PRIME-RL/SimpleVLA-RL.git                 chapter7/SimpleVLA-RL/SimpleVLA-RL       # Experiment 7-13 Vision-Language-Action RL

# Chapter 9 · Browser Automation & Claude Examples
git clone https://github.com/browser-use/browser-use.git               chapter9/browser-use
git clone https://github.com/anthropics/claude-quickstarts.git         chapter9/claude-quickstarts

# Chapter 10 · Dual-Agent Architecture (now independent as TalkAct project) + Stanford AI Town
git clone https://github.com/19PINE-AI/TalkAct.git                     chapter10/use-computer-while-calling
git clone https://github.com/joonspk-research/generative_agents.git    chapter10/generative_agents             # Experiment 10-7 Stanford AI Town

If a project's README specifies a particular commit, please git checkout to that version to ensure reproducible results. The use-computer-while-calling directory in Chapter 10 has evolved into the independently maintained repository 19PINE-AI/TalkAct. This repository only retains a pointer document (chapter10/use-computer-while-calling/README.md).

Experiments Requiring Real Hardware / External Environments (no code in this repo, refer to upstream docs):

  • Experiment 9-8 / 9-9 · XLeRobot Teleoperation & LLM Agent Control: Requires SO-100/XLeRobot robotic arm. Follow upstream documentation — Teleop · LLM Agent
  • Experiment 9-10 · RGB Zero-Shot Sim2Real Grasping: StoneT2000/lerobot-sim2real (simulation training can be done purely on GPU; real deployment requires SO-100 robotic arm)
  • Experiment 6-11 · OpenVLA + RoboTwin2 Simulation Evaluation: VLA training/environment dependencies are described in the README of chapter7/SimpleVLA-RL (which explains how to obtain and configure OpenVLA and RoboTwin2)

Reader Practice Experiments (given as exercises in the book, reusing existing documented projects, no dedicated directory):

  • Experiment 5-12 · An Agent That Creates Agents: Based on chapter5/coding-agent, extended via bootstrapping
  • Experiments 6-2 / 6-3 / 6-4 / 6-9: Human baseline, memory evaluation, JSON Cards vs RAG, memory selection — adapted from Chapter 3 projects user-memory / user-memory-evaluation / contextual-retrieval
  • Experiment 7-8 · Prompt Distillation: Implementation found in Chapter 8's chapter8/prompt-distillation (cross-chapter reuse)
  • Experiment 7-9 · CoT Distillation [Extension]: The book provides the experimental design and acceptance criteria as a reader extension exercise; no dedicated code yet.

🤝 Contributing

This book and its accompanying code are fully open source. Pull Requests for community collaboration are very welcome. We appreciate the following types of contributions:

  1. Book Content Improvements: Corrections, supplements, clearer explanations, or additions of recent advancements (text in book/chapter*.md)
  2. Code Improvements & Bug Fixes: Making the companion projects more robust, user-friendly, and closer to production practices
  3. New Practice Projects: Supplementing/replacing implementations for an experiment, or contributing entirely new example projects
  4. Book Illustration Design Improvements: Making the diagrams in book/images/ clearer and more aesthetically pleasing (illustrations are generated by book/gen_*_figs.py)

Before submitting, we recommend running the relevant experiment yourself to ensure reproducibility; feel free to open an issue to discuss ideas first.

📄 License

This project is licensed under the Apache License 2.0. See the LICENSE file for details. Some sub-projects may contain their own license information; please refer to the respective sub-project for details.

⭐ Star History

Star History Chart

Chart automatically generated weekly by a GitHub Actions scheduled task in the star-history style and committed to the star-history branch, hosted locally without external rate limits; click to view real-time data on star-history.com.

About

open-source repository for *In-Depth Understanding of AI Agents: Design Principles and Engineering Practices* (by Bojie Li): includes the full text, compiled PDF, and chapter-by-chapter accompanying code.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages