The agent loop
A model alone can only write text. An agent is a model in a loop. The model names a tool and an input. Your program runs the tool and returns the result to the model. The model reads the result and decides again. The loop ends when the model gives an answer. In this lab, the replies of the model are recorded, so the loop is the only part that you write.
About this lesson
Words to know
- agent
- A program in which a model chooses the next step, often in a loop, until it decides it is done.
- 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.
- tool call
- A model's request that your program run a function for it, with a name and arguments.
Why it matters
Each agent framework has this loop at its centre. When you know the loop, you can read what a framework does, and you can find the step where a run failed.
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.