The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(moa): tolerate overflowing fanout configuration
teo-nex367bbc3793b4
diff --git a/hermes_cli/moa_config.py b/hermes_cli/moa_config.pyindex 0c0c5289248..389765a2d23 100644--- a/hermes_cli/moa_config.py+++ b/hermes_cli/moa_config.py@@ -34,12 +34,12 @@ def _coerce_number(value: Any, cast, default=None, *, positive: bool = False):return defaulttry:number = cast(value)- except (TypeError, ValueError):+ except (TypeError, ValueError, OverflowError):if cast is not int:return defaulttry:number = int(float(value))- except (TypeError, ValueError):+ except (TypeError, ValueError, OverflowError):return defaultif positive and (number <= 0 or (cast is float and not math.isfinite(number))):return defaultdiff --git a/tests/hermes_cli/test_moa_numeric_config.py b/tests/hermes_cli/test_moa_numeric_config.pynew file mode 100644index 00000000000..a32d2273079--- /dev/null+++ b/tests/hermes_cli/test_moa_numeric_config.py@@ -0,0 +1,35 @@+"""Malformed numeric MoA settings must degrade to defaults, not break the CLI or JSON."""++import os+from pathlib import Path+import subprocess+import sys++import pytest+import yaml++from hermes_cli.moa_config import normalize_moa_config++[email protected]("fanout", [+ {"mode": "every_n", "n": float("inf")},+ {"mode": "every_n", "n": float("-inf")},+ {"mode": "every_n", "n": "inf"},+ {"mode": "every_n", "n": "-inf"},+ "every_n:inf",+ "every_n:-inf",+])+def test_moa_list_tolerates_nonfinite_fanout(tmp_path, fanout):+ home = tmp_path / "profile"+ home.mkdir()+ (home / "config.yaml").write_text(yaml.safe_dump({"moa": {"fanout": fanout}}))+ env = {**os.environ, "HERMES_HOME": str(home)}+ result = subprocess.run(+ [sys.executable, "-m", "hermes_cli.main", "moa", "list"],+ cwd=Path(__file__).resolve().parents[2],+ env=env, capture_output=True, text=True, timeout=45,+ )+ assert result.returncode == 0, result.stdout + result.stderr+ normalized = normalize_moa_config({"fanout": fanout})+ assert normalized["fanout"] == normalize_moa_config({})["fanout"]+