Build Your Own Agent Harness
A hands-on companion to the agent-harness course code
Welcome
This book is a beginner-friendly companion to the code in this repository. Over fifteen chapters, you’ll build an AI agent harness from scratch: a single call to a language model grows into an agent with a loop, tools, memory, planning, error recovery, guardrails, tracing, and helpers of its own, and finally into a small reusable library that can use tools from other programs.
Every chapter goes with one folder of runnable code. Chapter 2 is module02/, Chapter 13 is module13/, and so on. The code shows what each piece does. The book explains why it’s built that way, shows what actually happens when you run it, and helps you when you get stuck.
All the output in these pages comes from real runs on a small local model. That includes the failures: confidently wrong answers, invented “research,” ignored instructions. Those failures are the most useful part of the book, because every safeguard in the code exists to deal with one of them.
Start with Before You Begin to set up your computer, then read Chapters 0–3 in order. After that, you can follow your interests.
The code is written to be easy to read, not to be safe for real users. Run it on your own computer, for learning. Chapter 14 explains what would have to change before it could serve real people.