Lesson 15.02 · Phase 15 · Capstone: Your Own Agent Harness

The core loop & tool registry

Write the loop once, with five places to plug things in. Every later feature is a hook or a tool, never a rewrite.

Learning objectives

  • Build a tool registry that infers schemas from Python functions, validates arguments, and turns every failure into an observation.
  • Build workspace file tools with a path jail, paging, and read-before-edit.
  • Write the harness loop with five hook points, a shared token budget, and six stop reasons.
  • Show that the loop survives an unknown tool, broken JSON, a missing argument, a path escape, and a repeating model.

In 15.01 the bare loop crashed on broken JSON, crashed on an unknown tool, and called listfiles fifty times without noticing. Fixing each of those inside the loop is how loops turn into 600-line functions that nobody dares touch.

Loading the full lesson…