Skip to content
Index Ai Academy

LLM Harness

Build a bounded run loop, test it with scripted model responses, and recover interrupted work from an event log.

Already have an account? Sign in

First principles

Which parts of an agent can you make reproducible even when a model varies?

The harness turns proposals into timed, budgeted, authorized operations. Preserve a trace and durable operation identity so another process can resume safely and a keyless fixture can exercise the same policy.

  1. Starting point

    A scripted adapter returns a typed proposal.

  2. What changes

    The loop checks authorization, remaining budget, and previous operation state.

  3. Result

    The trace records the effect and yields a safe stopping or resumption point.

Compare all three steps
  1. Starting point

    A scripted adapter returns a typed proposal.

  2. What changes

    The loop checks authorization, remaining budget, and previous operation state.

  3. Result

    The trace records the effect and yields a safe stopping or resumption point.

Complete and reverse the trace

Given A scripted adapter returns a typed proposal. and The trace records the effect and yields a safe stopping or resumption point., write down the missing step that connects them.

Compare with the worked step

The loop checks authorization, remaining budget, and previous operation state.

Now take The loop checks authorization, remaining budget, and previous operation state. and the result above. Write an input and an implementation that could produce this trace.

Check one starting point

A scripted adapter returns a typed proposal.. Check that your implementation produces the result shown above.

Try it on a new case

The process crashes after a note is saved but before the success event is appended. What should a recovering harness do?

Show worked reasoning

Look up the original operation ID or retry through an idempotent interface with the same ID. Reconcile what was already committed before claiming success or making a new write.

Recover after the result was lost

  1. Before interruption

    Persist an intent with key W. The tool commits the note for W.

  2. Crash

    The event log lacks the tool result.

  3. Resume

    Two remaining steps are allowed. The same intent is unresolved.

What can a restarted harness infer from the log? How would you recover without adding a second note?

Compare your reasoning

The log proves the intent was recorded, while the final outcome is still uncertain. Look up W at the tool boundary or retry with the same idempotency key before recording the recovered outcome. Count checking and retrying against the defined run limits.

Resume a workload after its result was lost

A proposal is reversible until an effect commits. A durable operation ID and persisted event log let the harness reconcile the effect after a process interruption.

  1. Start with a small case

    Use one scripted fixture where a note is stored and the process stops before logging completion. Predict what a fresh process should look up before it makes another write.

  2. Produce evidence

    Provide a keyless test for success, a denied write, a budget stop, and safe recovery. Compare two harness revisions on the same inputs and present the trace and observed counts as evidence.

  3. Try a changed brief

    Arrange for the budget to run out during recovery. Explain whether lookup and re-execution have different costs and demonstrate that your policy bounds total effects.

Plan your practice and handover
  1. Start with the first lesson . Check the prerequisites under Before you start.
  2. Write a prediction for the small case above and record the result. Keep the fixture and the steps someone else needs to reproduce it.
  3. Use the changed brief to solve a case independently. Show what you changed, the output or test that supports your decision, and one condition that would make it fail.
  4. Open the final lesson . Give a reader the artifact described above and ask them to reproduce one result from your notes.
Between lessons

Validate a tool proposal before counting a call

Carry the loop's structured tool proposal into a registry boundary. The registry requires a text report ID before the tool can run.

Run the starter, predict the changed result, and then edit and run it again.

Replace numeric report ID 7 with the string R7. Check the result and count how many times the tool actually ran.

def read_report(report_id):
    return f"Report {report_id}"

proposal = {"tool": "read_report", "arguments": {"report_id": 7}}
registry = {"read_report": (str, read_report)}
expected_type, operation = registry[proposal["tool"]]
value = proposal["arguments"]["report_id"]
if isinstance(value, expected_type):
    print(f"{operation(value)} | calls=1")
else:
    print("Invalid arguments | calls=0")
Compare against the expected output

Starter output

Invalid arguments | calls=0

Changed output

Report R7 | calls=1
Common failure to check

