What Is an Agent Loop? How an AI Agent Actually Runs

Abstract illustration of a loop with a model at its center, framed by surrounding software.

An agent loop is a language model called over and over, with ordinary software carrying out its actions and feeding back the results. This post builds the loop from first principles: the equation, the harness that must decide when to stop, why tokens read grow with the square of the steps, a traced run, and about 30 lines of Python you can run offline.