Skip to content

The agent that grows with you

fix(gateway): tolerate list-shaped gateway.platforms from setup (#83185)

Seashore Shi5bc13cf5742d
diff --git a/gateway/run.py b/gateway/run.py
index af607198ba8..1dd0e9e7c34 100644
--- a/gateway/run.py
+++ b/gateway/run.py
@@ -5184,6 +5184,12 @@ class TurnRunner:
# slower than Linux. Off by default; soul identity is preserved so
# the persona survives even with minimal context.
_platforms_gw_cfg = (ctx.user_config.get("gateway") or {}).get("platforms") or {}
+ # ``hermes gateway setup`` writes ``gateway.platforms`` as a LIST of
+ # enabled platform names (e.g. ``- telegram``), not a dict. Treat any
+ # non-dict shape as "no per-platform overrides" instead of crashing
+ # on ``.get()`` for every incoming turn (#83185).
+ if not isinstance(_platforms_gw_cfg, dict):
+ _platforms_gw_cfg = {}
_plat_gw_cfg = _platforms_gw_cfg.get(platform_key) or {}
_skip_context = _plat_gw_cfg.get("skip_context_files")
skip_context_files = bool(_skip_context) if _skip_context is not None else False
diff --git a/tests/gateway/test_skip_context_files_wiring.py b/tests/gateway/test_skip_context_files_wiring.py
index eaea6babf8d..0cc8fd782c6 100644
--- a/tests/gateway/test_skip_context_files_wiring.py
+++ b/tests/gateway/test_skip_context_files_wiring.py
@@ -72,11 +72,17 @@ class TestSkipContextFilesConfigResolution:
({"gateway": {"platforms": {"discord": {"skip_context_files": True}}}}, "telegram", False),
# Truthy non-bool values coerce.
({"gateway": {"platforms": {"telegram": {"skip_context_files": 1}}}}, "telegram", True),
+ # ``hermes gateway setup`` writes platforms as a LIST of enabled
+ # platform names — must not crash and must default to False (#83185).
+ ({"gateway": {"platforms": ["telegram", "discord"]}}, "telegram", False),
+ ({"gateway": {"platforms": []}}, "telegram", False),
],
)
def test_resolution(self, cfg, platform_key, expected):
# Mirror the production resolution in TurnRunner exactly.
_platforms_gw_cfg = (cfg.get("gateway") or {}).get("platforms") or {}
+ if not isinstance(_platforms_gw_cfg, dict):
+ _platforms_gw_cfg = {}
_plat_gw_cfg = _platforms_gw_cfg.get(platform_key) or {}
_skip_context = _plat_gw_cfg.get("skip_context_files")
skip_context_files = bool(_skip_context) if _skip_context is not None else False