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

# Classify Unclean Exit • AI Agent SDK

> classify_unclean_exit: Classify the previous boot's exit and return a fresh boot record (pure).

# classify\_unclean\_exit

Function

> This function is defined in the [**protocols**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/protocols.md) module.

Classify the previous boot's exit and return a fresh boot record (pure).

Given the record persisted by the *previous* process, decide whether that
process exited cleanly and stamp a new `phase="running"` record for *this*
boot. Side-effect free so it is provable in isolation, mirroring
:func:`classify_exit_reason`.

Rules:

* No prior record ⇒ first boot / fresh store: `exit_kind="unknown"` (the
  caller must never treat `"unknown"` as healthy, but there is nothing to
  resume).
* Prior `phase == "exited"` ⇒ the previous process reached its graceful
  stop: `exit_kind="clean"`.
* Prior `phase in ("running", "draining")` ⇒ the previous process died
  before recording a clean exit (SIGKILL/OOM/segfault/orchestrator kill):
  `exit_kind="unclean"`, and `suspected_oom` when its last memory sample
  was at/above `oom_fraction` of the budget.

The returned record carries forward the prior `restart_events` so the
persistent restart-loop guard sees the full cross-boot history.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def classify_unclean_exit(prev: Optional[LifecycleRecord]) -> LifecycleRecord
```

## Parameters

**prev** `Optional[LifecycleRecord]` *required*

The previous process's persisted :class:`LifecycleRecord`, or `None` on a fresh store.

### Returns

**Returns** `LifecycleRecord`

class:`LifecycleRecord` for this boot.

## Uses

* `LifecycleRecord`

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L6180)
>
> `praisonaiagents/gateway/protocols.py` at line 6180


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