Agents and tools · core
The agent loop, workflows and limits
An agent is a model in a loop that chooses actions. Code must set hard limits, and many tasks are better as a fixed workflow where code controls the steps.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Agent loop: the model sees the goal, tools and history, and picks a tool call or a final answer. Code runs the tool, adds the result and repeats. In a workflow, your code chooses the path.
- Stop conditions: a final answer, plus hard limits in code: maximum steps, a token or rupee budget, a time limit, detection of repeated identical calls, and a hand-off to a human.
- Context grows each step, so each step costs more than the one before. Trim or summarise old tool outputs.
- ReAct: think, act, observe, one step at a time. Plan-and-execute: write a plan first, run the steps, and re-plan on failure.
- Use a workflow when the steps are known: extract, validate, match, flag. It is cheaper, faster, testable and easy to audit. Matching totals is arithmetic, not a model task.
- Agents fit when the path is not known in advance. Costs: more tokens, variable latency, harder tests and new failure modes such as loops and injection through tool results.
- Workflow patterns: prompt chaining, routing, parallel calls, orchestrator and workers, and an evaluator loop with a fixed limit.
- Runaway cause: an unhelpful error or a cut-off result makes the model repeat the call. Return actionable errors, summarise big outputs and stop gracefully with a progress report.
The red pen
Common traps: mistake → fix
Mistake: An agent is always better than a workflow
Fix: use a workflow when the steps are known.
Mistake: The prompt can tell the agent to stop after ten tries
Fix: limits must be in code.
Mistake: More steps mean better results
Fix: they raise cost and can loop.
Easy to hard
Questions interviewers ask, easy to hard
- What makes something an agent?
- How does an agent know when to stop?
- Agent or workflow for reading vendor invoices?
- Write the core agent loop with limits.
- An agent ran 40 minutes and 300 tool calls. What happened?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.