fix(gateway): tolerate list-shaped gateway.platforms from setup (#83185)
`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). Co-authored-by: SeashoreShi <seashore.shi@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user