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.Hybrid loop detection
Detect stalled or repetitive behavior.
repetitive_behavior_observationRECORD STATUSCandidate · v0.1.0UML class view
The proposed contract drawn as participant roles, received calls, and numbered dependencies.
Object interactions
The same roles and calls as a class collaboration and a numbered message sequence.
Pointcut
Where the mechanism applies. All four dimensions belong to the proposed match, not just its vocabulary.
- 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.
Protected contract
The obligation that clients, operators, and auditors should be able to rely on.
- 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.
Variation & lifecycle
The hot spot is admitted only where the protected semantics survive.
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 + code design
An illustrative prompt and a small design sketch for the proposed contract. Names and APIs are invented; this is not a repository excerpt.
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 NoneIllustrative 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.
Detection & matching
The frozen rule that retrieves this record, the canonical source exemplar, and the control that should stay unmatched.
- 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/HarnessX
harnessx/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 ↗
Repository files
Up to five public files retrieved by the frozen cue and pinned to the audited commit. A match is a place to inspect, not a confirmed implementation.
harnessx/processors/control/loop_detection.py:38CANONICAL SOURCE02anomalyco/opencodepackages/core/src/v1/config/permission.ts:27RETRIEVAL CUE03browser-use/browser-usebrowser_use/agent/service.py:440RETRIEVAL CUE04bytedance/deer-flowbackend/packages/harness/deerflow/agents/factory.py:230RETRIEVAL CUE05cline/clineapps/cli/src/runtime/interactive/session-config.ts:20RETRIEVAL CUEEvidence & provenance
Each layer answers a different question. Do not substitute retrieval for review.
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.
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 / 41ccb411691343harnessx/processors/control/loop_detection.py:38tests/unit/test_processor_triggers.py:135Repeated-call loop detector.
Exploratory retrieval cue Regex / v0.1.0
(?i)\b(?:loop[_-]?detect(?:ion|or)?|doom[_-]?loop|repetition[_-]?detect|stuck[_-]?(?:detect|loop))\bThis expression is a discovery instrument only. A match is a retrieval cue—not a confirmed implementation, pointcut match, or contract proof.