Calling the function before checking the schema lets an invalid proposal reach the tool and can spend budget or change state.

Take the changed output into the next lesson and explain which part of the handoff the next lesson needs.

Choose how to practice

Begin with What an agent harness is. Each lesson offers these practice modes and a saved handoff.

Work on the campaign checker

Run keyless scenarios for confirmation, budget stops, and recovery after a durable write.

Project workshop

Build it and prove each change

Use the campaign service starter from Software Lab. Follow each stage, collect the evidence, then move to the independent brief.

  1. 1

    Replace the model with a script

    Return a deterministic tool request from the model adapter. Run one read through the loop and record the proposed arguments, result, and final stop.Evidence to collect. Run the same input twice without a provider key. Explain which inputs you would have to hold fixed to compare two harness revisions.Open the lesson
  2. 2

    Validate, authorize, and confirm

    Separate typed parsing, tool validation, caller authorization, and human confirmation. Give readers permission to fetch a report and keep each durable write under policy.Evidence to collect. Run a malformed request, an allowed read, and a denied write. Show what each decision recorded and whether durable state changed.Open the lesson
  3. 3

    Stop cleanly at a budget

    Set a limit for tool steps and account for each proposed action. Include the budget decision in the trace and give the caller a stable stop reason.Evidence to collect. Have the scripted model request one more step than budget allows. Show the final permitted action and the trace proving the next one never ran.Open the lesson
  4. 4

    Recover across a durable effect

    Use a stable operation ID and append intention and result events. Reproduce an interruption after the effect commits, then restart from the saved trace.Evidence to collect. Show how recovery reconciles the operation ID with existing state. Run the same case a second time and check the number of written notes.Open the lesson
  5. 5

    Compare revisions and prepare the handover

    Run the same scripted scenario set against two revisions. Record task outcome, action count, latency, resource use, and one investigated failure case.Evidence to collect. Give a reviewer the scenarios, trace, dependency instructions, and revision IDs. Ask them to reproduce a bound or recovery result on their own.Open the lesson
What you'll learn

What you'll be able to do.

Model adapters, tool contracts, permissions, sessions, tracing, context and budgets, and regression testing.

In order

The 13 lessons.

One is free with no account, and a free account opens the rest.

  1. What an agent harness is FreeThe software around a model that turns it into an agent.35 min
  2. The core loop, built properlyStop reasons, parallel tool calls, errors and turn budgets.40 min
  3. A tool registry for agentsSchemas from functions, validation, output limits and helpful errors.40 min
  4. Permissions and approvalsRules, modes and approval prompts that keep a person in control.40 min
  5. Managing the context windowBudgets, clearing old tool results, compaction and a cacheable prefix.45 min
  6. Streaming, interrupts and sessionsLive output, stopping safely, and saving and resuming transcripts.40 min
  7. Running code safelyExecution tools, step limits, output caps and real sandboxes.45 min
  8. Sandboxes for agents that browseTreat every page as untrusted input: check hosts properly, gate actions by their effect, and layer the defenses.45 min
  9. Tracing, budgets and guardrailsSee what an agent did, cap what it spends, and stop it when it loops.40 min
  10. Tracing a run end to endFollow one run across an orchestrator, subagents and tool servers: trace ids, the traceparent header, the critical path, tokens by branch, and which traces to keep.45 min
  11. Evaluation harnessesRun agents on tasks in fresh environments and grade what they leave behind.45 min
  12. Capstone: build a coding agentA harness that edits a project, runs its tests and stops when they pass.45 min
  13. The same agent on the real SDKsPut the parts you built beside the tool runner and the Agent SDK, choose a surface for a job, and take an MCP server's tools into your registry with prefixed names, one rule per server and a capped result.35 min
Before and after

Where it starts, and what you earn.

When you finish

Finish every lesson and get staff approval on “Ship a recoverable report assistant” in My projects to earn the course certificate. Lessons you skip in the placement test count once you pass their phase's checkpoint.

Questions

Before you sign up.

Is it really free?

