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

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

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

<ParamField query="stop_timeout_s" type="Optional[float]" required={true}>
  The supervisor's configured stop-timeout in seconds, or `None` when it could not be determined.
</ParamField>

<ParamField query="drain_timeout_s" type="Optional[float]" required={true}>
  The gateway's configured drain timeout in seconds, or `None`/0 when draining is disabled.
</ParamField>

<ParamField query="headroom_s" type="float" required={false} default="30.0">
  Slack to reserve beyond the drain window for teardown.
</ParamField>

### Returns

<ResponseField name="Returns" type="bool">
  `True` when there is adequate headroom (or it cannot be determined),
  `False` only when the stop-timeout is provably too short.
</ResponseField>

## Source

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