Engineering notes from the team building LoopGain — an open-source cost controller for AI agent loops. max_iterations=5 stops a loop on a counter, with no idea whether the answer is still improving or already getting worse. LoopGain measures loop gain () in real time and stops when the loop has actually converged, so you stop paying for iterations that turn a good answer into a worse one.

How loop gain works: knowing when an AI agent loop has converged

max_iterations is a guess because it ignores the one thing that tells you whether to stop: the trajectory of the error. Here’s how LoopGain reads that trajectory — loop gain, a log-space trend fit, and a t-test — to decide an agent loop is done.

June 4, 2026 · 7 min · LoopGain

Tools for monitoring and controlling AI agent loops

Most agent tooling tells you what happened after the loop ran. A smaller category acts while the loop is still running. Here’s the landscape, drawn on the line that matters: observe versus control.

June 4, 2026 · 12 min · LoopGain