Yes. There's nothing to pay, here or anywhere in the academy. A free account saves your progress and issues your certificate.

Do I need to install anything?

The lessons run in your browser. The downloadable service project uses a local Python environment.

How long does it take?

About 11 hours in all, at your own pace. Your progress stays where you left it.

What does the certificate show?

You completed the course and passed a staff-reviewed independent project, “Ship a recoverable report assistant”. See My projects for the brief, evidence requirements, and submission.

Keep learning

Other free courses.

Or take the whole course: 575 lessons, from your first line of Python to production AI.

32 lessons about 21.5 hours

Free Python for AI course

Learn Python from your first line of code to your first call to a language model, with nothing to install.

15 lessons about 9.5 hours

Free prompt engineering course

Learn to write prompts that work reliably, then test them like an engineer: clear instructions, examples, structured output, chains, evals and defenses against prompt injection.

14 lessons about 9 hours

Free RAG course

Build retrieval-augmented generation step by step: embeddings, chunking, vector search, grounded answers with sources, and the measurements that tell you whether it works.

29 lessons about 22.5 hours

Free AI agents course

Learn how to build AI agents by building one: tools, the agent loop, MCP, permissions, context management and evals, ending with a coding agent that stops when its tests pass.

22 lessons about 16 hours

Build an LLM from scratch: a free course

Go from counting letter pairs to a small GPT you train yourself: tokenizers, attention, transformer blocks and the GPT architecture, written line by line.

127 lessons about 101.5 hours

Free Python developer course

Go from your first line of code to working as a Python developer: projects, testing, data, databases, web apps and APIs, all in your browser.

5 lessons about 3.5 hours

How Transformers Think: an interactive inference walkthrough

Follow one prompt, "The cat sat", through a language model with every number shown: tokens to IDs, embeddings and positional waves, the attention matrix, the feed-forward layer, and the probability over the next word.

6 lessons about 3 hours

Why Models Do That: six behaviors, traced to the mechanism

Confident wrong answers, miscounted letters, copying from the prompt, temperature, long prompts that dilute, and a model that never says "I don't know": each behavior reproduced on a tiny GPT with every number printed by code, then the mechanism behind it and the Phase 1 technique it justifies.

17 lessons about 13.5 hours

Creating Custom LLMs: Editing Open Weights Using Weight-Space Programming

Read a model's weights, change them by hand and judge an edit someone else made: deltas, merging, low-rank edits, directions and fact edits on a tiny GPT in your browser. Then replay recorded sessions of an LLM reading, fixing and writing weights, check the published edit of a real open model, and ship a model of your own with its patch, verdict and card. Every number is printed by the lesson's own code, and the method's limits are taught with it.

11 lessons about 9 hours

Free MLOps course: running machine learning in production

Take a model from a notebook to a system that stays right: track and reproduce every run, search settings honestly, version data and models, promote through gates, keep training and serving in step, choose batch or online, catch drift, and retrain through a pipeline. Every number is measured by the lesson's own code.

118 lessons about 95.5 hours

The Foundation Math For Ai & ML: from arithmetic to attention

Learn the math behind AI from arithmetic up: numbers, algebra, vectors and matrices, calculus, probability and statistics, each shown as numbers moving and checked in Python, ending with a network you build and train from the formulas.

19 lessons about 15 hours

Transposition of Formulas: algebraic manipulation in every topic

Learn to make any letter of any formula the subject: layers undone in reverse order, fractions, a letter that appears twice, powers, roots, quadratics, logs, inequalities, trigonometry, vectors, matrices, calculus, probability, statistics and the formulas inside AI models, each checked in Python.

20 lessons about 16.5 hours

Build and Operate HTTP APIs

Design, test, deploy, and operate an HTTP API that another engineer can use.

15 lessons about 11.5 hours

Build and Deploy MCP Integrations

Build a Model Context Protocol client and server, then verify the integration with a compatible host.

Never trained an AI? Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account. Teach it to write

Free, with a certificate

Start the course.

A free account saves your progress across devices and issues your certificate when you finish.