1 # The Confidence Loop Guardrail
2 # Never let AI iterate on its own output
3 # more than MAX_ITERATIONS times without
4 # independent verification from a human.
5
6 MAX_ITERATIONS = 2 # Hard ceiling before human review
7
8 def ai_iterate(task, model, context):
9 iterations = 0
10 result = None
11
12 while iterations < MAX_ITERATIONS:
13 result = model.generate(task, context)
14 iterations += 1
15 context = result # Feed output back as input
16
17 # ⚠️ STOP. Human verifies before continuing.
18 print(f"⏸ Paused after {iterations} iterations.")
19 print(" Review output before allowing more.")
20 return result
The pattern behind the principle. This is the simplest implementation of the "Confidence Loop" guardrail. Two iterations, then a hard stop for human review. Copy it, adapt it, put it in every AI-assisted workflow.