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.
Chapters
- 01Your First LLM Call
- 02Conversation
- 03The System Prompt and Context Builder
- 04Streaming Responses
- 05Provider Abstraction
- 06The Loop
- 07Tool Calling
- 08Observation and Continuation
The first eight 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. 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