Skip to content

From One Model Call to a Working Agent

Build a public library's catalogue assistant from a single model call to a tested, streaming agent loop in eight lessons: read a response properly, keep the message list valid, give the model a tool, close the loop with named exits and budgets, handle bad calls and bad results, stream the run, test it against a scripted model, and ship it with a release check.

3 modules8 lessons~2.5 hours2 free to read

Linden Library is an invented public library. Its catalogue assistant answers three kinds of request from readers: is this book available, can you place a hold on it for me, can you renew my loan. Behind it sit two ordinary services the library already runs: a catalogue service and a loans service. The assistant's job is to decide which to call, in what order, to act only on what a reader may ask for, and to stop when the reader has an answer.

The course begins before there is a loop at all. The first two lessons make one model call and read everything it returns, then build the message list that carries a conversation across turns without ever producing a request the provider rejects. The next three give the model a tool, close the loop with exits and budgets the model cannot argue with, and handle the calls and results that arrive broken. The last three make the assistant something a person can watch and trust: a stream of events a page can render, a test suite that needs no network, and a release check that proves each control holds.

The concept pages define the mechanisms; this course makes them work together in Linden. Every code example runs offline with the Python standard library against a scripted model, which is how the harness is tested throughout. Real model behaviour is measured separately, with the probe set the seventh lesson builds.

Read the first lesson without an account. Sign in for the message-list lesson. The first-tool workshop is also public. Continue with Premium for the loop, the error handling, streaming, testing and the release project. When you finish, the harness course takes the same skills into a support agent with refunds, context budgets and traces.

When you finish, you can

  • Read every field a model response carries and branch on the stop reason rather than the text
  • Build a message list with roles and paired tool results that never produces a rejected request
  • Write a tool definition a model can use and dispatch its first call with validation
  • Close a loop whose every exit is named and whose budgets end a run whatever the model believes
  • Turn malformed calls and failed tools into observations the model can act on, with caps
  • Emit loop events a client can render and cancel, instead of raw model deltas
  • Test the loop with a scripted model and probe a real one with checks that judge actions
  • Assemble a release check that proves each control holds before the assistant goes live

BEFORE YOU START · You can read and write Python and have made an HTTP request. You do not need to have called a model API before; the course starts there. No model account is needed: every example runs offline against a scripted fake model, and the library, its catalogue and its readers are invented.

Syllabus

01

What one model call gives you

Make a single model call for the library assistant, read every field it returns, and build the message list that carries a conversation across turns without a rejected request.

02

Tools and the loop

Give the assistant one tool and run its first call, close the loop with exits and budgets the model cannot argue with, and turn broken calls and failed tools into observations instead of crashes.

03

Make it trustworthy

Stream the run as events a page can render and cancel, test the loop against a scripted model and probe a real one, and ship the assistant with a release check that proves each control holds.