AI Engineering · LLM applications that ship
What is an agent loop and when is it worth it?
Short answer
An agent loop lets the model choose actions, observe results and repeat toward a goal. It is worth it when the path is unpredictable; for fixed steps, a deterministic workflow is cheaper and safer.
A workflow encodes the steps in code: retrieve, call this API, then summarise. An agent decides the next step itself, using tools and observations. That flexibility helps with open-ended tasks such as debugging or research, but it makes behaviour harder to predict, test and bound.
- Use a workflow when the sequence is known and compliance matters.
- Use an agent when the number and order of steps genuinely vary by input.
- Always cap iterations, wall-clock time and spend.
- Give the agent a clear stop condition and a way to ask for help.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1How would you test an agent that takes different paths?
- 2What stop conditions would you enforce?
- 3When would you split one agent into several specialised ones?
Say it in the interview
An agent loop lets the model pick the next action based on what it has observed so far. I reach for it only when the path really is unpredictable. If I can write the steps in code, I do, because a workflow is easier to test and bound. When I do use an agent, I cap iterations, time and cost, and I give it explicit stop conditions so it cannot wander indefinitely.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live AI Engineering mock interview and get scored feedback on depth, clarity and confidence.