Mid-level interview question
Walk me through the agent loop.
Model answer
The model reads the context and writes a step: a thought and a tool call, or a final answer. The harness parses and runs the call and appends the result as an observation. Repeat.
Scroll sideways to see the whole diagram
Each turn, the model reads the whole context and writes its next step. ReAct (Yao et al., 2022) interleaves a reasoning trace with each action.
Text version
- Each turn, the model reads the whole context and writes its next step. ReAct (Yao et al., 2022) interleaves a reasoning trace with each action.
- If the step is a tool call, the model doesn't run it. The harness, your code, parses it, checks it, and executes it.
- The result is appended to the context as an observation, and the loop goes round again.
- It ends when the model writes a final answer instead of a tool call.
- Or when the harness ends it. Anthropic recommends stopping conditions such as a maximum number of iterations.
It ends when the model answers or the harness stops it: step limits, budgets, errors.
Practise the rest
6 Agent loop questions, 492 in all, each with a model answer. Free.