Scale To Zero Policy • AI Agent SDK
ScaleToZeroPolicy: Config-driven idle policy for safe scale-to-zero.
ScaleToZeroPolicy
Defined in the protocols module.
AI Agent
Config-driven idle policy for safe scale-to-zero.
The default referenced by `scale_to_zero: blocks in gateway.yaml and the BotOS(..., idle_policy=...)` 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 (suspend host, stand transports down, wake endpoint).
The gateway is considered idle only when all guards pass:
- no in-flight agent turn (`
running_turns == 0`), - no live background work (scheduled jobs, delegated subagents,
- durable outbox drains — `
has_background_workisFalse`), - no inbound message for at least `
idle_timeout_minutes`.
Example::
ScaleToZeroPolicy(idle_timeout_minutes=5,
wake_url="https://my-bot.fly.dev/_wake")Constructor
ParamField
floatNo description available.
ParamField
Optional[str]No description available.
ParamField
boolNo description available.
Methods
Source
View on GitHubpraisonaiagents/gateway/protocols.py at line 4189