The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway/config): root-level platform blocks keep their adapter keys
teknium167bd2f6571f7
diff --git a/gateway/config_loader.py b/gateway/config_loader.pyindex 1d383f1fac1..9ed0042842a 100644--- a/gateway/config_loader.py+++ b/gateway/config_loader.py@@ -13,7 +13,7 @@ import osfrom pathlib import Pathfrom typing import Any-from gateway.config import Platform, _dict_slot, _normalize_choice+from gateway.config import Platform, PlatformConfig, _coerce_dict, _dict_slot, _normalize_choice# Logger name parity with the origin module: records stay under "gateway.config".logger = logging.getLogger("gateway.config")@@ -205,8 +205,15 @@ _SHARED_KEYS: tuple = (*_plain("gateway_restart_notification", "typing_indicator", "typing_status_text"),)-def _bridged_keys(plat: Platform, platform_cfg: dict, gw_data: dict) -> dict:+def _bridged_keys(plat: Platform, platform_cfg: dict, gw_data: dict, *, root_block: bool = False) -> dict:+ """Shared-key bridge; a ROOT-level ``<platform>:`` block (which ``merge_platform_sections``+ never copies into ``platforms_data``) also gets its adapter keys promoted into ``extra``, with+ the same typed-key exclusion and explicit-``extra`` precedence as ``PlatformConfig.from_dict``."""bridged: dict = {}+ if root_block:+ typed = PlatformConfig._TYPED_KEYS | {"channel_overrides"}+ bridged.update({k: v for k, v in platform_cfg.items() if k not in typed})+ bridged.update(_coerce_dict(platform_cfg.get("extra", {})))for key, only, transform in _SHARED_KEYS:if key not in platform_cfg or (only is not None and plat not in only):continue@@ -243,7 +250,7 @@ def bridge_platform_shared_keys(platform_cfg, cfg_toplevel = platform_section(yaml_cfg, plat.value, gateway_platforms)if not isinstance(platform_cfg, dict):continue- bridged = _bridged_keys(plat, platform_cfg, gw_data)+ bridged = _bridged_keys(plat, platform_cfg, gw_data, root_block=cfg_toplevel)has_channel_overrides = "channel_overrides" in platform_cfgif has_channel_overrides and isinstance(platform_cfg.get("channel_overrides"), dict):plat_data = _dict_slot(platforms_data, plat.value)diff --git a/tests/gateway/test_config.py b/tests/gateway/test_config.pyindex 0b5bc41c077..32923a9a218 100644--- a/tests/gateway/test_config.py+++ b/tests/gateway/test_config.py@@ -1055,6 +1055,21 @@ class TestWebhookPortBridging:assert wh.extra.get("host") == "0.0.0.0"+ def test_root_level_platform_block_adapter_keys_reach_extra(self, tmp_path, monkeypatch):+ """A ROOT-level ``webhook:`` block (not under ``platforms:``) is a supported spelling; its+ adapter keys must reach ``extra`` like the nested form, with nested ``extra:`` winning."""+ hermes_home = tmp_path / ".hermes"+ hermes_home.mkdir()+ (hermes_home / "config.yaml").write_text(+ "webhook:\n enabled: true\n port: 9100\n host: 127.0.0.2\n secret: fixture\n"+ " extra:\n port: 9999\n",+ encoding="utf-8",+ )+ monkeypatch.setenv("HERMES_HOME", str(hermes_home))+ monkeypatch.delenv("WEBHOOK_PORT", raising=False)+ wh = load_gateway_config().platforms[Platform.WEBHOOK]+ assert (wh.extra.get("port"), wh.extra.get("host"), wh.extra.get("secret")) == (9999, "127.0.0.2", "fixture")+def test_msgraph_webhook_port_host_secret_bridged_from_toplevel(self, tmp_path, monkeypatch):"""msgraph_webhook top-level port/host/secret must be bridged into extra,with an explicit extra: value still winning over the top-level one."""