The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(delegation): a global backend switch is refused on a managed install
Teknium070dac76faad
diff --git a/agent/delegation_backends.py b/agent/delegation_backends.pyindex 180c0ab11b4..e19ac9dec3a 100644--- a/agent/delegation_backends.py+++ b/agent/delegation_backends.py@@ -74,8 +74,14 @@ def set_session_backend(session_key: str, name: Optional[str]) -> None:def set_global_backend(name: str, *, session_key: str = "") -> None:"""Persist ``delegation.backend`` to the active profile's config.yaml (raw user config, never merged- defaults) and drop ``session_key``'s override, which would otherwise shadow it."""- from hermes_cli.config import atomic_config_write, get_config_path, read_user_config_raw+ defaults) and drop ``session_key``'s override, which would otherwise shadow it. Raises ``PermissionError``+ on a package-manager-managed install (its config.yaml is not ours to write) and ``ValueError`` for a backend+ that cannot run."""+ from hermes_cli.config import (+ atomic_config_write, format_managed_message, get_config_path, is_managed, read_user_config_raw,+ )+ if is_managed():+ raise PermissionError(format_managed_message("set delegation.backend"))key = lower_key(name)info = _info(key)if not info.available:diff --git a/tests/tools/test_delegation_backends.py b/tests/tools/test_delegation_backends.pyindex c72b4bf8ed4..3819f0ce43c 100644--- a/tests/tools/test_delegation_backends.py+++ b/tests/tools/test_delegation_backends.py@@ -227,6 +227,21 @@ def test_a_session_backend_switch_routes_that_session_only_and_global_persists(tmanager.unload()+def test_a_global_backend_switch_is_refused_on_a_managed_install(tmp_path, monkeypatch):+ """Like every other config writer: a package-manager-managed install's config.yaml is never written."""+ home, manager = _home(tmp_path, monkeypatch, {"backend": "probe-options"})+ try:+ from agent.delegation_backends import set_global_backend++ before = (home / "config.yaml").read_bytes()+ monkeypatch.setenv("HERMES_MANAGED", "nixos")+ with pytest.raises(PermissionError, match="managed by nixos"):+ set_global_backend("default")+ assert (home / "config.yaml").read_bytes() == before+ finally:+ manager.unload()++def test_plugin_parameters_never_redefine_core_or_route_fields(tmp_path, monkeypatch):from agent.delegation_provider import DelegationProviderfrom tools.delegate_tool_routes import schema_extension