- All Courses
- Building LLM Applications
- Tools and Agents
- Multi-step agent loops
Multi-step agent loops
An agent is a loop: send the conversation, get either a final answer or a tool request, execute, append the result, repeat.
Overview
A loop with a budget
An agent is a loop: send the conversation, get either a final answer or a tool request, execute, append the result, repeat. The pattern is simple; the discipline is in the limits.
Always bound the step count and the total token spend. A model that keeps trying a failing tool will loop until something stops it, and without a cap that something is your bill.
Log every step — the request, the arguments, the result. When an agent produces a strange answer, the trace is the only way to find out which step went wrong.
In this lesson you will:
- Run a call-execute-continue loop
- Bound the number of steps
- Log each step for debugging
Resources
Notes are not saved yet — they clear when you leave this page.
Designing a tool interface
14m
Guardrails and failure modes
11m