Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions gateway/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,15 +980,18 @@ def load_gateway_config() -> GatewayConfig:
gw_data["thread_sessions_per_user"] = yaml_cfg["thread_sessions_per_user"]

# Multiplexing flag: accept both the top-level key and the nested
# gateway.multiplex_profiles form (from_dict resolves the nested
# fallback, but surface the top-level key here for parity with the
# other session-scope flags above).
# gateway.multiplex_profiles form (written by
# ``hermes config set gateway.multiplex_profiles true``).
if "multiplex_profiles" in yaml_cfg:
gw_data["multiplex_profiles"] = yaml_cfg["multiplex_profiles"]

gateway_section = yaml_cfg.get("gateway")
if isinstance(gateway_section, dict) and "max_concurrent_sessions" in gateway_section:
gw_data["max_concurrent_sessions"] = gateway_section["max_concurrent_sessions"]
if isinstance(gateway_section, dict):
if "multiplex_profiles" in gateway_section and "multiplex_profiles" not in gw_data:
# gateway.multiplex_profiles written by `hermes config set gateway.multiplex_profiles true`
gw_data["multiplex_profiles"] = gateway_section["multiplex_profiles"]
if "max_concurrent_sessions" in gateway_section:
gw_data["max_concurrent_sessions"] = gateway_section["max_concurrent_sessions"]

if "max_concurrent_sessions" in yaml_cfg:
gw_data["max_concurrent_sessions"] = yaml_cfg["max_concurrent_sessions"]
Expand Down
26 changes: 26 additions & 0 deletions tests/gateway/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,32 @@ def test_bridges_quick_commands_from_config_yaml(self, tmp_path, monkeypatch):

assert config.quick_commands == {"limits": {"type": "exec", "command": "echo ok"}}

def test_multiplex_profiles_from_nested_gateway_section(self, tmp_path, monkeypatch):
"""``gateway.multiplex_profiles: true`` (the nested form written by
``hermes config set gateway.multiplex_profiles true``) must enable
multiplexing when loaded via load_gateway_config().

Regression: load_gateway_config() only surfaced the *top-level*
``multiplex_profiles`` key into gw_data, so a config.yaml that pinned
the flag under the nested ``gateway:`` section silently loaded with
multiplex_profiles=False. (from_dict honors the nested fallback, but
load_gateway_config builds gw_data from the top-level keys before
calling from_dict, so the nested value never reached it.)
"""
hermes_home = tmp_path / ".hermes"
hermes_home.mkdir()
config_path = hermes_home / "config.yaml"
config_path.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

def test_relay_platform_enabled_from_env_url(self, tmp_path, monkeypatch):
"""GATEWAY_RELAY_URL must enable Platform.RELAY in config.platforms so
start_gateway()'s connect loop actually dials the connector. Registering
Expand Down
Loading