> ## 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**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/doom_loop.md) module.

AI Agent

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

**config** `Optional[DoomLoopConfig]`

No description available.

## Methods

> [card] [start\_session()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/DoomLoopDetector-start_session.md)
>
> Start a new detection session.

> [card] [record\_action()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/DoomLoopDetector-record_action.md)
>
> Record an action for loop detection.

> [card] [record\_response()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/DoomLoopDetector-record_response.md)
>
> Record model response text for content streaming loop detection.

> [card] [mark\_progress()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/DoomLoopDetector-mark_progress.md)
>
> Mark meaningful progress.

> [card] [is\_doom\_loop()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/DoomLoopDetector-is_doom_loop.md)
>
> Check if current state indicates a doom loop.

> [card] [get\_loop\_type()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/DoomLoopDetector-get_loop_type.md)
>
> Get the type of doom loop detected.

> [card] [get\_loop\_event()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/DoomLoopDetector-get_loop_event.md)
>
> Get the current loop event if one exists.

> [card] [get\_recovery\_action()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/DoomLoopDetector-get_recovery_action.md)
>
> Get recommended recovery action.

> [card] [apply\_backoff()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/DoomLoopDetector-apply_backoff.md)
>
> Apply backoff delay and return the delay used.

> [card] [reset\_backoff()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/DoomLoopDetector-reset_backoff.md)
>
> Reset backoff to initial value.

> [card] [increment\_recovery()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/DoomLoopDetector-increment_recovery.md)
>
> Increment recovery attempt counter.

> [card] [get\_stats()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/DoomLoopDetector-get_stats.md)
>
> Get detection statistics.

## 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] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/escalation/doom_loop.py#L90)
>
> `praisonaiagents/escalation/doom_loop.py` at line 90


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.