Agents and tools · Concept
The agent loop and when it stops
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voiceThe interviewer asks
What makes something an 'agent' rather than a single model call? Describe the agent loop, and tell me how it knows when to stop.
Then
Follow-ups the interviewer asks next
- What's in the model's context on the fifth step?
- Which stop conditions belong in code, not in the prompt?
- ReAct or plan-then-execute: what's the difference?
- What does a framework like LangGraph give you, and when is plain code enough?
- What do you log at each step?
The answer
What a strong answer covers
- An agent runs a model in a loop: the model sees the goal, the tools and what has happened so far, and picks an action (a tool call or a final answer); code runs the tool, adds the result, and repeats. The model chooses the path; in a workflow, your code does.
- Stop conditions: the model gives a final answer, plus hard limits in code: maximum steps (say 10–20), a token or rupee budget per task, a time limit, detection of repeated identical calls, and a hand-off to a human.
- The context grows every step, especially with tool results, so each step costs more than the last; trim or summarise old tool outputs.
- ReAct: think, act, observe, one step at a time; flexible but can wander. Plan-and-execute: write a plan first, then run the steps (maybe with a cheaper model), and re-plan on failure; more predictable and easier to show the user.
- Frameworks (LangGraph, LlamaIndex, provider agent SDKs) give state, checkpoints, retries, pauses for human approval and tracing. A plain loop is about 40 lines and easy to debug. Choose by need, not fashion.
- Log every step: input size, tool chosen, arguments, result size, latency, tokens and cost, and the final outcome. That record is the agent's trace.
The red pen
Common traps
Avoid:"an agent is a chatbot with tools" with no loop; a stop rule only in the prompt; no cost limit.
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voicePractise questions like this out loud
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.