The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(gateway): GATEWAY_RELAY_ALLOW_DIRECT_PLATFORMS opt-out for relay-exclusive mode
Ben Barclay2d3f5c1554b2
diff --git a/gateway/config.py b/gateway/config.pyindex 590bb5ebe86..172eaf4ff27 100644--- a/gateway/config.py+++ b/gateway/config.py@@ -2772,7 +2772,15 @@ def _apply_env_overrides(config: GatewayConfig) -> None:# Deployments that configure relay only via gateway.relay_url in# config.yaml keep the old additive behavior (relay beside direct# adapters).- if relay_url_env:+ #+ # Opt-out: GATEWAY_RELAY_ALLOW_DIRECT_PLATFORMS=true keeps direct+ # adapters running beside the relay for deployments that intentionally+ # mix both ingress paths. Like the trigger, it is a deploy-stamp env var,+ # not a config.yaml setting.+ allow_direct = os.getenv(+ "GATEWAY_RELAY_ALLOW_DIRECT_PLATFORMS", ""+ ).strip().lower() in ("1", "true", "yes", "on")+ if relay_url_env and not allow_direct:non_messaging = {Platform.LOCAL, Platform.API_SERVER, Platform.WEBHOOK}for platform, platform_config in config.platforms.items():if platform is Platform.RELAY or platform in non_messaging:diff --git a/tests/gateway/test_config.py b/tests/gateway/test_config.pyindex 8e110714df8..5fd626051b9 100644--- a/tests/gateway/test_config.py+++ b/tests/gateway/test_config.py@@ -746,6 +746,31 @@ class TestLoadGatewayConfig:assert config.platforms[Platform.TELEGRAM].enabled is True+ def test_relay_env_url_opt_out_keeps_direct_platforms(self, tmp_path, monkeypatch):+ """GATEWAY_RELAY_ALLOW_DIRECT_PLATFORMS=true opts a deployment out of+ the relay-exclusive sweep: direct adapters stay enabled beside the+ relay even with the GATEWAY_RELAY_URL env stamp present."""+ hermes_home = tmp_path / ".hermes"+ hermes_home.mkdir()+ config_path = hermes_home / "config.yaml"+ config_path.write_text(+ "gateway:\n"+ " platforms:\n"+ " telegram:\n"+ " enabled: true\n"+ " bot_token: '123:abc'\n",+ encoding="utf-8",+ )+ monkeypatch.setenv("HERMES_HOME", str(hermes_home))+ monkeypatch.setenv("GATEWAY_RELAY_URL", "https://connector.example/relay")+ monkeypatch.setenv("GATEWAY_RELAY_ALLOW_DIRECT_PLATFORMS", "true")++ config = load_gateway_config()++ assert config.platforms[Platform.RELAY].enabled is True+ assert config.platforms[Platform.TELEGRAM].enabled is True++def test_thread_require_mention_yaml_does_not_overwrite_env(self, tmp_path, monkeypatch):"""Explicit env var should win over config.yaml (env > yaml precedence)."""hermes_home = tmp_path / ".hermes"