Skip to content
Agents · 3 of 6 · about 20 minutes · With a year

Stop a loop

An agent decides its own next step, so it can make the same step again and again. Each step costs time and money, and the user waits. A program that runs an agent needs two guards. A step limit ends a run that is too long. A repeat check ends a run where the agent makes the same call two times in a row, because the second result is usually the same.

About this lesson

Words to know

agent loop
The cycle that runs an agent: the model requests a tool, the program runs the tool, and the model reads the result. The cycle repeats until the model answers.
step limit
The most steps that one run of an agent can make before the program stops the run.

Why it matters

Without these guards, one bad run can use the budget of a day. Each agent product has a step limit, and the limit is often the first setting that you change.

With a year

How it works, a worked example, the exercise with its tests, three hints and the explained solution are in the app, with a year of Algo150 for $29 or ₾49. The first chapter, Model foundations, is free for everyone: start with Vector dot product.

What a year includes