CourseModel Context Protocol: The Complete Course · Module 6: Building Clients and Hosts · part 43 of 77
Part 43 · Module 6: Building Clients and Hosts

Lesson 2: The agent loop, and how it stops

24 min read·13 Oct 2026
Module 6 · Lesson 2 · About 50 minutes · Needs: Lesson 1 of this module (a model connected to the notes server, tools converted to the model's format); Module 4 Lesson 1 (notes:// resources)

The situation

Thursday 24 September 2026, week 3. Lesson 1 built Host, whose loop answers Nare's question, "How many participants will the nap study have?", in three steps: search, open the lab sync note, answer. Today you test how that loop ends. A model can repeat itself, guess note ids that do not exist, or wait on a server that never replies. You add the stop rules Lesson 1 left out, and test its timeout.

THURSDAY 24 SEPTEMBER: ONE QUESTION Nare asks how many participants? Step 1 search_notes Step 2 read lab sync Step 3 answer: 24 when should the host stop asking the model?
Nare's question takes three steps, two tool calls by the host (blue) and an answer from the model (amber), so the host must loop and know when to stop.

The rest of this course is yours to keep

This course is bought on its own, once, and stays readable afterwards, including the parts added to it later.