Four loops you can run right here.
Simulated in the browser — no API keys required — but the control flow, termination logic, and log format mirror what real production loops emit. The fourth one is a cautionary tale.
ReAct — reason, act, observe
A tool-using agent answers a question by interleaving reasoning with tool calls. Watch it decide, act, observe, and either continue or stop.
Reflection — draft, critique, revise
The agent drafts an answer, critiques itself against a rubric, then revises. Two to three passes tend to be the sweet spot before diminishing returns.
Evaluator–Optimizer — independent critic
A separate evaluator model grades against fixed criteria and returns targeted fixes. The optimizer applies them. Stop when the score clears a threshold.
No verifier — a cautionary tale
Same coding task as a healthy loop — but the verification step is switched off. Watch the agent declare victory over and over while nothing actually works, until the circuit breaker ends the performance.