The loop fits in a few lines of ordinary code, and most of what surprises people about agents comes from it.
Agent loop
Also called Agentic loop, Tool loop
The cycle inside every agent: send the context to the model, read its reply, run any tools it asked for, add the results to the context, and send it all again. It ends when the model stops asking for tools.
The whole context goes back on every turn, so it only grows, and a wrong assumption from turn two is still being read on turn twenty. Slow late turns, rising cost, and an agent stuck on an early mistake all come from this.
“Before you edit anything, tell me the next three tool calls you expect to make and what result would change your mind. If you have made 10 tool calls without a passing test, stop and tell me where you are.”