Skip to content

The agent that grows with you

fix(config): recognize supported MoA preset settings

Gille00b639741822
diff --git a/hermes_cli/config.py b/hermes_cli/config.py
index 8253d067b31..dbb059565a4 100644
--- a/hermes_cli/config.py
+++ b/hermes_cli/config.py
@@ -2969,7 +2969,7 @@ def _validate_config_key(key: str) -> tuple[bool, Optional[str]]:
if known or not key:
return known, suggestion
from hermes_cli.config_runtime_keys import is_runtime_read_key
- return (True, None) if is_runtime_read_key(".".join(_split_key_path(key))) else (False, suggestion)
+ return (True, None) if is_runtime_read_key(key) else (False, suggestion)
def _validate_schema_key(key: str) -> tuple[bool, Optional[str]]:
diff --git a/hermes_cli/config_runtime_keys.py b/hermes_cli/config_runtime_keys.py
index cdaee2e7a27..a3eac191d0b 100644
--- a/hermes_cli/config_runtime_keys.py
+++ b/hermes_cli/config_runtime_keys.py
@@ -2,11 +2,13 @@
``_validate_config_key`` asks here only AFTER the schema walk refused a key, so nothing here can
override a schema verdict; it only vouches for an exact path (and what is below it) a reader uses.
-Three owners supply them:
+Four owners supply them:
* Core selection keys (``browser.cloud_provider``, ``<category>.use_gateway``, ``stt.provider``):
:func:`tools.tool_backend_helpers.selection_config_keys`, built from ``read_selection``'s tables.
* Core-owned unseeded keys outside that table, each listed with its reader (:data:`CORE_RUNTIME_KEYS`).
+* MoA preset fields: the normalizer's own field list, under any preset name. Only exact fields
+ qualify, not arbitrary descendants of ``moa.presets``.
* ACTIVE plugins: a ``config_keys`` list in ``plugin.yaml`` (or ``extensions.com.nousresearch.hermes``
in a portable ``plugin.json``) names core-section paths the plugin's code reads, e.g.
``memory.retaindb``. Plugins are found and gated by the loader's own discovery
@@ -101,10 +103,16 @@ def plugin_declared_config_keys() -> frozenset[str]:
def is_runtime_read_key(key: str) -> bool:
- """True when ``key`` (dotted) is a core selection key, a core runtime key, or sits at/under a path
- an active plugin declares. Call only for a key the schema walk refused."""
+ """Recognize runtime-owned paths after the schema refuses them, retaining escaped dots in names."""
+ from hermes_cli.config import _split_key_path
+ from hermes_cli.moa_config import _FLAT_PRESET_KEYS
from tools.tool_backend_helpers import selection_config_keys
+ parts = _split_key_path(key)
+ if (len(parts) == 4 and parts[:2] == ["moa", "presets"]
+ and parts[2].strip() and parts[3] in _FLAT_PRESET_KEYS):
+ return True
+ key = ".".join(parts)
if key in selection_config_keys() or _covered(key, CORE_RUNTIME_KEYS):
return True
return _covered(key, plugin_declared_config_keys())
diff --git a/tests/hermes_cli/test_moa_config_key_validation.py b/tests/hermes_cli/test_moa_config_key_validation.py
new file mode 100644
index 00000000000..6161c063986
--- /dev/null
+++ b/tests/hermes_cli/test_moa_config_key_validation.py
@@ -0,0 +1,111 @@
+"""Supported MoA preset keys survive CLI writes and reach the executing advisor loop."""
+
+import json
+from types import SimpleNamespace
+
+import pytest
+
+from hermes_cli.config import get_config_value, load_config, set_config_value
+from hermes_cli.moa_config import resolve_moa_preset
+
+
+def moa_home(tmp_path, monkeypatch):
+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))
+ (tmp_path / ".env").touch()
+ return tmp_path
+
+
[email protected]("name", ["default", "review", "review.v2", "code review"])
+def test_configured_cadence_and_timeout_reach_moa(name, moa_home, monkeypatch, capsys):
+ (moa_home / "config.yaml").write_text(
+ json.dumps(
+ {
+ "moa": {
+ "presets": {
+ name: {
+ "reference_models": [
+ {"provider": "openrouter", "model": "test/advisor"}
+ ],
+ "aggregator": {
+ "provider": "openrouter",
+ "model": "test/actor",
+ },
+ }
+ }
+ }
+ }
+ ),
+ encoding="utf-8",
+ )
+ prefix = "moa.presets." + name.replace(".", r"\.")
+ set_config_value(f"{prefix}.fanout", "every_n:5")
+ set_config_value(f"{prefix}.reference_timeout", "900")
+ written = capsys.readouterr()
+ preset = resolve_moa_preset(load_config()["moa"], name)
+ assert preset["fanout"] == "every_n:5"
+ assert preset["reference_timeout"] == 900
+
+ reads = []
+ for field, expected in (("fanout", "every_n:5"), ("reference_timeout", 900)):
+ get_config_value(f"{prefix}.{field}", as_json=True)
+ captured = capsys.readouterr()
+ assert json.loads(captured.out) == expected
+ reads.append(captured.err)
+
+ calls = []
+
+ def fake_call(**kwargs):
+ calls.append(kwargs)
+ message = SimpleNamespace(content="advice", tool_calls=[])
+ return SimpleNamespace(
+ choices=[SimpleNamespace(message=message, finish_reason="stop")],
+ usage=None,
+ model="test/model",
+ )
+
+ monkeypatch.setattr("agent.moa_loop.call_llm", fake_call)
+ from agent.moa_loop import MoAChatCompletions
+
+ facade = MoAChatCompletions(name)
+ messages = [{"role": "user", "content": "Review the task"}]
+ reference_counts = []
+ for iteration in range(6):
+ facade.create(messages=list(messages), tools=[])
+ reference_counts.append(sum(call["task"] == "moa_reference" for call in calls))
+ messages.extend(
+ [
+ {
+ "role": "assistant",
+ "content": "",
+ "tool_calls": [
+ {
+ "id": f"c{iteration}",
+ "function": {"name": "inspect", "arguments": "{}"},
+ }
+ ],
+ },
+ {
+ "role": "tool",
+ "tool_call_id": f"c{iteration}",
+ "content": f"result {iteration}",
+ },
+ ]
+ )
+ assert reference_counts == [1, 1, 1, 1, 1, 2]
+ assert all(
+ call["timeout"] == 900 for call in calls if call["task"] == "moa_reference"
+ )
+ assert "not a recognized config key" not in written.out + written.err + "".join(
+ reads
+ )
+
+
[email protected]("name", ["default", "review", "review.v2"])
+ "field", ["fanoutt", "reference_timeot", "unexpected.fanout", "fanout.unexpected"]
+)
+def test_preset_typos_still_warn(name, field, moa_home, capsys):
+ prefix = "moa.presets." + name.replace(".", r"\.")
+ set_config_value(f"{prefix}.{field}", "5")
+ assert "not a recognized config key" in capsys.readouterr().out