Skip to main content

An Illustrated Guide to AI Agents

Welcome! Here, you will find the code for the book An Illustrated Guide to AI Agents written by Maarten Grootendorst and Jay Alammar. In this repository, you will:

"Build an Agent From Scratch!"

Through the visually educational nature of this book and with more than 300 custom made figures, learn the practical tools and concepts you need to use AI Agents today!

Cover

Table of Contents - Build a TinyAgent from Scratch!

The code examples in this repo are used for you to start building a TinyAgent entirely from scratch, using nothing more than LLM calls. You will learn how to create your own Agent that has memory, tools, and autonomy!

All examples can be run in Google Colab for free using their T4 GPU. You have options for running everything either locally or on the cloud without any additional costs involved.

Chapter Notebook
Chapter 1: Introduction to AI Agents Open In Colab
Chapter 2: Large Language Models Open In Colab
Chapter 3: Reasoning Large Language Models Open In Colab
Chapter 4: Memory Open In Colab
Chapter 5: Tools Open In Colab
Chapter 6: Planning Open In Colab
Chapter 7: Evaluation Open In Colab
Chapter 8: Multi-Agent Collaboration Open In Colab
Chapter 9: Multimodal Understanding Open In Colab
Chapter 10: Coding Agents Open In Colab

[!TIP] You can check the setup folder for a quick-start guide to install all packages locally.

Reviews

"The authors are exceptional builders, and this book is a testament to the depth of their knowledge. The generous illustrations and hands-on TinyAgent exercise make the concepts approachable, intuitive, and fun to learn."

Chip Huyen - author of AI Engineering and Designing Machine Learning Systems


"I have thought a lot about how to teach AI systems, and this book still surprised me with how much of the domain of modern AI agents it could make clear through illustrations. Maarten and Jay do an impressive job identifying and explaining the timeless ideas in this fast-moving field, and I expect this to become the first book I recommend to anyone who wants to understand how modern agents work and how to build them."

Omar Khattab - assistant professor, MIT EECS.


"Grootendorst and Alammar explain the entire AI agent stack, from tokenization to multiagent systems, in an engaging visual style. As the field evolves, this book will continue to serve as a useful reference because it covers the subject matter so thoroughly."

Ofir Press - research scientist at Meta FAIR, coauthor of SWE-bench and SWE-agent.


A Unique Way of Learning

We wanted to do something special this time around and allow readers to Build an Agent From Scratch! However, we did not stop there and wanted the act of building the Agent to be a modular experience that enhances the learning experience. By iteratively adding components, one at a time, it becomes much more intuitive how an Agent actually works.

book

We decided to combine this with creative (if we say so ourselves) ways to explain what is happening and how each added component affects your TinyAgent!

images/tinyagents.png

Through a philosophy centered around modularity, each chapter can neatly cover a single topic. As such, that allows us to do things like annotate code to help you understand what reason is for specific lines of code.

images/annotated.png

As we are building up your TinyAgent there might be many code changes happening in certain chapters. To illustrate the effect of these changes on your TinyAgent, we made use of diffs as a way to ease the learning curve.

images/diffs.png

Citation

Please consider citing the book if you consider it useful for your research:

@book{illustrated-agents-book,
  author       = {Maarten Grootendorst and Jay Alammar},
  title        = {An Illustrated Guide to AI Agents},
  publisher    = {O'Reilly},
  year         = {2026},
  isbn         = {979-8341662698},
  url          = {https://www.oreilly.com/library/view/an-illustrated-guide/9798341662681/},
  github       = {https://github.com/HandsOnLLM/An-Illustrated-Guide-To-AI-Agents}
}

Metadata

Release files for illustrated-agents 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for illustrated-agents 0.1.1
File Size Uploaded
illustrated_agents-0.1.1.tar.gz 40.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for illustrated-agents 0.1.1
File Interpreter ABI Platform
illustrated_agents-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 89.1 kB

Release files / illustrated_agents-0.1.1.tar.gz

Download URL illustrated_agents-0.1.1.tar.gz
Size 40.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f0436521cb79055e2c47cdf55622b5d9fb4d975947c167536fb5d213f73f1594
BLAKE2b-256 checksum
How to use checksums
dfece9166d4f5a581a11b03eb7714a874ef384ec407eba0f204e57e26df2c7b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.9

Release files / illustrated_agents-0.1.1-py3-none-any.whl

Download URL illustrated_agents-0.1.1-py3-none-any.whl
Size 48.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b018222b6747eee5ed994e9f9525d9c925fb0f88ec7019624e5f8f02021fc6b
BLAKE2b-256 checksum
How to use checksums
0e0086fa522e442fcfac4e2696da643a047abfec44e22ebcae4287775b85224e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page