Skip to content

The agent that grows with you

fix(gateway): guard Teams multiplex listener ownership

Joel Taylor9d5c58be893d
diff --git a/gateway/config.py b/gateway/config.py
index 49b405fc029..93bccff17ba 100644
--- a/gateway/config.py
+++ b/gateway/config.py
@@ -444,6 +444,7 @@ PORT_BINDING_PLATFORM_VALUES = frozenset({
"sms",
"whatsapp_cloud",
"line",
+ "teams",
})
# Platforms whose port-binding status depends on connection mode. Feishu in
diff --git a/hermes_cli/web_server.py b/hermes_cli/web_server.py
index 8304414d109..dd224b7ef6a 100644
--- a/hermes_cli/web_server.py
+++ b/hermes_cli/web_server.py
@@ -3414,6 +3414,7 @@ _PORT_BINDING_PLATFORM_PORTS: Dict[str, Tuple[str, int]] = {
"sms": ("webhook_port", 8080),
"whatsapp_cloud": ("webhook_port", 8090),
"line": ("port", 8646),
+ "teams": ("port", 3978),
}
# Platform states that mean the adapter is NOT serving its port right now.
diff --git a/tests/gateway/test_multiplex_adapter_registry.py b/tests/gateway/test_multiplex_adapter_registry.py
index 84b539cdf2a..af2063d5e0f 100644
--- a/tests/gateway/test_multiplex_adapter_registry.py
+++ b/tests/gateway/test_multiplex_adapter_registry.py
@@ -1011,6 +1011,29 @@ class TestSecondaryProfileConfigHandling:
assert second == 1
assert runner._profile_adapters["later"][photon] is later
+ @pytest.mark.asyncio
+ async def test_secondary_teams_uses_degradable_error(self, monkeypatch):
+ from gateway.config import GatewayConfig, Platform, PlatformConfig
+ from gateway.run import SecondaryPortBindingConfigError
+
+ runner = GatewayRunner.__new__(GatewayRunner)
+ runner.config = GatewayConfig(multiplex_profiles=True)
+ runner._profile_adapters = {}
+
+ reviewer_cfg = GatewayConfig(multiplex_profiles=True)
+ reviewer_cfg.platforms = {
+ Platform("teams"): PlatformConfig(enabled=True, extra={"port": 3978}),
+ }
+ monkeypatch.setattr(
+ "gateway.config.load_gateway_config", lambda: reviewer_cfg
+ )
+
+ with pytest.raises(SecondaryPortBindingConfigError) as exc_info:
+ await runner._start_one_profile_adapters("reviewer", "/tmp/x", {})
+ assert "teams" in str(exc_info.value)
+ assert "reviewer" in str(exc_info.value)
+ assert "reviewer" not in runner._profile_adapters
+
class TestSecondaryProfileHookRegistration:
"""A secondary profile's own `hooks:` block must register on ITS