Skip to content

The agent that grows with you

fix(gateway): persist slash-command config writes into the routed profile

StanleyStetson94a2d7f8affe
diff --git a/gateway/slash_commands.py b/gateway/slash_commands.py
index 162f231b136..184754b0693 100644
--- a/gateway/slash_commands.py
+++ b/gateway/slash_commands.py
@@ -3760,9 +3760,9 @@ class GatewaySlashCommandsMixin:
def _save_gateway_config_key(self, key_path: str, value) -> bool:
"""Save a dot-separated key to config.yaml (shared by /reasoning, /fast
and their interactive pickers)."""
- from gateway.run import _hermes_home
+ from gateway.run import _gateway_config_home
from hermes_cli.config import read_user_config_raw
- config_path = _hermes_home / "config.yaml"
+ config_path = _gateway_config_home() / "config.yaml"
try:
# Write-back round-trip: raw read is correct (merged defaults must
# not be persisted back to the user's file).
@@ -4004,7 +4004,7 @@ class GatewaySlashCommandsMixin:
Gate changes persist to config.yaml and evict the cached agent so the
new setting takes effect on the next message.
"""
- from gateway.run import _hermes_home
+ from gateway.run import _gateway_config_home
from hermes_cli.write_approval_commands import handle_pending_subcommand
from tools import write_approval as wa
from tools.memory_tool import load_on_disk_store
@@ -4012,7 +4012,7 @@ class GatewaySlashCommandsMixin:
raw_args = event.get_command_args().strip()
args = raw_args.split() if raw_args else []
session_key = self._session_key_for_source(event.source)
- config_path = _hermes_home / "config.yaml"
+ config_path = _gateway_config_home() / "config.yaml"
def _set_approval(enabled: bool):
# Write-back round-trip: raw read is correct (merged defaults must
@@ -4053,14 +4053,14 @@ class GatewaySlashCommandsMixin:
the write-approval ``diff <id>``; the CLI also has an unrelated
``hermes skills diff <name>`` that diffs a bundled skill vs stock.)
"""
- from gateway.run import _hermes_home
+ from gateway.run import _gateway_config_home
from hermes_cli.write_approval_commands import handle_pending_subcommand
from tools import write_approval as wa
raw_args = event.get_command_args().strip()
args = raw_args.split() if raw_args else []
session_key = self._session_key_for_source(event.source)
- config_path = _hermes_home / "config.yaml"
+ config_path = _gateway_config_home() / "config.yaml"
gate_on = wa.write_approval_enabled(wa.SKILLS)
wants_toggle = bool(args) and args[0].lower() in {"approval", "mode"}
@@ -4240,9 +4240,9 @@ class GatewaySlashCommandsMixin:
``display.platforms.<platform>.tool_progress`` so each channel can
have its own verbosity level independently.
"""
- from gateway.run import _hermes_home, _load_gateway_config, _platform_config_key
+ from gateway.run import _gateway_config_home, _load_gateway_config, _platform_config_key
- config_path = _hermes_home / "config.yaml"
+ config_path = _gateway_config_home() / "config.yaml"
platform_key = _platform_config_key(event.source.platform)
# --- check config gate ------------------------------------------------
@@ -4378,10 +4378,10 @@ class GatewaySlashCommandsMixin:
are respected but not modified here — edit config.yaml directly for
per-platform control.
"""
- from gateway.run import _hermes_home, _load_gateway_config, _platform_config_key, _resolve_gateway_model
+ from gateway.run import _gateway_config_home, _load_gateway_config, _platform_config_key, _resolve_gateway_model
from gateway.runtime_footer import resolve_footer_config
- config_path = _hermes_home / "config.yaml"
+ config_path = _gateway_config_home() / "config.yaml"
platform_key = _platform_config_key(event.source.platform)
# --- parse argument -------------------------------------------------
diff --git a/tests/gateway/test_slash_config_writes_routed_profile.py b/tests/gateway/test_slash_config_writes_routed_profile.py
new file mode 100644
index 00000000000..c1893156f52
--- /dev/null
+++ b/tests/gateway/test_slash_config_writes_routed_profile.py
@@ -0,0 +1,70 @@
+"""Slash-command config writes must land in the routed profile's config.yaml.
+
+Regression for #87939 / #75684: the multiplexed inbound handler already runs
+every slash handler inside ``_profile_runtime_scope`` (routed HERMES_HOME
+override), but several handlers built their write path from the module
+constant ``gateway.run._hermes_home`` — the LAUNCH home — so ``/reasoning
+--global``, ``/fast``, ``/memory approval``, ``/skills approval``, ``/verbose``
+and ``/footer`` persisted into the default profile's config.yaml. They now go
+through ``_gateway_config_home()`` like the reads do.
+"""
+
+from __future__ import annotations
+
+import pytest
+import yaml
+
+import gateway.run as gateway_run
+from gateway.run import GatewayRunner, _profile_runtime_scope
+from gateway.slash_commands import GatewaySlashCommandsMixin
+
+
+class _Runner(GatewaySlashCommandsMixin):
+ _run_in_executor_with_context = GatewayRunner._run_in_executor_with_context
+ _get_executor = GatewayRunner._get_executor
+
+ def _session_key_for_source(self, _source):
+ return "k"
+
+ def _evict_cached_agent(self, _session_key):
+ pass
+
+
+class _Event:
+ def __init__(self, args: str = ""):
+ self._args = args
+ self.source = None
+
+ def get_command_args(self) -> str:
+ return self._args
+
+
+def homes(tmp_path, monkeypatch):
+ default_home = tmp_path / "default"
+ routed_home = tmp_path / "profiles" / "beta"
+ default_home.mkdir()
+ routed_home.mkdir(parents=True)
+ (default_home / "config.yaml").write_text("agent:\n reasoning_effort: medium\n")
+ (routed_home / "config.yaml").write_text("agent:\n reasoning_effort: none\n")
+ monkeypatch.setattr(gateway_run, "_hermes_home", default_home)
+ monkeypatch.setenv("HERMES_HOME", str(default_home))
+ return default_home, routed_home
+
+
+async def test_slash_config_writes_hit_routed_profile_and_leave_default_untouched(homes):
+ default_home, routed_home = homes
+ default_before = (default_home / "config.yaml").read_bytes()
+ runner = _Runner()
+
+ with _profile_runtime_scope(routed_home):
+ assert runner._save_gateway_config_key("agent.reasoning_effort", "high")
+ await runner._handle_memory_command(_Event("approval on"))
+ await runner._handle_skills_command(_Event("approval on"))
+
+ routed = yaml.safe_load((routed_home / "config.yaml").read_text())
+ assert routed["agent"]["reasoning_effort"] == "high"
+ assert routed["memory"]["write_approval"] is True
+ assert routed["skills"]["write_approval"] is True
+ assert (default_home / "config.yaml").read_bytes() == default_before