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

# Drain Timeout Has Headroom • AI Agent SDK

> drain_timeout_has_headroom: Return whether the supervisor stop-timeout leaves room to drain.

# drain\_timeout\_has\_headroom

Function

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

Return whether the supervisor stop-timeout leaves room to drain.

Pure predicate used by a startup sanity check. A supervisor whose
stop-timeout is shorter than `drain_timeout + headroom` will `SIGKILL`
the gateway mid-drain, leaving no explanation. This returns `False` only
when we can *prove* the headroom is insufficient; when either value is
unknown (`None`) or non-positive it returns `True` (fail-open: do not
emit a spurious warning when we cannot tell).

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def drain_timeout_has_headroom(stop_timeout_s: Optional[float], drain_timeout_s: Optional[float], headroom_s: float) -> bool
```

## Parameters

**stop\_timeout\_s** `Optional[float]` *required*

The supervisor's configured stop-timeout in seconds, or `None` when it could not be determined.

**drain\_timeout\_s** `Optional[float]` *required*

The gateway's configured drain timeout in seconds, or `None`/0 when draining is disabled.

**headroom\_s** `float` (default: 30.0)

Slack to reserve beyond the drain window for teardown.

### Returns

**Returns** `bool`

`True` when there is adequate headroom (or it cannot be determined),
`False` only when the stop-timeout is provably too short.

## Source

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


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