Classify Exit Reason • AI Agent SDK
classify_exit_reason: Map an exit cause to a supervisor-friendly exit code (pure).
classify_exit_reason
Function
</div>
This function is defined in the 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
def classify_exit_reason(exc: 'BaseException | None') -> intParameters
'BaseException \| None'The exception that terminated the process, or `None` for a clean shutdown.
Returns
intdata: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
View on GitHubpraisonaiagents/gateway/protocols.py at line 5979