Messages list (growing conversation)
Tool registry (name -> python function)
Model call (returns text or tool_call)
Dispatcher (executes + appends result)
You will usually use a framework in production, but a minimal agent loop is short enough to write from scratch and is worth doing once so the abstraction stops feeling magical.