From 3638abfbf9c311d78814cd45206eeef729e1f80f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=96=87?= Date: Mon, 6 Jul 2026 16:45:00 +0800 Subject: [PATCH] fix(moa): parse JSON string reference_models in _normalize_preset When reference_models is stored as a JSON string (e.g. from hermes moa configure or hand-edited config.yaml), _normalize_preset silently falls back to hardcoded defaults because the string fails both isinstance(x, list) and isinstance(x, dict) checks. Add json.loads() parsing before the type checks so both formats work. --- hermes_cli/moa_config.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hermes_cli/moa_config.py b/hermes_cli/moa_config.py index bf40976dc2ac..9353587fe722 100644 --- a/hermes_cli/moa_config.py +++ b/hermes_cli/moa_config.py @@ -207,6 +207,12 @@ def _normalize_preset(raw: Any) -> dict[str, Any]: raw = {} raw_refs = raw.get("reference_models") + # reference_models may be a JSON string (hand-edited config.yaml) or a list. + if isinstance(raw_refs, str): + try: + raw_refs = json.loads(raw_refs) + except (json.JSONDecodeError, ValueError): + raw_refs = [] if not isinstance(raw_refs, list): # A hand-edited scalar / single mapping (or a bad type) must degrade to # defaults instead of crashing the iteration, mirroring the tolerance