> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Scale To Zero Policy • AI Agent SDK

> ScaleToZeroPolicy: Config-driven idle policy for safe scale-to-zero.

# ScaleToZeroPolicy

> Defined in the [**protocols**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/protocols.md) 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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
ScaleToZeroPolicy(idle_timeout_minutes=5,
                  wake_url="https://my-bot.fly.dev/_wake")
```

## Constructor

**idle\_timeout\_minutes** `float` (default: 5.0)

No description available.

**wake\_url** `Optional[str]`

No description available.

**enabled** `bool` (default: True)

No description available.

## Methods

> [card] [idle\_timeout\_seconds()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/ScaleToZeroPolicy-idle_timeout_seconds.md)
>
> Instance method.

> [card] [should\_arm()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/ScaleToZeroPolicy-should_arm.md)
>
> Instance method.

> [card] [is\_idle()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/ScaleToZeroPolicy-is_idle.md)
>
> Instance method.

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L4189)
>
> `praisonaiagents/gateway/protocols.py` at line 4189


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.