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

<div className="flex items-center gap-2">
  <Badge color="teal">Function</Badge>
</div>

> This function is defined in the [**protocols**](../modules/protocols) 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

<ParamField query="exc" type="'BaseException \| None'" required={true}>
  The exception that terminated the process, or `None` for a clean shutdown.
</ParamField>

### Returns

<ResponseField name="Returns" type="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).
</ResponseField>

## Source

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