fix: per-profile subprocess HOME isolation (#4426)#7357
Merged
Conversation
Isolate system tool configs (git, ssh, gh, npm) per profile by injecting
a per-profile HOME into subprocess environments only. The Python
process's own os.environ['HOME'] and Path.home() are never modified,
preserving all existing profile infrastructure.
Activation is directory-based: when {HERMES_HOME}/home/ exists on disk,
subprocesses see it as HOME. The directory is created automatically for:
- Docker: entrypoint.sh bootstraps it inside the persistent volume
- Named profiles: added to _PROFILE_DIRS in profiles.py
Injection points (all three subprocess env builders):
- tools/environments/local.py _make_run_env() — foreground terminal
- tools/environments/local.py _sanitize_subprocess_env() — background procs
- tools/code_execution_tool.py child_env — execute_code sandbox
Single source of truth: hermes_constants.get_subprocess_home()
Closes #4426
Tommyeds
pushed a commit
to Tommyeds/hermes-agent
that referenced
this pull request
Apr 12, 2026
…esearch#7357) Isolate system tool configs (git, ssh, gh, npm) per profile by injecting a per-profile HOME into subprocess environments only. The Python process's own os.environ['HOME'] and Path.home() are never modified, preserving all existing profile infrastructure. Activation is directory-based: when {HERMES_HOME}/home/ exists on disk, subprocesses see it as HOME. The directory is created automatically for: - Docker: entrypoint.sh bootstraps it inside the persistent volume - Named profiles: added to _PROFILE_DIRS in profiles.py Injection points (all three subprocess env builders): - tools/environments/local.py _make_run_env() — foreground terminal - tools/environments/local.py _sanitize_subprocess_env() — background procs - tools/code_execution_tool.py child_env — execute_code sandbox Single source of truth: hermes_constants.get_subprocess_home() Closes NousResearch#4426
1 task
ulasbilgen
pushed a commit
to ulasbilgen/hermes-adhd-agent
that referenced
this pull request
May 1, 2026
…esearch#7357) Isolate system tool configs (git, ssh, gh, npm) per profile by injecting a per-profile HOME into subprocess environments only. The Python process's own os.environ['HOME'] and Path.home() are never modified, preserving all existing profile infrastructure. Activation is directory-based: when {HERMES_HOME}/home/ exists on disk, subprocesses see it as HOME. The directory is created automatically for: - Docker: entrypoint.sh bootstraps it inside the persistent volume - Named profiles: added to _PROFILE_DIRS in profiles.py Injection points (all three subprocess env builders): - tools/environments/local.py _make_run_env() — foreground terminal - tools/environments/local.py _sanitize_subprocess_env() — background procs - tools/code_execution_tool.py child_env — execute_code sandbox Single source of truth: hermes_constants.get_subprocess_home() Closes NousResearch#4426
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
…esearch#7357) Isolate system tool configs (git, ssh, gh, npm) per profile by injecting a per-profile HOME into subprocess environments only. The Python process's own os.environ['HOME'] and Path.home() are never modified, preserving all existing profile infrastructure. Activation is directory-based: when {HERMES_HOME}/home/ exists on disk, subprocesses see it as HOME. The directory is created automatically for: - Docker: entrypoint.sh bootstraps it inside the persistent volume - Named profiles: added to _PROFILE_DIRS in profiles.py Injection points (all three subprocess env builders): - tools/environments/local.py _make_run_env() — foreground terminal - tools/environments/local.py _sanitize_subprocess_env() — background procs - tools/code_execution_tool.py child_env — execute_code sandbox Single source of truth: hermes_constants.get_subprocess_home() Closes NousResearch#4426
olympus-terminal
pushed a commit
to olympus-terminal/hermes-agent
that referenced
this pull request
May 16, 2026
…esearch#7357) Isolate system tool configs (git, ssh, gh, npm) per profile by injecting a per-profile HOME into subprocess environments only. The Python process's own os.environ['HOME'] and Path.home() are never modified, preserving all existing profile infrastructure. Activation is directory-based: when {HERMES_HOME}/home/ exists on disk, subprocesses see it as HOME. The directory is created automatically for: - Docker: entrypoint.sh bootstraps it inside the persistent volume - Named profiles: added to _PROFILE_DIRS in profiles.py Injection points (all three subprocess env builders): - tools/environments/local.py _make_run_env() — foreground terminal - tools/environments/local.py _sanitize_subprocess_env() — background procs - tools/code_execution_tool.py child_env — execute_code sandbox Single source of truth: hermes_constants.get_subprocess_home() Closes NousResearch#4426
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
…esearch#7357) Isolate system tool configs (git, ssh, gh, npm) per profile by injecting a per-profile HOME into subprocess environments only. The Python process's own os.environ['HOME'] and Path.home() are never modified, preserving all existing profile infrastructure. Activation is directory-based: when {HERMES_HOME}/home/ exists on disk, subprocesses see it as HOME. The directory is created automatically for: - Docker: entrypoint.sh bootstraps it inside the persistent volume - Named profiles: added to _PROFILE_DIRS in profiles.py Injection points (all three subprocess env builders): - tools/environments/local.py _make_run_env() — foreground terminal - tools/environments/local.py _sanitize_subprocess_env() — background procs - tools/code_execution_tool.py child_env — execute_code sandbox Single source of truth: hermes_constants.get_subprocess_home() Closes NousResearch#4426
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
…esearch#7357) Isolate system tool configs (git, ssh, gh, npm) per profile by injecting a per-profile HOME into subprocess environments only. The Python process's own os.environ['HOME'] and Path.home() are never modified, preserving all existing profile infrastructure. Activation is directory-based: when {HERMES_HOME}/home/ exists on disk, subprocesses see it as HOME. The directory is created automatically for: - Docker: entrypoint.sh bootstraps it inside the persistent volume - Named profiles: added to _PROFILE_DIRS in profiles.py Injection points (all three subprocess env builders): - tools/environments/local.py _make_run_env() — foreground terminal - tools/environments/local.py _sanitize_subprocess_env() — background procs - tools/code_execution_tool.py child_env — execute_code sandbox Single source of truth: hermes_constants.get_subprocess_home() Closes NousResearch#4426
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Isolates system tool configs (git, ssh, gh, npm) per profile by injecting a per-profile HOME into subprocess environments only. The Python process's own
os.environ["HOME"]andPath.home()are never modified.Closes #4426
The problem
Two related bugs share a root cause:
/root/don't persist when the container is recreated — only/opt/data(the persistent volume) survives./root/'s git identity, SSH keys, gh tokens, etc.Why previous approaches were rejected
PR #4437 and PR #4685 both set
os.environ["HOME"]globally in the Python process. This breaksPath.home()which is used by 42 files — profile infrastructure (_get_profiles_root(),_get_default_hermes_home(),_get_wrapper_dir()), systemd/launchd paths, and every Python library that callsos.path.expanduser().This approach: subprocess-only injection
Every subprocess the agent spawns goes through one of three choke points that already build custom env dicts. We inject
HOME={HERMES_HOME}/home/at these three points:_make_run_env()tools/environments/local.py_sanitize_subprocess_env()tools/environments/local.pychild_envconstructiontools/code_execution_tool.pySingle source of truth:
hermes_constants.get_subprocess_home()Activation
Directory-based — zero config needed:
{HERMES_HOME}/home/exists → subprocesses get it as HOMEWho creates the directory:
entrypoint.shbootstraps it inside the persistent volume"home"to_PROFILE_DIRSin profiles.pyWhat this preserves
Path.home()untouched → profile infrastructure, systemd paths, wrapper dirs all workos.environ["HOME"]untouched → no impact on Python process internalsbash -c(non-login, used for terminal commands) doesn't source profile filesChanges
hermes_constants.pyget_subprocess_home()— returns{HERMES_HOME}/home/if it existstools/environments/local.py_make_run_env()and_sanitize_subprocess_env()tools/code_execution_tool.pyhermes_cli/profiles.py"home"to_PROFILE_DIRSdocker/entrypoint.shhometo bootstrapped directoriestests/test_subprocess_home_isolation.pyTest plan
python3 -m pytest tests/test_subprocess_home_isolation.py— 13/13 ✓python3 -m pytest tests/tools/test_local_env_blocklist.py tests/hermes_cli/test_profiles.py tests/tools/test_env_passthrough.py— 121/121 ✓python3 -m pytest tests/tools/test_code_execution.py— 63/63 ✓