Agent Harness Loop Contract

The harness is the agent. The model is a coprocessor. This lesson freezes the loop contract you can wire any model into.

Build 1.5 hr Python

Prerequisites: Phase 13 lessons 01-07, Phase 14 lesson 01

#Learning Objectives

  • Specify an agent harness loop as a deterministic state machine with explicit transitions.
  • Implement ten lifecycle hook topics that operators wire policy, telemetry, and guardrails into.
  • Define two pull points where the loop yields control back to the caller and resumes on a fresh input.
  • Enforce per-session budgets (turns, tool calls, wall-clock) without leaking partial state on exceeding.
  • Emit a typed stream of eleven event types so downstream UIs and tracers can subscribe without inspecting the loop directly.
Full Access lesson

Keep going. The rest of this lesson is one step away.

Unlock all 503 lessons, video, code, quizzes and every future update. Pay in your own currency with Paystack.

The text and code of this lesson are based on AI Engineering from Scratch by Rohit Ghumare, MIT licensed.