> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Doom Loop Detector • AI Agent SDK

> DoomLoopDetector: Detects and prevents doom loops in agent execution.

# DoomLoopDetector

> Defined in the [**Doom Loop**](../modules/doom_loop) module.

<Badge color="blue">AI Agent</Badge>

Detects and prevents doom loops in agent execution.

Monitors action history for patterns that indicate stuck states:

* Repeated identical actions
* Repeated similar actions
* Consecutive failures
* No meaningful progress

## Constructor

<ParamField query="config" type="Optional[DoomLoopConfig]" required={false}>
  No description available.
</ParamField>

## Methods

<CardGroup cols={2}>
  <Card title="start_session()" icon="function" href="../functions/DoomLoopDetector-start_session">
    Start a new detection session.
  </Card>

  <Card title="record_action()" icon="function" href="../functions/DoomLoopDetector-record_action">
    Record an action for loop detection.
  </Card>

  <Card title="record_response()" icon="function" href="../functions/DoomLoopDetector-record_response">
    Record model response text for content streaming loop detection.
  </Card>

  <Card title="mark_progress()" icon="function" href="../functions/DoomLoopDetector-mark_progress">
    Mark meaningful progress.
  </Card>

  <Card title="is_doom_loop()" icon="function" href="../functions/DoomLoopDetector-is_doom_loop">
    Check if current state indicates a doom loop.
  </Card>

  <Card title="get_loop_type()" icon="function" href="../functions/DoomLoopDetector-get_loop_type">
    Get the type of doom loop detected.
  </Card>

  <Card title="get_loop_event()" icon="function" href="../functions/DoomLoopDetector-get_loop_event">
    Get the current loop event if one exists.
  </Card>

  <Card title="get_recovery_action()" icon="function" href="../functions/DoomLoopDetector-get_recovery_action">
    Get recommended recovery action.
  </Card>

  <Card title="apply_backoff()" icon="function" href="../functions/DoomLoopDetector-apply_backoff">
    Apply backoff delay and return the delay used.
  </Card>

  <Card title="reset_backoff()" icon="function" href="../functions/DoomLoopDetector-reset_backoff">
    Reset backoff to initial value.
  </Card>

  <Card title="increment_recovery()" icon="function" href="../functions/DoomLoopDetector-increment_recovery">
    Increment recovery attempt counter.
  </Card>

  <Card title="get_stats()" icon="function" href="../functions/DoomLoopDetector-get_stats">
    Get detection statistics.
  </Card>
</CardGroup>

## Usage

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
detector = DoomLoopDetector()
    
    # Record actions
    detector.record_action("read_file", {"path": "foo.py"}, "content", True)
    detector.record_action("read_file", {"path": "foo.py"}, "content", True)
    
    # Check for loops
    if detector.is_doom_loop():
        event = detector.get_loop_event()
        recovery = detector.get_recovery_action()
```

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/escalation/doom_loop.py#L90">
  `praisonaiagents/escalation/doom_loop.py` at line 90
</Card>
