Gateway Drain Policy Protocol • AI Agent SDK

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

GatewayDrainPolicyProtocol

Defined in the protocols 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

Source

View on GitHub

praisonaiagents/gateway/protocols.py at line 4442


Related Documentation