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_work is False`),
  • no inbound message for at least `idle_timeout_minutes`.

Example::

python
ScaleToZeroPolicy(idle_timeout_minutes=5,
                  wake_url="https://my-bot.fly.dev/_wake")

Constructor

ParamField float

No description available.

ParamField Optional[str]

No description available.

ParamField bool

No description available.

Methods

Source

View on GitHub

praisonaiagents/gateway/protocols.py at line 4189