> ## 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**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/protocols.md) module.

AI Agent

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

**drain\_timeout\_seconds** `float` (default: 30.0)

No description available.

## Methods

> [card] [should\_keep\_draining()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/DrainTimeoutPolicy-should_keep_draining.md)
>
> Instance method.

## Source

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


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