> ## 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 Exit Reason • AI Agent SDK

> classify_exit_reason: Map an exit cause to a supervisor-friendly exit code (pure).

# classify\_exit\_reason

Function

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

Map an exit cause to a supervisor-friendly exit code (pure).

The single source of truth shared by the wrapper CLI and runtime
entry point. Side-effect free so it is provable in isolation.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def classify_exit_reason(exc: 'BaseException | None') -> int
```

## Parameters

**exc** `'BaseException \\| None'` *required*

The exception that terminated the process, or `None` for a clean shutdown.

### Returns

**Returns** `int`

data:`GATEWAY_OK_EXIT_CODE` (0) when `exc` is `None` or a
`KeyboardInterrupt`/`SystemExit(0)` (clean stop).

* :data:`GATEWAY_FATAL_CONFIG_EXIT_CODE` (78) for
  :class:`FatalConfigError` (do not restart — fix config).
* :data:`GATEWAY_RESTART_EXIT_CODE` (75) for any other exception
  (transient — ask supervisor to restart).

## Source

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


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