Loops are the #1 way to AI generate code at scale.
Spiralling is the symptom of a broken loop. With no definite end state, the loop has no way to know it's finished, so it keeps "improving" in circles while the token meter runs.
Verification is a strong solution, where you want to keep the loop on track so that you are not wasting tokens and are still completing your goal efficiently.
> Be annoyingly specific about what counts as done
> Explicitly name the shortcuts you're forbidding before the model goes looking for them
Read more about building verifiable loops: https://www.cerebras.ai/blog/never-loop-without-verifiers