Complete for freeAdvanced

Course 25

Custom Agent Harnesses, Evaluations, and Multi-Agent Systems

Frameworks hide the parts of an agent that decide whether it is safe and whether it works. In this course you write those parts yourself, as one Python package called harness that grows module by module in a project folder called harness-lab. You start with a single model interface, complete(messages, tools), that both a scripted fake model and a real client implement; the real client speaks the OpenAI-compatible chat API, so it works with a free local model through Ollama or with a hosted provider. Then you build the runtime loop (message history, a tool registry with JSON Schema validation, structured errors, stop rules, and a verify step), run model-written code in a child process with a time limit, an output cap, and a stripped environment, and learn exactly what that does not protect against and when you need a container or VM instead. You record every model call and tool call as JSONL traces with tokens and latency, replay runs for free, and turn traces into versioned eval cases with graders. Later modules attack your own graders, measure success rate, latency, tokens, and cost, route work across planner, worker, and reviewer agents, and add loop limits, human approvals, and rollback before anything reaches a repository. The harness uses only the Python standard library, and every runnable cell on these pages uses the scripted model, so the code you see ran offline to produce the output shown. Each core module has a Notes lesson, a Build-along, and a Practice set with hints and worked solutions, and the course ends with a capstone: a secure, evaluated multi-agent system you attack and improve.

Free completion promise: Every lesson can be completed for $0. The harness uses only the Python standard library, every runnable example uses a scripted model that works offline, and the optional real-model steps can use Ollama, which is free and runs on your own computer.

What's inside

  • 24hand-written lessons
  • 20videos
  • 5step-through animations
  • 28diagrams, charts & live previews
  • 50quiz questions
  • 182code examples

Before you begin

Requirements & setup for Custom Agent Harnesses, Evaluations, and Multi-Agent Systems

Start with the complete free pathway below. Hardware, subscriptions, paid APIs, and cloud credits are never required.

Start here Β· free path

Your complete $0 setup

Every lesson can be completed for $0. The harness uses only the Python standard library, every runnable example uses a scripted model that works offline, and the optional real-model steps can use Ollama, which is free and runs on your own computer.

$0 required

Setup checklist

0 of 16 complete

This checklist is a temporary setup aid and resets when the page reloads. Saved course progress begins in the setup lessons below.

  1. Everything required for this course is free. Paid software, APIs, cloud credits, GPUs, and physical equipment are optional.

    About 2 min
  2. Check your version with python3 --version (macOS and Linux) or py --version (Windows); install Python 3.10 or newer from python.org if it is older or missing.

  3. Create a folder called harness-lab, then run python3 -m venv .venv (or py -m venv .venv on Windows) inside it.

    About 5 min
  4. Activate the environment with source .venv/bin/activate (macOS and Linux) or .venv\Scripts\Activate.ps1 (Windows PowerShell).

    About 5 min
  5. Create the harness, tests, workspace, traces, and evals folders, plus an empty harness/__init__.py and tests/__init__.py.

    About 5 min
  6. Write harness/model.py and check_setup.py from Module 1, then run python check_setup.py.

    About 5 min
  7. Every lesson works in Python 3.10 or newer (standard library only), so Ollama with a small tool-calling model is never required.

  8. If you have Ollama with a small tool-calling model, use it where a lesson mentions it and compare your result with the lesson's.

    About 5 min
  9. If it doesn't match, finish that step in Python 3.10 or newer (standard library only) and keep going.

    About 5 min
  10. Every lesson works in Python 3.10 or newer (standard library only), so An API key from a hosted model provider is never required.

  11. If you have An API key from a hosted model provider, use it where a lesson mentions it and compare your result with the lesson's.

    About 5 min
  12. If it doesn't match, finish that step in Python 3.10 or newer (standard library only) and keep going.

    About 5 min
  13. Every lesson works in Python 3.10 or newer (standard library only), so Docker or another container runtime is never required.

  14. If you have Docker or another container runtime, use it where a lesson mentions it and compare your result with the lesson's.

    About 5 min
  15. If it doesn't match, finish that step in Python 3.10 or newer (standard library only) and keep going.

    About 5 min
  16. Python 3.10 or newer (standard library only): python check_setup.py prints [ok] for Python 3.10 or newer, the virtual environment, and the scripted model, then ends with the line "Ready for the course". Ollama with a small tool-calling model: python check_setup.py prints [ok] for Python 3.10 or newer, the virtual environment, and the scripted model, then ends with the line "Ready for the course". An API key from a hosted model provider: python check_setup.py prints [ok] for Python 3.10 or newer, the virtual environment, and the scripted model, then ends with the line "Ready for the course". Docker or another container runtime: python check_setup.py prints [ok] for Python 3.10 or newer, the virtual environment, and the scripted model, then ends with the line "Ready for the course".

    About 5 min

Software

1 item

Python 3.10 or newer (standard library only)

The whole harness is written with Python's standard library: dataclasses for messages, urllib for talking to model APIs, subprocess and tempfile for the sandbox, and json for traces. There is nothing to pip install. You work in a project folder with its own virtual environment, in any editor, and run everything from a terminal.

Course need
Python 3.10 or newer (standard library only)
Free

