An iteration limit sets the maximum number of cycles an agentic loop may execute. It is the loop’s nonnegotiable safety net: even if no other exit condition succeeds, the process stops at this ceiling. section 9.2.4 section 9.6
Treat it as one layer of a termination gate, not as a replacement for recognizing success or failure. A goal may be satisfied early, while stagnation or budget exhaustion may require earlier termination. section 9.2.4
Build the stopping policy around complementary controls:
- Use the iteration limit as the defensive ceiling. section 9.2.4
- Add a budget limit to control token or monetary cost. section 9.2.4
- Allow goal satisfaction and quality thresholds to end successful work early. section 9.2.4
- Detect stagnation when successive iterations repeat findings or stop improving confidence. section 9.2.4 section 10.3.5
A bounded research loop
A research agent can search, read, synthesize, and generate follow-up questions across several cycles, but the iteration limit guarantees that the loop eventually stops. A separate synthesis step can then compile the accumulated findings. section 9.6
Listing 10.10 11_stagnation_detector.py
def detect_stagnation(workspace: CognitiveWorkspace) -> bool:
# Need at least 2 findings to compare
if len(workspace.findings) < 2:
return False
# Check content overlap between last two findings
last = workspace.findings[-1].content.lower().split()
prev = workspace.findings[-2].content.lower().split()
overlap = len(set(last) & set(prev)) / max(len(set(last)), 1)
if overlap > 0.7: #1
workspace.active_signal = AttentionSignal.STAGNATION
workspace.signal_source = "content_overlap"
return True
# Check confidence plateau
if len(workspace.confidence_trend) >= 3:
recent = workspace.confidence_trend[-3:]
spread = max(recent) - min(recent)
if spread < 0.05: #2
workspace.active_signal = AttentionSignal.STAGNATION
workspace.signal_source = "confidence_plateau"
return True
return False
Inspect the stagnation detector to see how progress checks can prevent an agent from merely running until its iteration ceiling. section 10.3.5
