Catalog/P family/P18
Proposed specificationSource-located exemplarH2

Hybrid loop detection

Detect stalled or repetitive behavior.

JOIN POINTrepetitive_behavior_observationRECORD STATUSCandidate · v0.1.0
UML class view for Hybrid loop detection, showing participant roles, received calls, and analytical dependencies
FIG. P18 / UML CLASS VIEW
Object interaction diagram for Hybrid loop detection, showing role collaboration and a numbered message sequence
FIG. P18 / OBJECT INTERACTIONS
Context
Successive agent observations or actions can repeat without progress.
Trigger
A loop signal crosses a configured threshold or composite condition.
Structure
Repetition signals, thresholds, and an intervention interface.
Effect
The harness diagnoses a loop and stops, redirects, or escalates.
Requires
Action or observation history is available in comparable form.
Ensures
Intervention is attributed to explicit evidence and recorded in the trace.
Invariant
A detector cannot block all exploration solely because outputs are similar.
Violation
Detector error, disabled mode, or false positive has a recoverable path.

Negative control

A recursion depth limit alone is not semantic loop detection.

Permitted variation

Action repetition, observation similarity, semantic signals, and composite thresholds.

Test obligation

Test exact repeats, productive variation, false positives, and intervention.

Evolution question

Did repetition detection move from prompt advice to executable intervention?

PROMPT SKETCH
Watch for repetition using evidence you can name: repeated actions, near-identical observations, or a declared semantic signal. Attribute any intervention to that evidence and record it in the trace.
CODE DESIGN / PYTHON
def detect_loop(history, policy):
    window = history[-policy.window :]
    if action_repetition(window) >= policy.action_threshold:
        return Intervention("repeated action", window[-1].action)
    if observation_similarity(window) >= policy.similarity_threshold:
        return Intervention("similar observations", window[-1].observation)
    return None

Illustrative design sketch. A loop detector without a recorded reason is indistinguishable from a random nudge. This example is a teaching aid, not implementation evidence or a conformance claim.

Join point
repetitive_behavior_observation
Source locator
Barbaste et al., §6.2, p. 15 (Gemini CLI, “Hybrid Loop Detection”); Table 11 “Stuck Detection”, p. 52; source label
Lexical cue
(?i)\b(?:loop[_-]?detect(?:ion|or)?|doom[_-]?loop|repetition[_-]?detect|stuck[_-]?(?:detect|loop))\bFrozen expression, v0.1.0. A match is a retrieval cue, not a confirmed implementation.
Aliases
loopdetect, doomloop, repetitiondetect, stuckloop
Canonical exemplar
Darwin-Agent/HarnessXharnessx/processors/control/loop_detection.py:38Support: tests/unit/test_processor_triggers.py:135
Negative control
A recursion depth limit alone is not semantic loop detection.

Scope-anchored review. pohe-agent analyze <repo> --pattern P18 anchors the cue to its enclosing declaration and checks a separate operational signature for all four pointcut dimensions. Missing roles and negative-control risks remain visible; a structural match is not E2/E3. Calibration report ↗

Source-located exemplar

A concrete source anchor is available for this proposed record. It is one exemplar, not evidence that all repositories—or every contract field—conform.

Review boundary: this candidate and its specification come from an AI-assisted study. Independent human validation remains open.

ANY-EVIDENCE FAMILY COVERAGE8/36

22.2% of repository families in the frozen panel have at least one current cue, historical cue, or canonical source layer. This is not confirmed prevalence.

Current lexical-cue repositories: 8 / 41
Canonical source anchorDarwin-Agent/HarnessX ccb411691343harnessx/processors/control/loop_detection.py:38

Repeated-call loop detector.

Exploratory retrieval cue Regex / v0.1.0
(?i)\b(?:loop[_-]?detect(?:ion|or)?|doom[_-]?loop|repetition[_-]?detect|stuck[_-]?(?:detect|loop))\b

This expression is a discovery instrument only. A match is a retrieval cue—not a confirmed implementation, pointcut match, or contract proof.