The whole harness is written with Python's standard library: dataclasses for messages, urllib for talking to model APIs, subprocess and tempfile for the sandbox, and json for traces. There is nothing to pip install. You work in a project folder with its own virtual environment, in any editor, and run everything from a terminal. Every lesson is readable text with copyable code, keyboard-friendly quizzes and step-throughs, and videos with YouTube captions.

  1. Check your version with python3 --version (macOS and Linux) or py --version (Windows); install Python 3.10 or newer from python.org if it is older or missing.
  2. Create a folder called harness-lab, then run python3 -m venv .venv (or py -m venv .venv on Windows) inside it.
  3. Activate the environment with source .venv/bin/activate (macOS and Linux) or .venv\Scripts\Activate.ps1 (Windows PowerShell).
  4. Create the harness, tests, workspace, traces, and evals folders, plus an empty harness/__init__.py and tests/__init__.py.
  5. Write harness/model.py and check_setup.py from Module 1, then run python check_setup.py.

Hardware

3 items

Ollama with a small tool-calling model

Optional and free. Runs open-weight models such as qwen2.5:3b on your own computer and serves an OpenAI-compatible API at localhost:11434, so you can watch a real model drive your harness without sending data anywhere.

Optional
Python 3.10 or newer (standard library only)
Free

Optional. Every lesson can be completed with Python 3.10 or newer (standard library only); Ollama with a small tool-calling model is an extra for learners who have it. Optional equipment: every assessed outcome can be completed without it.

  1. Every lesson works in Python 3.10 or newer (standard library only), so Ollama with a small tool-calling model is never required.
  2. If you have Ollama with a small tool-calling model, use it where a lesson mentions it and compare your result with the lesson's.
  3. If it doesn't match, finish that step in Python 3.10 or newer (standard library only) and keep going.

An API key from a hosted model provider

Optional and usually paid per token. Any provider with an OpenAI-compatible chat completions endpoint works with the harness's real client; set a spending limit before you start.

Optional
Python 3.10 or newer (standard library only)
Free

Optional. Every lesson can be completed with Python 3.10 or newer (standard library only); An API key from a hosted model provider is an extra for learners who have it. Optional equipment: every assessed outcome can be completed without it.

  1. Every lesson works in Python 3.10 or newer (standard library only), so An API key from a hosted model provider is never required.
  2. If you have An API key from a hosted model provider, use it where a lesson mentions it and compare your result with the lesson's.
  3. If it doesn't match, finish that step in Python 3.10 or newer (standard library only) and keep going.

Docker or another container runtime

Optional. Module 3 shows how to run generated code in a locked-down container for real isolation; the lessons themselves only need Python.

Optional
Python 3.10 or newer (standard library only)
Free

Optional. Every lesson can be completed with Python 3.10 or newer (standard library only); Docker or another container runtime is an extra for learners who have it. Optional equipment: every assessed outcome can be completed without it.

  1. Every lesson works in Python 3.10 or newer (standard library only), so Docker or another container runtime is never required.
  2. If you have Docker or another container runtime, use it where a lesson mentions it and compare your result with the lesson's.
  3. If it doesn't match, finish that step in Python 3.10 or newer (standard library only) and keep going.

Accounts

Nothing required

No external account is needed for this course.

What you will be able to do

Learning outcomes

  • Write an observe, plan, act, and verify runtime with a tool registry, argument validation, structured errors, and stop rules for steps, repeats, and budget.
  • Run model-written code in a child process with a timeout, an output limit, and an allowlisted environment, and explain what a container or VM adds that a subprocess cannot.
  • Retry only the failures worth retrying, with capped exponential backoff and jitter, and make side-effecting tools safe to repeat.
  • Record complete JSONL traces with tokens and latency, replay a run deterministically, and build versioned eval cases from real traces.
  • Grade agents with deterministic checks and with a justified model-based judge, and detect graders that can be gamed.
  • Coordinate specialized agents with routing, loop controls, human approval, and rollback, backed by adversarial tests.

Build real work

Assignments & capstone

Free tools accepted

Agent loop with validated tools

Write a Python agent harness with a complete(messages, tools) model interface, a tool registry that validates arguments and never raises, file tools locked to one workspace folder, and a loop with stop rules and a verify step, tested offline with a scripted model.

Every lesson can be completed for $0. The harness uses only the Python standard library, every runnable example uses a scripted model that works offline, and the optional real-model steps can use Ollama, which is free and runs on your own computer. Submit your project file, or screenshots with descriptions, or a short demo.

Sandboxed eval runner

Build a subprocess sandbox with time, CPU, file, and output limits, then an eval runner that grades scripted agents on a pinned task set, keeps hidden tests outside the sandbox, and reports pass@k, cost, and bootstrap intervals.

Every lesson can be completed for $0. The harness uses only the Python standard library, every runnable example uses a scripted model that works offline, and the optional real-model steps can use Ollama, which is free and runs on your own computer. Submit your project file, or screenshots with descriptions, or a short demo.

Final assessment

Secure, evaluated agent team

On your own Python harness, build a planner, workers, and a read-only reviewer for a job such as fixing seeded bugs, with run budgets, approval gates, scoped credentials, and an audit log, then test it against a single-agent baseline and eight automated attacks. Deliverables: Code that reproduces every number offline with ScriptedModel, REPORT.md with dev and held-out results and bootstrap intervals, SECURITY.md with the threat model and attack results, and Five-minute demo with one live task and one live attack.

Prerequisites & pacing

Skills assumed

  • Python: functions, classes and dataclasses, dictionaries, exceptions, and reading a traceback
  • Running Python scripts and Git commands from a terminal
  • How tool calling works at a high level: a model asks for a function call and the program runs it
  • Writing basic unit tests

Recommended prior courses

These are advisory, not locks. If you already have the skills listed above, enroll directly.

Choose your pace

  • self paced: 14 weeks at 6 hours per week
  • weekly: 14 weeks at 6 hours per week

Part of this learning path

Course created by Zafir Shamsi.