Skip to main content

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::

Constructor

float
default:"30.0"
No description available.

Methods

should_keep_draining()

Instance method.

Source

View on GitHub

praisonaiagents/gateway/protocols.py at line 3093