Skip to content

The agent that grows with you

fix(agent): repair a missing HOME in terminal.home_mode auto, not just a wrong one

chelsealong4c4924d28144
diff --git a/hermes_constants.py b/hermes_constants.py
index 48af7fab814..36e66563344 100644
--- a/hermes_constants.py
+++ b/hermes_constants.py
@@ -954,7 +954,7 @@ def get_subprocess_home(env: dict[str, str] | None = None) -> str | None:
if profile_home and is_container():
return profile_home
- if _is_profile_home(current_home, profile_home):
+ if not current_home or _is_profile_home(current_home, profile_home):
return repaired
return None
diff --git a/tests/tools/test_subprocess_home_isolation.py b/tests/tools/test_subprocess_home_isolation.py
index 48bf1ed6526..70bc05d05c3 100644
--- a/tests/tools/test_subprocess_home_isolation.py
+++ b/tests/tools/test_subprocess_home_isolation.py
@@ -49,6 +49,19 @@ class TestGetSubprocessHome:
from hermes_constants import get_subprocess_home
assert get_subprocess_home() is None
+ def test_host_auto_repairs_missing_home(self, tmp_path, monkeypatch):
+ """A systemd system unit with no HOME at all should still get real HOME repaired."""
+ self._host_mode(monkeypatch)
+ real_home = tmp_path / "real-home"
+ hermes_home = real_home / ".hermes" / "profiles" / "coder"
+ profile_home = hermes_home / "home"
+ profile_home.mkdir(parents=True)
+ monkeypatch.delenv("HOME", raising=False)
+ monkeypatch.setenv("HERMES_REAL_HOME", str(real_home))
+ monkeypatch.setenv("HERMES_HOME", str(hermes_home))
+ from hermes_constants import get_subprocess_home
+ assert get_subprocess_home() == str(real_home)
+
def test_container_auto_uses_profile_home_when_home_dir_exists(self, tmp_path, monkeypatch):
self._container_mode(monkeypatch)
hermes_home = tmp_path / ".hermes"