R257 · AI education › Learning paths for AI engineers

Build Your Own Agent Harness: a failure-first course and book

Read the original

Authors Jimin Lee

agent-harnesslearning-resourcesteachingagent-reliabilitylocal-inferenceopen-source

R257 · · Source: Jimin Lee's LinkedIn post (share dated 2026-11-22, edited) announcing a free companion book for the MIT-licensed repo jiminelee/agent-harness-course.

In one paragraph

A 15-module Python course that grows one project from a single chat-completion call into a small harness: loop, tools, a registry, context compression, JSON memory, plan/execute/synthesize, retry limits plus a critic, async tool calls, guardrails with human confirmation and an audit log, tracing, sub-agents as tools, a packaged library with cost tracking and caching, and MCP tools. No framework; plain openai SDK against an OpenAI-compatible endpoint, tested on Ollama with gemma4:e4b. The new book is the useful part for experienced readers: every chapter runs the code against a small local model and records what actually went wrong, then traces each safeguard to that failure. The final chapter turns those runs into a ledger of failure to production practice.

Architecture of the course

The failures it documents (the reason to read it)

ChapterWhat the small model didHarness lesson
1Put TASK_COMPLETE at the end, not the start; the parser returned an empty answer with no errorParse defensively; prefer structured signals over text markers
4A rolling summary dropped a completed step; the agent redid searches until MAX_TURNSTrack completed work in code, not in a summary; budget by tokens, not steps
5Followed 2 of 5 memory rules in the prompt (missed a fact under another key, saved without being asked); held against an injected instruction in 2 of 2 runsMove rules into tool behavior (a miss returns all entries)
6Leaked a <|tool_response> fragment as the subtask result in 4 of 6 reruns; the synthesizer recomputed 17×23+100 as 591, then 501Pass evidence, not conclusions; give dependent subtasks prior results; reject empty or <| output between stages
7The critic passed a wrong big product; once wrote "incorrect" with passes: truePut reasoning before the verdict field (fixed 4 of 4); reviewers need tool evidence
9Path validation allowed deleting the running script; the model invented a chat "magic phrase" approvalAllowlist a scratch folder; approval is a code path, never chat text
11Researcher wrote findings from a stub result; orchestrator rewrote notes; 7 calls for one paragraph"Fact laundering" across agent hops; pass outputs through unchanged; make unknown a valid answer
12The response cache stored the leaked fragment and replayed it instantly; a global tool registry leaked tools into every new agentValidate before caching; caching freezes randomness; tools still re-run on a cache hit; pass registries explicitly
13A schema-validation failure looked like a dead connectionClassify errors precisely; discovery is not permission

The book's own summary: almost none of these failures was loud. Production work on agents is mostly making quiet failures visible.

Tradeoffs and limits

Review checklist it implies for any harness

  1. Does the loop parse model output defensively, and fail loudly on an empty final answer?

  2. Is completed work tracked outside the model's context (a list the code owns)?

  3. Which prompt rules matter enough to enforce in tool code instead?

  4. Do stage boundaries pass tool evidence and reject empty or malformed outputs?

  5. Does any structured verdict put reasoning before the decision field?

  6. Are destructive tools behind an allowlist plus a human gate that the model cannot satisfy with text?

  7. Does every agent hop keep provenance, so a guess can't become a "finding"?

  8. Is output validated before it is cached, and are side-effecting tools safe to re-run on a cache hit?

  9. Are traces written as they happen, so a crash keeps them?

  10. Is each of the above a repeatable test case, run several times per prompt or model change?

Where it fits

Links: book · repo · post

Connections

See R257 on the knowledge map

Part of the Research notes on nowucca.com. Figures and claims are the source's own unless the summary says otherwise.