Pattern · Agents
Agent loop
A model that repeatedly chooses a tool, sees the result, and decides the next step until the task is done.
Say it in the interview
If the steps are known, I would build a workflow; if not, an agent loop: the model picks a tool, my code validates and runs it, the result goes back, with a step cap and a budget, and a hand-off to a person when either is hit.
When to use it
- The steps are not known in advance
- The task needs information gathered along the way
How it works
- Model: task + history + tools → Wants a tool?
- Wants a tool? → yes → Your code validates and runs it
- Your code validates and runs it → Model: task + history + tools
- Wants a tool? → no → Final answer
- Your code validates and runs it → step cap or budget hit → Stop, hand to a person
Trade-offs
- Handles open-ended tasks
- Less predictable, slower and costlier than a fixed workflow
- Needs caps, logs and evals
Pitfalls interviewers probe
- Using an agent where a fixed workflow would do
- No step cap or budget