The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): count secondary adapters parked mid-reconnect in the scale-to-zero gate
teknium197011235409c
diff --git a/gateway/run_shutdown.py b/gateway/run_shutdown.pyindex 19c14965494..96fa0fc72de 100644--- a/gateway/run_shutdown.py+++ b/gateway/run_shutdown.py@@ -334,7 +334,10 @@ class GatewayShutdownMixin:``self.config`` belongs to the launch profile, while ``_profile_adapters`` holdslive adapters for multiplexed secondary profiles. A direct secondary connection- must block suspension just like a direct primary connection.+ must block suspension just like a direct primary connection. A secondary adapter+ parked in ``_profile_failed_platforms`` (popped from ``_profile_adapters`` while a+ retryable fatal reconnects) is still served: suspending mid-reconnect would leave+ that reconnect unable to complete, so pending reconnects count as active too.config.platforms is pre-seeded with disabled placeholders, and the api_server isforce-enabled on every hosted container (counting it silently disarmed the feature).@@ -356,6 +359,9 @@ class GatewayShutdownMixin:for profile_adapters in (getattr(self, "_profile_adapters", {}) or {}).values():for platform in profile_adapters:add_platform(platform)+ for profile_pending in (getattr(self, "_profile_failed_platforms", {}) or {}).values():+ for platform in profile_pending or {}:+ add_platform(platform)except Exception: # noqa: BLE001 - unreadable state must keep the gateway awakelogger.debug("scale-to-zero: active messaging platforms unreadable — staying awake",diff --git a/tests/gateway/test_scale_to_zero.py b/tests/gateway/test_scale_to_zero.pyindex d94ba3250cd..8215bb507e7 100644--- a/tests/gateway/test_scale_to_zero.py+++ b/tests/gateway/test_scale_to_zero.py@@ -80,6 +80,14 @@ def test_scale_to_zero_gate_accounts_for_secondary_profile_direct_adapter(monkeyassert runner._scale_to_zero_should_arm() is False+ # Mid-reconnect the adapter is popped from _profile_adapters and parked in+ # _profile_failed_platforms (retryable fatal); it is still served and must+ # keep the process awake or the reconnect can never complete.+ runner._profile_adapters = {}+ runner._profile_failed_platforms = {"imessage": {Platform("photon"): object()}}++ assert runner._scale_to_zero_should_arm() is False+def test_watcher_reasks_gate_before_dormant_sequence(monkeypatch):# Arming is a boot-time snapshot. A direct adapter hot-added afterwards (profile reconcile)