This course builds LLM agents from the bottom up. Each module pairs short notes on one idea with one or more Jupyter notebooks in which you build that idea in plain Python: a tool-calling loop, a tokenizer, a retrieval index, a sandbox, an evaluation harness, and finally a small coding agent that fixes a repository until its tests pass. The notebooks share one small package, agentlab, which grows a little with each module.
Every notebook runs offline, with no API key, against a deterministic stand-in for a model, so the outputs on these pages are exactly what you will get. Set one environment variable and the same code runs against a real model.
Start here
Read Module 1, then open Notebook 1. All notebooks are listed on the notebooks page.
Part I: Foundations
- 01 What is an agent? the loop, workflows vs agents, budgets
- 02 LLMs for builders tokens, sampling, the client layer
- 03 Tools and MCP schemas, errors, an MCP server
- 04 The ReAct agent context, tools, the Agent class
Part II: Capabilities
- 05 RAG and knowledge BM25, vectors, agentic retrieval
- 06 Memory and context engineering windows, compaction, sessions
- 07 Planning and reflection plans, todos, recovery
- 08 Code execution and skills sandboxes, CodeAct, skills
- 09 Multi-agent systems handoffs, agents as tools, A2A
Part III: Good, safe, real
- 10 Evaluating agents traces, graders, pass@k
- 11 Optimizing agents prompt search, GRPO, rewards
- 12 Safety and guardrails injection, permissions, egress
- 13 Capstone, a coding agent fix a repo until the tests pass
Running the notebooks
You need uv and nothing else; uv installs the right Python.
uv sync # create .venv with Python 3.13 and agentlab
uv run jupyter lab # open notebooks/build/nb/*.ipynb, or a downloaded notebook
make notebooks # or: rebuild and execute every notebook headlessEach notebook’s first cell prints which model backend it is using. With no configuration it is the offline policy model: a few deterministic rules that read the request and answer the way a tool-calling model would. It is not a language model, and its outputs only show what the agent code does, not how a real model behaves. To use a real model, put a LiteLLM model name and the matching key in .env:
MODEL=anthropic/claude-sonnet-5-5
ANTHROPIC_API_KEY=...Live runs cost money and give different outputs on each run. Each notebook ends with a table of model calls, tokens and cost.
Sources
The spine of the course is Hur and Song, Build an AI Agent (From Scratch) (Manning, 2026); agentlab keeps the shape of the book’s scratch_agents package (MIT licence) so its listings map onto ours. Several modules draw on Stanford CS329Z: Engineering AI Agents and CS336: Language Modeling from Scratch; the optimization module also uses Lambert, Reinforcement Learning from Human Feedback (Manning, 2026). The prose and notebooks here are original; see each module’s readings.