> ## 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**](../modules/protocols) module.

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

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

<CardGroup cols={2}>
  <Card title="should_keep_draining()" icon="function" href="../functions/GatewayDrainPolicyProtocol-should_keep_draining">
    Return a :class:`DrainDecision` for the supplied facts.
  </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#L3066">
  `praisonaiagents/gateway/protocols.py` at line 3066
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Gateway Feature" icon="tower-broadcast" href="/docs/docs/features/gateway" />
</CardGroup>
