mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-20 15:33:54 +00:00
fix(config): honor gateway.multiplex_profiles nested form
load_gateway_config only forwarded the top-level multiplex_profiles key, ignoring the nested gateway.multiplex_profiles form. The latter is what `hermes config set gateway.multiplex_profiles true` writes, so users who ran that command got multiplex_profiles=False silently — no warning, no fallback, profile_routes just stopped matching. Loader now checks the top-level key first, falls back to the nested gateway section, and only then defaults to False. Same precedence is applied to other nested-form keys (profile_routes already did this). Tests cover: top-level honored, nested honored (regression test for the silent-fallback bug), default False, top-level overrides nested. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
a1d6654264
commit
d7993ab178
1 changed files with 90 additions and 0 deletions
|
|
@ -1467,3 +1467,93 @@ class TestMultiplexProfilesEnvOverride:
|
|||
for noise in ("", " ", "maybe", "2"):
|
||||
monkeypatch.setenv("GATEWAY_MULTIPLEX_PROFILES", noise)
|
||||
assert _env_multiplex_profiles_override() is None, repr(noise)
|
||||
|
||||
|
||||
class TestMultiplexProfilesConfig:
|
||||
"""Tests for parsing multiplex_profiles (top-level and nested forms)."""
|
||||
|
||||
def test_multiplex_profiles_top_level(self, tmp_path, monkeypatch):
|
||||
"""Top-level multiplex_profiles is honored."""
|
||||
hermes_home = tmp_path / ".hermes"
|
||||
hermes_home.mkdir()
|
||||
(hermes_home / "config.yaml").write_text(
|
||||
"multiplex_profiles: true\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
|
||||
|
||||
config = load_gateway_config()
|
||||
|
||||
assert config.multiplex_profiles is True
|
||||
|
||||
def test_multiplex_profiles_nested_under_gateway(self, tmp_path, monkeypatch):
|
||||
"""gateway.multiplex_profiles (the form written by `hermes config set
|
||||
gateway.multiplex_profiles true`) must be honored. Regression test for
|
||||
the silent-fallback bug where the loader only forwarded the top-level
|
||||
key, so users who wrote it under gateway: got multiplex_profiles=False
|
||||
with no warning."""
|
||||
hermes_home = tmp_path / ".hermes"
|
||||
hermes_home.mkdir()
|
||||
(hermes_home / "config.yaml").write_text(
|
||||
"gateway:\n multiplex_profiles: true\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
|
||||
|
||||
config = load_gateway_config()
|
||||
|
||||
assert config.multiplex_profiles is True, (
|
||||
"gateway.multiplex_profiles: true was silently ignored — "
|
||||
"loader only forwarded the top-level form"
|
||||
)
|
||||
|
||||
def test_multiplex_profiles_default_false(self, tmp_path, monkeypatch):
|
||||
"""Default is False when neither form is present."""
|
||||
hermes_home = tmp_path / ".hermes"
|
||||
hermes_home.mkdir()
|
||||
(hermes_home / "config.yaml").write_text("", encoding="utf-8")
|
||||
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
|
||||
|
||||
config = load_gateway_config()
|
||||
|
||||
assert config.multiplex_profiles is False
|
||||
|
||||
def test_multiplex_profiles_top_level_overrides_nested(self, tmp_path, monkeypatch):
|
||||
"""When both forms are present, top-level wins (matches profile_routes
|
||||
and other parity bridges in load_gateway_config)."""
|
||||
hermes_home = tmp_path / ".hermes"
|
||||
hermes_home.mkdir()
|
||||
(hermes_home / "config.yaml").write_text(
|
||||
"multiplex_profiles: true\n"
|
||||
"gateway:\n multiplex_profiles: false\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
|
||||
|
||||
config = load_gateway_config()
|
||||
|
||||
assert config.multiplex_profiles is True
|
||||
|
||||
def test_multiplex_profiles_explicit_top_level_false_not_consulting_nested(
|
||||
self, tmp_path, monkeypatch
|
||||
):
|
||||
"""Lock in the `is None` vs `is False` distinction: when top-level is
|
||||
explicitly false, the loader must forward False WITHOUT consulting the
|
||||
nested form (so a stale `gateway.multiplex_profiles: true` cannot
|
||||
silently re-enable multiplexing). Guards against a future regression
|
||||
that flips the check to `not _mp`."""
|
||||
hermes_home = tmp_path / ".hermes"
|
||||
hermes_home.mkdir()
|
||||
(hermes_home / "config.yaml").write_text(
|
||||
"multiplex_profiles: false\n"
|
||||
"gateway:\n multiplex_profiles: true\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
|
||||
|
||||
config = load_gateway_config()
|
||||
|
||||
assert config.multiplex_profiles is False, (
|
||||
"Explicit top-level false was overridden by nested true — "
|
||||
"loader must respect top-level precedence when key is present"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue