A hands-on book

AI Agent Engineering

Build a personal AI agent from scratch in Python. Each chapter adds a single idea until you have a real agent you understand top to bottom. All file links in Production references are clickable and take you to the exact line in the exact version of the reference codebase.

Start reading → Chapter 1About the author

Chapters

  1. 01Your First LLM Call
  2. 02Conversation
  3. 03The System Prompt and Context Builder
  4. 04Streaming Responses
  5. 05Provider Abstraction

The first five chapters are published here. More are on the way.

About the reference codebase

Each chapter ends with a Production reference that maps the toy code you build to real functions in nanobot, an open-source personal AI agent. The book pins one specific snapshot so the file and function names it cites stay accurate: commit 28f9bbf (28 Apr 2026).

nanobot is under active development, so if a section the book references has since changed upstream, you can always read the exact version the book is describing at the pinned commit:

github.com/HKUDS/nanobot/tree/28f9bbf

To check it out locally:

git clone https://github.com/HKUDS/nanobot.git
cd nanobot
git checkout 28f9bbf