An agent can keep producing plausible findings without making progress—like repeating the same search in slightly different words. Stagnation detection identifies iterations whose outputs have not meaningfully changed. Unlike an error check, it catches work that looks successful but adds little value. section 9.2.4
A practical check has three parts:
- Keep comparable records of successive iterations, such as normalized summaries or findings. section 9.2.4
- Measure whether they are too similar. One approach compares semantic overlap using embeddings and cosine similarity; a simpler exercise checks word overlap. section 9.2.4 section 9.5
- Choose a response: stop and return existing findings in a basic loop, or signal the planner to try a different strategy. section 9.2.4 section 10.3.5
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
The Python detector compares words in the last two findings and also checks whether recent confidence scores have barely changed. When it detects high content overlap, it records a stagnation signal in the workspace. section 10.3.5
Test the broken-record case
Give an evaluation module two consecutive identical findings and verify that it flags stagnation. To test a loop’s stopping behavior, compare a run with an overlap check against one governed only by its other termination conditions. section 10.5 section 9.5
Use stagnation detection alongside a hard iteration limit and a cost ceiling, not instead of them. Similarity thresholds are design choices: the examples use different measures and cutoffs. Decide whether repeated findings should end the task or trigger replanning, then test that behavior. section 9.6 section 10.3.5

