Drain Timeout Policy • AI Agent SDK
DrainTimeoutPolicy: Config-driven graceful-drain policy for safe shutdown.
DrainTimeoutPolicy
Defined in the protocols 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 > 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::
DrainTimeoutPolicy(drain_timeout_seconds=30)Constructor
ParamField
floatNo description available.
Methods
Source
View on GitHubpraisonaiagents/gateway/protocols.py at line 4469