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
Modules 0 to 3 are cumulative: one call, then a loop with a done marker and
MAX_TURNS, then one tool, then a decorator registry with an executor that turns every tool error into a string the model can read.Modules 4 to 11 are branches off the module 3 loop, each showing one feature alone (the book says so explicitly, so module 6 has no module 5 memory).
Module 12 folds the core into an importable
agent_harnesspackage: config, tools, prompts with versions, cost, cache, loop.Module 13 moves tools into a separate MCP server process (official Python SDK
MCPServerandClient), with a model-free inspector script first.Module 14 is a production roadmap: security, reliability, evaluation, observability, scale and cost, UX, frameworks, in a suggested order.
The failures it documents (the reason to read it)
| Chapter | What the small model did | Harness lesson |
|---|---|---|
| 1 | Put TASK_COMPLETE at the end, not the start; the parser returned an empty answer with no error | Parse defensively; prefer structured signals over text markers |
| 4 | A rolling summary dropped a completed step; the agent redid searches until MAX_TURNS | Track completed work in code, not in a summary; budget by tokens, not steps |
| 5 | Followed 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 runs | Move rules into tool behavior (a miss returns all entries) |
| 6 | Leaked a <|tool_response> fragment as the subtask result in 4 of 6 reruns; the synthesizer recomputed 17×23+100 as 591, then 501 | Pass evidence, not conclusions; give dependent subtasks prior results; reject empty or <| output between stages |
| 7 | The critic passed a wrong big product; once wrote "incorrect" with passes: true | Put reasoning before the verdict field (fixed 4 of 4); reviewers need tool evidence |
| 9 | Path validation allowed deleting the running script; the model invented a chat "magic phrase" approval | Allowlist a scratch folder; approval is a code path, never chat text |
| 11 | Researcher 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 |
| 12 | The response cache stored the leaked fragment and replayed it instantly; a global tool registry leaked tools into every new agent | Validate before caching; caching freezes randomness; tools still re-run on a cache hit; pass registries explicitly |
| 13 | A schema-validation failure looked like a dead connection | Classify 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
One small local model (gemma4:e4b,
reasoning_effort="none"). Several failures (chat-format leaks, marker placement) are much rarer on frontier models; the lessons hold, the frequencies don't transfer.Sample sizes are 2 to 7 runs per experiment. The book says so and asks readers to run cases several times; treat the tables as demonstrations, not measurements.
Teaching code by design:
eval()calculator, secrets as constants, in-memory audit log, stub web search. The README's caveat lists what a production review must add.No sandboxing, durable state, token-level budgeting, or evals are built; chapter 14 points to them only.
Module 13 pins an older
openaiversion in a separate venv.The author says AI helped write the code and book; the documented runs carry dates and versions, which makes them checkable.
Review checklist it implies for any harness
Does the loop parse model output defensively, and fail loudly on an empty final answer?
Is completed work tracked outside the model's context (a list the code owns)?
Which prompt rules matter enough to enforce in tool code instead?
Do stage boundaries pass tool evidence and reject empty or malformed outputs?
Does any structured verdict put reasoning before the decision field?
Are destructive tools behind an allowlist plus a human gate that the model cannot satisfy with text?
Does every agent hop keep provenance, so a guess can't become a "finding"?
Is output validated before it is cached, and are side-effecting tools safe to re-run on a cache hit?
Are traces written as they happen, so a crash keeps them?
Is each of the above a repeatable test case, run several times per prompt or model change?
Where it fits
R023 and R095 are the other open harness courses: R023 builds a Claude Code-style coding agent, R095 adds production teardowns. This one is the most beginner-friendly and the only one that publishes the model's failures run by run.
R218 uses the same "recorded experiment per answer" style for LangChain.
R087 is a university syllabus covering similar ground at a higher level.