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

> DrainTimeoutPolicy: Config-driven graceful-drain policy for safe shutdown.

# DrainTimeoutPolicy

> Defined in the [**protocols**](../modules/protocols) module.

<Badge color="blue">AI Agent</Badge>

Config-driven graceful-drain policy for safe shutdown.

The default referenced by `drain_timeout` in `gateway.yaml` and
the `BotOS(..., drain_timeout=...)` Python surface. It is
intentionally minimal and dependency-free so the decision lives in
core and is provable in isolation; the wrapper owns the side effects
(quiesce ingress, wait, flush outbox, then tear down).

Drain continues while *both* guards hold:

* at least one agent turn is still in flight (`running_turns &gt; 0`),
* the elapsed wait is still within `drain_timeout_seconds`.

A `drain_timeout_seconds` of `0` disables draining entirely
(today's behaviour: in-flight turns are cancelled immediately).

Example::

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
DrainTimeoutPolicy(drain_timeout_seconds=30)
```

## Constructor

<ParamField query="drain_timeout_seconds" type="float" required={false} default="30.0">
  No description available.
</ParamField>

## Methods

<CardGroup cols={2}>
  <Card title="should_keep_draining()" icon="function" href="../functions/DrainTimeoutPolicy-should_keep_draining">
    Instance method.
  </Card>
</CardGroup>

## Source

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