An agent loop sends the goal and current context to a model, which selects either a tool call or a final answer. After a tool runs, its result becomes part of the next model input.
The demo cycles through reasoning, tool use, observation, and response. A real implementation needs a step limit, tool permissions, timeouts, failure handling, and a clear stopping rule to prevent runaway execution.
When to use
Use it when a model must consult tools or perform several steps to complete a task.