fix: make profile subprocess HOME policy explicit#46075
Merged
Conversation
…olation
When profile isolation activates ({HERMES_HOME}/home/ exists), child
processes receive HOME={HERMES_HOME}/home/ for tool config isolation
(git, ssh, gh). However, scripts using Path.home() to locate
~/.hermes/ would incorrectly resolve to the isolated profile home,
breaking helpers that rely on the real user home directory.
New get_real_home() helper in hermes_constants resolves the actual
user home independently of profile isolation. All four subprocess
spawners now inject HERMES_REAL_HOME alongside the profile HOME:
- tools/code_execution_tool.py (execute_code)
- tools/environments/local.py (terminal background, run_env)
- agent/copilot_acp_client.py (Copilot ACP)
Child scripts can now use:
Path(os.environ.get("HERMES_REAL_HOME", os.environ.get("HOME", "")))
to reliably find the real user home regardless of profile isolation.
Closes #25114
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
invalid-assignment |
1 |
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [invalid-assignment] invalid-assignment: Object of type `None` is not assignable to attribute `_credits_session_start_micros` of type `int`
✅ Fixed issues (2):
| Rule | Count |
|---|---|
unresolved-attribute |
2 |
First entries
run_agent.py:2891: [unresolved-attribute] unresolved-attribute: Object of type `Self@get_credits_spent_micros` has no attribute `_credits_session_start_micros`
tests/run_agent/test_credits_notices_toggle.py:76: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_credits_session_start_micros` on type `AIAgent`
Unchanged: 5724 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
b787939 to
75de214
Compare
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
Profile subprocesses now keep the real OS-user
HOMEon host installs by default, while profile state remains scoped byHERMES_HOMEand containers keep persistent profile-home behavior.This salvages #25151's
HERMES_REAL_HOMEidea, but fixes the larger CLI side effect: opaque tools likegit,ssh,gh,az, Claude Code, Codex, and npm should not lose their normal~credentials just because Hermes is running under a named profile.Changes
HERMES_REAL_HOMEexposure for child scripts.apply_subprocess_home_env()helper for terminal, background processes,execute_code, and Copilot ACP children.terminal.home_mode:autodefault: host subprocesses keep realHOME; containers use{HERMES_HOME}/home.real: force real OS-userHOME.profile: opt into the old strict{HERMES_HOME}/homebehavior.HOMEpointed at a profilehome/directory andHERMES_REAL_HOME/OS account home can recover the real home.Validation
scripts/run_tests.sh tests/test_subprocess_home_isolation.py tests/agent/test_copilot_acp_client.py tests/gateway/test_config_cwd_bridge.py→ 52 passedenv -u PYTEST_PLUGINS python -m pytest ... -q -o addopts=→ 52 passedpy_compileon changed Python files → passedgit diff --check→ passedexecute_codechild saw realHOME,HERMES_REAL_HOME, and profileHERMES_HOMEexecute_codechild saw profileHOMEplus realHERMES_REAL_HOMECloses #25114.
Helps #36144 and #29015.
Salvages #25151 with attribution preserved.
Infographic