What is an AI agent and how does its loop work?
Essence
An AI agent isn't a special kind of model. It's a harness program around an ordinary language model. The model can do only one thing: produce a continuation for the input text. What turns it into an agent is a loop run by your code: the model proposes an action, the program executes it, the result goes back to the model, and so on until the task is done.
In short, the loop is: think → call a tool → look at the result → repeat. Claude Code, Codex, Cursor in agent mode and the agents inside Xcode 27 all work this way; they differ in their tool sets, safety rules and model quality.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep