The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(child-env): openviking, raft and buzz keep the user's HOME
kshitijk4poore14936b5088f
diff --git a/plugins/memory/openviking/__init__.py b/plugins/memory/openviking/__init__.pyindex 8e21c70b268..845427e9b79 100644--- a/plugins/memory/openviking/__init__.py+++ b/plugins/memory/openviking/__init__.py@@ -983,8 +983,7 @@ def _start_local_openviking_server(endpoint: str) -> tuple[str, str]:# and relay tokens never do. HOME stays the user's: ov.conf defaults to ~/.openviking.from tools.environments.local import hermes_subprocess_envchild_env = hermes_subprocess_env(inherit_credentials=True)- if "HOME" in os.environ:- child_env["HOME"] = os.environ["HOME"]+ child_env["HOME"] = child_env["HERMES_REAL_HOME"]child_env.pop("PYTHONPATH", None)with log_path.open("ab") as log_file:subprocess.Popen([server_cmd, "--host", host, "--port", str(port)], stdout=log_file, stderr=log_file,diff --git a/plugins/platforms/buzz/adapter.py b/plugins/platforms/buzz/adapter.pyindex 6b3275a18e7..1288c48ee26 100644--- a/plugins/platforms/buzz/adapter.py+++ b/plugins/platforms/buzz/adapter.py@@ -394,6 +394,7 @@ async def _exec_buzz("""Run the buzz CLI (argv, never a shell) -> ``(rc, stdout, stderr)``. Key travels via env only."""from tools.environments.local import hermes_subprocess_envenv = hermes_subprocess_env() # a third-party CLI: its own key only, never Hermes' credentials+ env["HOME"] = env["HERMES_REAL_HOME"] # its own config and credentials file live under the user's HOMEenv["BUZZ_RELAY_URL"] = relay_urlenv["BUZZ_PRIVATE_KEY"] = private_keyenv.pop("BUZZ_AUTH_TAG", None)diff --git a/plugins/platforms/raft/adapter.py b/plugins/platforms/raft/adapter.pyindex a8b80dd1165..941ef6375c1 100644--- a/plugins/platforms/raft/adapter.py+++ b/plugins/platforms/raft/adapter.py@@ -378,6 +378,7 @@ class RaftAdapter(BasePlatformAdapter):from tools.environments.local import hermes_subprocess_env# The raft CLI needs its own profile and channel token, never Hermes' credentials.env = {**hermes_subprocess_env(), "RAFT_PROFILE": profile, "RAFT_CHANNEL_TOKEN": self._bridge_token}+ env["HOME"] = env["HERMES_REAL_HOME"] # the raft CLI's own login lives under the user's HOMEtry:self._bridge_process = subprocess.Popen(cmd, env=env, stdin=subprocess.DEVNULL)logger.info("[raft] Spawned bridge pid=%d profile=%s endpoint=%s", self._bridge_process.pid, profile, endpoint)diff --git a/tests/tools/test_spawn_site_child_env.py b/tests/tools/test_spawn_site_child_env.pyindex 6d330d1e4da..d72c5bcdac6 100644--- a/tests/tools/test_spawn_site_child_env.py+++ b/tests/tools/test_spawn_site_child_env.py@@ -78,6 +78,7 @@ def test_openviking_server_keeps_provider_keys_but_never_tier1_secrets(child_env# It finds ov.conf through OPENVIKING_CONFIG_FILE or HOME; Hermes' PYTHONPATH would shadow its# own site-packages (#78153)._plant(monkeypatch)+ monkeypatch.setenv("TERMINAL_HOME_MODE", "profile") # HOME stays the user's even somonkeypatch.setenv("OPENVIKING_CONFIG_FILE", str(child_env / "ov.conf"))monkeypatch.setenv("PYTHONPATH", str(child_env / "hermes-venv"))own = {"OPENVIKING_CONFIG_FILE": str(child_env / "ov.conf"), "HOME": str(child_env), "PYTHONPATH": None}@@ -90,10 +91,14 @@ def test_openviking_server_keeps_provider_keys_but_never_tier1_secrets(child_env@pytest.mark.parametrize("site", ["lsp_server", "lsp_go_install", "lsp_npm_install", "raft_bridge", "buzz_cli"])def test_third_party_children_never_see_hermes_credentials(child_env, monkeypatch, site):_plant(monkeypatch)+ # Profile home mode (the container default) re-points HOME; the CLIs whose own logins live+ # under the user's HOME get it back, language servers and installers follow the terminal.+ monkeypatch.setenv("TERMINAL_HOME_MODE", "profile")+ (child_env / "hermes" / "home").mkdir(parents=True, exist_ok=True)out = child_env / "seen.json"own = {"lsp_server": "LSP_OWN_SETTING", "lsp_go_install": "GOBIN", "lsp_npm_install": "PATH","raft_bridge": "RAFT_CHANNEL_TOKEN", "buzz_cli": "BUZZ_PRIVATE_KEY"}[site]- probe = _probe_script(child_env / "probe", out, [*_TIER1, _PROVIDER, own])+ probe = _probe_script(child_env / "probe", out, [*_TIER1, _PROVIDER, own, "HOME"])if site == "lsp_server":from agent.lsp.client import LSPClient@@ -134,3 +139,5 @@ def test_third_party_children_never_see_hermes_credentials(child_env, monkeypatcseen = json.loads(out.read_text(encoding="utf-8"))assert {k: seen[k] for k in (*_TIER1, _PROVIDER)} == dict.fromkeys((*_TIER1, _PROVIDER))assert seen[own] # the child's own configuration still arrives+ user_home = site in ("raft_bridge", "buzz_cli")+ assert seen["HOME"] == str(child_env if user_home else child_env / "hermes" / "home")