The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway/config): promote every top-level platform key into extra
teknium12f3ccfa3bdc5
diff --git a/gateway/config.py b/gateway/config.pyindex d316cf55095..b299f2c36cd 100644--- a/gateway/config.py+++ b/gateway/config.py@@ -383,12 +383,22 @@ class PlatformConfig:result["channel_overrides"] = {cid: ov.to_dict() for cid, ov in self.channel_overrides.items()}return result+ # Keys consumed by typed fields; everything else at the top of a platform block is adapter+ # config and belongs in ``extra`` (see from_dict).+ _TYPED_KEYS = frozenset({+ "enabled", "token", "api_key", "home_channel", "reply_to_mode", "channel_overrides", "extra",+ "gateway_restart_notification", "typing_indicator", "typing_status_text",+ })+@classmethoddef from_dict(cls, data: Dict[str, Any]) -> "PlatformConfig":data = _coerce_dict(data)home = data.get("home_channel")- # The typing/restart-notification keys may be top-level or bridged into ``extra``; top-level wins.- extra = _coerce_dict(data.get("extra", {}))+ # Adapters read their settings from ``extra`` (``config.extra.get("port")``), but users+ # write them where the docs and ``hermes config set platforms.webhook.port`` put them:+ # directly under the platform block. Promote every non-typed top-level key so neither+ # spelling is silently dropped (#10206); an explicit ``extra:`` value wins on a clash.+ extra = {**{k: v for k, v in data.items() if k not in cls._TYPED_KEYS}, **_coerce_dict(data.get("extra", {}))}def toplevel_or_extra(key: str) -> Any:value = data.get(key)diff --git a/gateway/config_loader.py b/gateway/config_loader.pyindex 7435df03343..1d383f1fac1 100644--- a/gateway/config_loader.py+++ b/gateway/config_loader.py@@ -125,8 +125,8 @@ def merge_platform_sections(yaml_cfg: dict, gateway_cfg: Any, gw_data: dict) ->``gateway.platforms.*`` → top-level ``platforms.*`` → ``gateway.<platform>`` subsections (nestedfirst so top-level config keeps precedence, matching the gateway.streaming fallback). An``enabled`` key in any block sets the ``_enabled_explicit`` marker consumed by the env pass.- Finally api_server's port/key/host/cors_origins/model_name are bridged into ``extra`` so- ``gateway.api_server.port: 8642`` reaches the adapter (mirrors the env path).+ Top-level adapter keys (``gateway.api_server.port: 8642``) reach ``extra`` in+ ``PlatformConfig.from_dict``."""platforms_data = _dict_slot(gw_data, "platforms")@@ -150,13 +150,6 @@ def merge_platform_sections(yaml_cfg: dict, gateway_cfg: Any, gw_data: dict) ->merge(nested_gateway.get("platforms"))merge(yaml_cfg.get("platforms"))merge({k: v for k, v in nested_gateway.items() if k != "platforms" and isinstance(v, dict) and _is_platform_name(k)})-- api_plat = platforms_data.get("api_server")- if isinstance(api_plat, dict):- api_extra = _dict_slot(api_plat, "extra")- for key in ("port", "key", "host", "cors_origins", "model_name"):- if key in api_plat and key not in api_extra:- api_extra[key] = api_plat.pop(key)return platforms_data@@ -212,15 +205,6 @@ _SHARED_KEYS: tuple = (*_plain("gateway_restart_notification", "typing_indicator", "typing_status_text"),)-# Top-level port/host/secret bridged into ``extra`` for adapters that read them from config.extra-# (PlatformConfig.from_dict only reads the ``extra:`` sub-key, so ``platforms.webhook.port`` would be lost).-_PORT_BRIDGE_KEYS: dict = {- Platform.WEBHOOK: ("port", "host", "secret"),- Platform.MSGRAPH_WEBHOOK: ("port", "host", "secret"),- Platform.API_SERVER: ("port", "host"),-}--def _bridged_keys(plat: Platform, platform_cfg: dict, gw_data: dict) -> dict:bridged: dict = {}for key, only, transform in _SHARED_KEYS:@@ -230,9 +214,6 @@ def _bridged_keys(plat: Platform, platform_cfg: dict, gw_data: dict) -> dict:bridged[key] = _dm_behavior_choice(platform_cfg[key], gw_data.get("unauthorized_dm_behavior", "pair"))else:bridged[key] = transform(platform_cfg[key]) if transform else platform_cfg[key]- for key in _PORT_BRIDGE_KEYS.get(plat, ()):- if key in platform_cfg and key not in platform_cfg.get("extra", {}):- bridged[key] = platform_cfg[key]return bridgeddiff --git a/tests/gateway/test_config.py b/tests/gateway/test_config.pyindex 297eb7de152..0b5bc41c077 100644--- a/tests/gateway/test_config.py+++ b/tests/gateway/test_config.py@@ -46,6 +46,18 @@ class TestHomeChannelRoundtrip:class TestPlatformConfigRoundtrip:+ def test_toplevel_adapter_keys_promoted_into_extra(self):+ """Adapter settings written directly under the platform block (the documented+ ``platforms.webhook.port`` shape) reach ``extra``; an explicit ``extra:`` value wins and+ typed fields never leak into ``extra`` (#10206)."""+ pc = PlatformConfig.from_dict({+ "enabled": True, "reply_to_mode": "all", "typing_indicator": False,+ "port": 9100, "routes": {"gh": {"prompt": "x"}}, "extra": {"port": 9999},+ })+ assert pc.extra == {"port": 9999, "routes": {"gh": {"prompt": "x"}}}+ assert pc.reply_to_mode == "all" and pc.typing_indicator is False+ assert PlatformConfig.from_dict(pc.to_dict()).extra == pc.extra+def test_to_dict_from_dict(self):pc = PlatformConfig(enabled=True,diff --git a/website/docs/user-guide/messaging/webhooks.md b/website/docs/user-guide/messaging/webhooks.mdindex d9acdb8918f..3a2b3aafb5e 100644--- a/website/docs/user-guide/messaging/webhooks.md+++ b/website/docs/user-guide/messaging/webhooks.md@@ -72,7 +72,7 @@ Expected response:## Configuring Routes {#configuring-routes}-Routes define how different webhook sources are handled. Each route is a named entry under `platforms.webhook.extra.routes` in your `config.yaml`.+Routes define how different webhook sources are handled. Each route is a named entry under `platforms.webhook.extra.routes` in your `config.yaml`. Adapter settings (`port`, `host`, `secret`, `routes`) may also be written directly under `platforms.webhook:` — both spellings reach the adapter; a value nested under `extra:` wins if the same key appears in both places.### Route properties