Understanding the AI Agent Loop

Every AI agent is built on the same simple pattern: call the model, run the tools it requests, and repeat. Here's how to build that loop from scratch, step by step.