Skip to content

The agent that grows with you

chore(gateway): drop the default scale-to-zero idle timeout to 2 minutes

Ben Barclay48f15c1ecee4
diff --git a/gateway/scale_to_zero.py b/gateway/scale_to_zero.py
index 4e16937c105..3007c4444c9 100644
--- a/gateway/scale_to_zero.py
+++ b/gateway/scale_to_zero.py
@@ -63,7 +63,13 @@ FLY_API_SOCKET = "/.fly/api"
# config.yaml default (D2). Behavioural setting -> config, not env.
-DEFAULT_IDLE_TIMEOUT_MINUTES = 5
+# 2 minutes: with the gateway owning the suspend (idle predicate covers agent
+# turns, cron, API runs, and background work; the relay drains + flips before
+# the freeze), a short window is safe — real work always blocks the suspend and
+# resume-from-suspend is sub-second, so the only cost of waking "too eagerly"
+# after a quiet spell is a Fly-proxied poke away. Longer windows just bill idle
+# RAM. Raise per-instance via gateway.scale_to_zero.idle_timeout_minutes.
+DEFAULT_IDLE_TIMEOUT_MINUTES = 2
_TRUTHY = {"1", "true", "yes", "on"}
diff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.py
index e20450b98b5..cf3769c0c77 100644
--- a/hermes_cli/config_defaults.py
+++ b/hermes_cli/config_defaults.py
@@ -2925,7 +2925,7 @@ DEFAULT_CONFIG = {
# — whether the feature is enabled at all is the Labs toggle, never a
# config key (decisions.md D2/D11). 0/negative falls back to the default.
"scale_to_zero": {
- "idle_timeout_minutes": 5,
+ "idle_timeout_minutes": 2,
},
# Auto-resume restart-loop breaker (#30719, defense-3). When the
diff --git a/tests/gateway/test_scale_to_zero.py b/tests/gateway/test_scale_to_zero.py
index 9fc6f11a9fb..0f604850c47 100644
--- a/tests/gateway/test_scale_to_zero.py
+++ b/tests/gateway/test_scale_to_zero.py
@@ -38,6 +38,14 @@ def test_timeout_parses_minutes_to_seconds():
assert parse_idle_timeout_seconds("5") == 300.0
+def test_timeout_invalid_values_degrade_to_default():
+ # Behavior contract: bad config falls back to the module default (whatever
+ # its current value), never to zero/negative — an instant-dormant gateway
+ # is never the intent.
+ for bad in (None, "", "nope", 0, -3):
+ assert parse_idle_timeout_seconds(bad) == DEFAULT_IDLE_TIMEOUT_MINUTES * 60.0
+
+
# ── messaging_is_relay_only_or_absent (F6/D1) ────────────────────────────────