Skip to content

Replaying any step

Part 2’s eight steps are eight commits, and the code runs at every one of them. That is a deliberate constraint, and it makes the repository itself a teaching tool.

Terminal window
git clone https://github.com/nhial/building-ai-agents
cd building-ai-agents
git log --oneline -- part2/ # the syllabus
4d7b7d5 part 2 · step 1: the alert and the fixtures
498a253 part 2 · step 2: the model call
3291bed part 2 · step 3: the tools and their schemas
3b34216 part 2 · step 4: the tool loop
148436b part 2 · step 5: intake and enrichment
5b1e8ca part 2 · step 6: deterministic risk scoring
8bcfb29 part 2 · step 7: the case worker
8c3b685 part 2 · step 7: the orchestrator and the human gate
3082d1f part 2 · step 8: the audit trail

Jump to any of them and run it exactly as it was:

Terminal window
git switch --detach 3b34216 # step 4, the tool loop
cd part2 && uv run --with ollama run.py
cd .. && git switch main # come back

--detach means you are looking at a commit rather than working on a branch — exactly what you want for reading. git switch main returns you.

Watching an idea arrive. The most useful thing in the history is the diff between two adjacent steps:

Terminal window
git diff 5b1e8ca 8bcfb29 -- part2/ # what the Case worker added

Every step is small enough that its diff is readable in one screen. That is the constraint that shaped the commits: if a step needs a long explanation, it’s two steps.

Seeing a failure that no longer exists. Failure 1 — the invented merchant — only happens at step 2, before tools. You cannot reproduce it from the finished code. You can check out step 2 and watch it happen:

Terminal window
git switch --detach 498a253
cd part2 && uv run --with ollama run.py

Every commit runs. No exceptions. A step that errors is not committed.

This costs something while building — sometimes an idea has to be split, or a stub written so the pipeline still completes. It buys a property nothing else gives you: you can never be reading code that doesn’t work. When a step behaves oddly, that is the lesson, not a bug in the course.

The two other rules that go with it:

  • One step, one commit. Message format: step N: what it adds.
  • Small. Each step adds one idea.

You do not need a course to benefit from this. Any prototype someone else will have to understand is improved by commits that each add one thing and each run. The audience is usually you, four months later, trying to remember why a piece exists.

The version worth stealing: when you build something to learn it, commit at every point where it worked. Not at the end. The intermediate states are where the understanding actually lives, and they are gone forever if you squash them into “add fraud triage agent”.