All posts

"The agent loop, dissected: plan, act, observe — and when to stop"

Every agent is the same three lines of pseudocode: plan, act, observe, repeat. The whole engineering discipline lives in the fourth line nobody writes down — when to stop. Step budgets, real termination conditions, and how to detect an agent that is spinning rather than working.

Agents5 min read17 September 2026by Ahmed
"The agent loop, dissected: plan, act, observe — and when to stop"

Strip away the frameworks and every agent is the same loop: the model looks at the goal and the situation, picks an action, your code executes it, the result goes back into the context, and round again. Plan, act, observe. Three lines of pseudocode, and vendors will sell you many layers of abstraction on top of them. But the part that separates a system from a demo is not in those three lines at all. It is in the exit condition — and if you have ever watched an agent burn twenty minutes and several pounds re-reading the same file, you already know why.

Have an AI feature stuck between demo and production?

The gap — reliability, evals, cost control, the plumbing that keeps it running unattended — is exactly the work I do. If that sounds familiar, a short conversation is usually enough to point you the right way.

Book a free consultation

© 2026 Ahmed Fareed. All rights reserved.

LOADING