> ## 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.

# Persistent Restart Loop Guard • AI Agent SDK

> PersistentRestartLoopGuard: A :class:`RestartLoopGuard` whose events survive a process restart.

# PersistentRestartLoopGuard

> Defined in the [**protocols**](../modules/protocols) module.

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

A :class:`RestartLoopGuard` whose events survive a process restart.

The in-memory guard is reconstructed fresh on every boot, so a persisted
turn that hard-crashes the *whole* process (OOM, segfault) can drive an
infinite `supervisor → boot → auto-resume → crash` loop the breaker never
sees. This subclass loads its event history from an injected
:class:`RestartStoreProtocol` at construction and flushes back on every
mutation, so the breaker observes the true cross-boot restart rate and can
trip on a crash cycle *slower* than a single in-process window.

The window defaults to one hour (vs. the in-process 60s) because a
cross-boot crash loop is paced by process (re)start latency, not by an
in-loop retry. Pure decision preserved: all persistence is delegated to the
injected store, so the trip logic remains provable in isolation.

Example::

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
guard = PersistentRestartLoopGuard(store, max_restarts=3,
                                   window_seconds=3600)
if guard.record(now=time.time()):
    # too many restart-interrupted boots — stop auto-resuming the turn
    ...
```

## Constructor

<ParamField query="store" type="RestartStoreProtocol" required={true}>
  No description available.
</ParamField>

## Methods

<CardGroup cols={2}>
  <Card title="record()" icon="function" href="../functions/PersistentRestartLoopGuard-record">
    Record a restart at wall-clock `now` and flush to the store.
  </Card>

  <Card title="reset()" icon="function" href="../functions/PersistentRestartLoopGuard-reset">
    Clear the history in memory *and* in the durable store.
  </Card>
</CardGroup>

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L4982">
  `praisonaiagents/gateway/protocols.py` at line 4982
</Card>
