A practical look at the runtime of an AI agent — what actually happens between the prompt and the finished task.
A few months ago, a CTO at a fintech company asked me why his agent kept failing. Not what it was failing at — he knew that. He wanted to know how the thing worked, in enough detail that he could see where the money was leaking. I opened a terminal and showed him one run: the model emitted a tool call, our runtime executed it, the result went back into the context, the model emitted another call, and so on for nine steps. Eight of those steps were good. One was a re-query of the same web search with slightly different phrasing.
He looked at the log and said the quiet part out loud: "So it's just a loop that guesses, and we log the guesses."
He was not wrong. An AI agent, under the hood, is a loop. Everything else — memory, tools, frameworks, orchestration — is scaffolding around that loop. This article is a walk through what actually happens on every step: the loop itself, the tool-calling protocol, the two kinds of memory, and the guardrails that stop the loop from running off a cliff. No framework marketing. Just the mechanics, the way they work in production.
The Loop Is the Agent






