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

# Gateway Drain Policy Protocol • AI Agent SDK

> GatewayDrainPolicyProtocol: Protocol for graceful-drain decisions on gateway shutdown.

# GatewayDrainPolicyProtocol

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

AI Agent

Protocol for graceful-drain decisions on gateway shutdown.

Pure, import-free decision contract consumed by the wrapper's
`BotOS` shutdown path. On `SIGTERM`/`SIGINT` (rolling deploy,
auto-update, host restart) the wrapper stops accepting new inbound
and then repeatedly asks this policy whether to keep waiting for
in-flight agent turns to finish, up to a bounded deadline. The
wrapper supplies live facts (running turns, seconds elapsed); the
policy decides whether the drain should continue. Concrete teardown
(cancel tasks, stop transports, flush outbox) lives in the wrapper;
this contract keeps the *wait condition* testable in isolation.

A config-driven default (:class:`DrainTimeoutPolicy`) is provided for
the common "wait for in-flight turns up to N seconds" case.

## Methods

> [card] [should\_keep\_draining()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/GatewayDrainPolicyProtocol-should_keep_draining.md)
>
> Return a :class:`DrainDecision` for the supplied facts.

## Source

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

***

## Related Documentation

> [card] [Gateway Feature](https://praison.ai/docs/docs/features/gateway)


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