Build an Agent Harness From the Loop Up
Build Fernhill's support agent through ten lessons: a bounded loop, tool and message contracts, model selection, checked answers, evidence retrieval, context budgets, idempotent refunds, traces and an offline release project.
Fernhill Supply is a fictional outdoor-gear shop whose customers ask about orders, address changes and refunds. Its support agent needs to understand a request, collect the right evidence and propose a useful answer. The harness decides which tools it may call and which results are sufficient to claim success.
Across ten lessons you build the loop and tool contracts, then design the model boundary: choose a workflow or agent, compare model candidates, preserve message roles, validate final claims and stop retrieval when evidence is sufficient. You then add context budgeting, an idempotent refund, traces and a release project that tests the combined behavior.
The concept pages define the mechanisms; this course makes them work together in Fernhill. Every code example runs offline with the Python standard library. Scripted models verify control paths, while a real model comparison remains a separate experiment with a stated task set and budget.
Read the first loop lesson without an account. Sign in for the tool-contract lesson. The candidate-selection workshop is also public. Continue with Premium for the remaining model-boundary lessons, budgeting, effects, tracing and the final project. Continue with the evaluation course to measure model behavior as well as harness correctness.
When you finish, you can
- Write an agent loop whose every exit is named, tested and visible in the result
- Turn existing APIs into tool contracts that validate input and return errors the model can act on
- Keep a long conversation inside a token budget without losing the facts the run depends on
- Make a payment side effect safe to retry with an idempotency key and a recorded outcome
- Record traces that show who decided each step and find the bad turn in one
- Assemble a release check that runs the agent against scripted models and blocks a regression
- Compare workflow and model candidates against an explicit task contract
- Preserve message roles and validate final claims against retrieved evidence
BEFORE YOU START · You can read and write Python and have called an HTTP API. No model account is needed: every example runs offline against a scripted fake model, and the shop, its orders and its customers are invented.
Syllabus
A loop that ends on purpose
Write the loop a scripted model can drive, give it named exits, and put three shop APIs behind tool contracts the model can use correctly.
Design the model boundary
Choose the task and model, compile instructions, validate completed replies, and give the agent evidence it can inspect.
Keep the run in bounds
Hold a long conversation inside a token budget without losing the facts it depends on, and make the refund safe to retry.
Ready to ship
Record traces that show who decided each step, then assemble a release check that runs the agent against scripted conversations before any customer sees it.