
Debugging AI
Progress from deterministic debugging to diagnosing models, evidence, trajectories, and AI-generated work.
Debugging AI builds one continuous debugging system from Python tracebacks to production AI incidents.
The progression is deliberate:
- Debug values and state in deterministic software.
- Cross the bridge: debug the interactive and numerical systems in between — notebooks, data, tensors, training, and evaluation — where state accumulates invisibly and every result must be reproduced before it is trusted.
- Debug distributions and uncertainty in learned systems.
- Debug intent and evidence in prompts, retrieval, and hallucinations.
- Debug trajectories in agents.
- Debug causes experimentally and convert diagnoses into prevention.
The debugging objects underneath that progression stay fixed — values, state, distributions, evidence, trajectories. Step 2 is not a new object; it is state stretched from a single binding to an entire accumulated computation, and the on-ramp to the distributional thinking step 3 depends on.
By the end, the reader should be able to move from a symptom to a scoped, reversible, causally-supported diagnosis, design discriminating experiments, and convert confirmed failures into durable regression artifacts.
The five objects are deep-structure categories, not a taxonomy of convenience: skilled diagnosis increasingly depends on classifying the structure of the failure — a value, an accumulated state, a distribution, an evidence chain, a trajectory — rather than reacting to its surface symptom, and each object selects its diagnostic method.
A diagnostic root-cause account, in this book, is an evidence-backed, reversible explanation sufficient to predict the observed failure within a defined diagnostic envelope. It is built by climbing a ladder — a difference, then a relevant difference, then a difference that changes the outcome when changed, then one that survives replication and reversal. It is not a claim that every system exposes one objective earliest cause: where ordering, observability, or intervention break down, the honest output is PROVISIONAL or INCONCLUSIVE, and socio-technical incidents carry a separate list of contributing factors rather than a single root.
Chapters
What Does It Mean to Debug?
Chapter 1 develops what does it mean to debug? within the book's end-to-end AI debugging system.
The First Divergence
Chapter 2 develops the first divergence within the book's end-to-end AI debugging system.
Evidence Before Explanation
Chapter 3 develops evidence before explanation within the book's end-to-end AI debugging system.
The Debugging Stack
Chapter 4 develops the debugging stack within the book's end-to-end AI debugging system.
Reading Python Exceptions
Chapter 5 develops reading python exceptions within the book's end-to-end AI debugging system.
Inspect State, Don't Guess
Chapter 6 develops inspect state, don't guess within the book's end-to-end AI debugging system.
Debug the Boundary
Chapter 7 develops debug the boundary within the book's end-to-end AI debugging system.
Assertions, Invariants, and Contracts
Chapter 8 develops assertions, invariants, and contracts within the book's end-to-end AI debugging system.
Environment Bugs
Chapter 9 develops environment bugs within the book's end-to-end AI debugging system.
The Notebook Is Not the Program You See
Chapter 10 develops the notebook is not the program you see within the book's end-to-end AI debugging system.
Hidden Notebook State
Chapter 11 develops hidden notebook state within the book's end-to-end AI debugging system.
Reproducible Notebooks
Chapter 12 develops reproducible notebooks within the book's end-to-end AI debugging system.
Debug the Data Before the Model
Chapter 13 develops debug the data before the model within the book's end-to-end AI debugging system.
Shapes, Types, Devices, and Tensors
Chapter 14 develops shapes, types, devices, and tensors within the book's end-to-end AI debugging system.
When Training Goes Wrong
Chapter 15 develops when training goes wrong within the book's end-to-end AI debugging system.
Debugging Evaluation
Chapter 16 develops debugging evaluation within the book's end-to-end AI debugging system.
Debugging What You Cannot See
Chapter 17 develops debugging what you cannot see within the book's end-to-end AI debugging system.
Is the Model Actually the Problem?
Chapter 18 develops is the model actually the problem? within the book's end-to-end AI debugging system.
Inspect the Actual Model Input
Chapter 19 develops inspect the actual model input within the book's end-to-end AI debugging system.
Context Windows and Truncation
Chapter 20 develops context windows and truncation within the book's end-to-end AI debugging system.
Sampling Is Part of the Program
Chapter 21 develops sampling is part of the program within the book's end-to-end AI debugging system.
Internal Signals
Chapter 22 develops internal signals within the book's end-to-end AI debugging system.
Representation and Behavioral Diffs
Chapter 23 develops representation and behavioral diffs within the book's end-to-end AI debugging system.
AI as Builder, Designer, Researcher, and Reviewer
Chapter 24 develops ai as builder, designer, researcher, and reviewer within the book's end-to-end AI debugging system.
Debugging Intent
Chapter 25 develops debugging intent within the book's end-to-end AI debugging system.
Debugging Context for Coding Agents
Chapter 26 develops debugging context for coding agents within the book's end-to-end AI debugging system.
Debugging AI-Generated Designs
Chapter 27 develops debugging ai-generated designs within the book's end-to-end AI debugging system.
Debugging AI Research
Chapter 28 develops debugging ai research within the book's end-to-end AI debugging system.
Debugging Coding Agents
Chapter 29 develops debugging coding agents within the book's end-to-end AI debugging system.
Treat Prompts as Programs
Chapter 30 develops treat prompts as programs within the book's end-to-end AI debugging system.
Minimize the Prompt
Chapter 31 develops minimize the prompt within the book's end-to-end AI debugging system.
Retrieval Is a Pipeline
Chapter 32 develops retrieval is a pipeline within the book's end-to-end AI debugging system.
Retriever Failure or Generator Failure?
Chapter 33 develops retriever failure or generator failure? within the book's end-to-end AI debugging system.
Debugging Hallucinations
Chapter 34 develops debugging hallucinations within the book's end-to-end AI debugging system.
The Model's Explanation Is Not a Trace
Chapter 35 develops the model's explanation is not a trace within the book's end-to-end AI debugging system.
An Agent Is a Trajectory
Chapter 36 develops an agent is a trajectory within the book's end-to-end AI debugging system.
Trace the Agent
Chapter 37 develops trace the agent within the book's end-to-end AI debugging system.
Agent Failure Taxonomy
Chapter 38 develops agent failure taxonomy within the book's end-to-end AI debugging system.
Loops, Thrashing, and Retry Storms
Chapter 39 develops loops, thrashing, and retry storms within the book's end-to-end AI debugging system.
Time Travel, Replay, and Forking
Chapter 40 develops time travel, replay, and forking within the book's end-to-end AI debugging system.
Causal Replay
Chapter 41 develops causal replay within the book's end-to-end AI debugging system.
Trajectory Diff
Chapter 42 develops trajectory diff within the book's end-to-end AI debugging system.
Multi-Agent Systems
Chapter 43 develops multi-agent systems within the book's end-to-end AI debugging system.
Can One AI Debug Another?
Chapter 44 develops can one ai debug another? within the book's end-to-end AI debugging system.
The AI Crash Dump
Chapter 45 develops the ai crash dump within the book's end-to-end AI debugging system.
Diagnostic AI Invariants
Chapter 46 develops diagnostic ai invariants within the book's end-to-end AI debugging system.
From Symptom to Hypotheses
Chapter 47 develops from symptom to hypotheses within the book's end-to-end AI debugging system.
Discriminating Experiments
Chapter 48 develops discriminating experiments within the book's end-to-end AI debugging system.
How Do You Know the Diagnosis Is Right?
Chapter 49 develops how do you know the diagnosis is right? within the book's end-to-end AI debugging system.
AIDebugBench
Chapter 50 develops aidebugbench within the book's end-to-end AI debugging system.
Debug the Debugger
Chapter 51 develops debug the debugger within the book's end-to-end AI debugging system.
AI Observability
Chapter 52 develops ai observability within the book's end-to-end AI debugging system.
From Production Failure to Regression
Chapter 53 develops from production failure to regression within the book's end-to-end AI debugging system.
Runtime Invariants and Guardrails
Chapter 54 develops runtime invariants and guardrails within the book's end-to-end AI debugging system.
Debugging Cost and Latency
Chapter 55 develops debugging cost and latency within the book's end-to-end AI debugging system.
Debugging in Production
Chapter 56 develops debugging in production within the book's end-to-end AI debugging system.
The Ten-Minute Debug
Chapter 57 develops the ten-minute debug within the book's end-to-end AI debugging system.
The One-Hour Investigation
Chapter 58 develops the one-hour investigation within the book's end-to-end AI debugging system.
The Full AI Incident Investigation
Chapter 59 develops the full ai incident investigation within the book's end-to-end AI debugging system.
The Debugging AI Toolkit
Chapter 60 develops the debugging ai toolkit within the book's end-to-end AI debugging system.