Skip to content

fix: make profile subprocess HOME policy explicit#46075

Merged
teknium1 merged 2 commits into
mainfrom
fix/profile-home-policy
Jun 14, 2026
Merged

fix: make profile subprocess HOME policy explicit#46075
teknium1 merged 2 commits into
mainfrom
fix/profile-home-policy

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Profile subprocesses now keep the real OS-user HOME on host installs by default, while profile state remains scoped by HERMES_HOME and containers keep persistent profile-home behavior.

This salvages #25151's HERMES_REAL_HOME idea, but fixes the larger CLI side effect: opaque tools like git, ssh, gh, az, Claude Code, Codex, and npm should not lose their normal ~ credentials just because Hermes is running under a named profile.

Changes

  • Preserves @zccyman's HERMES_REAL_HOME exposure for child scripts.
  • Adds one shared apply_subprocess_home_env() helper for terminal, background processes, execute_code, and Copilot ACP children.
  • Adds terminal.home_mode:
    • auto default: host subprocesses keep real HOME; containers use {HERMES_HOME}/home.
    • real: force real OS-user HOME.
    • profile: opt into the old strict {HERMES_HOME}/home behavior.
  • Repairs subprocess envs when a parent process already has HOME pointed at a profile home/ directory and HERMES_REAL_HOME/OS account home can recover the real home.
  • Documents the contract in configuration/profile docs and updates config examples/tips.

Validation

Check Result
Targeted wrapper 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 passed
Direct focused pytest env -u PYTEST_PLUGINS python -m pytest ... -q -o addopts= → 52 passed
Compile py_compile on changed Python files → passed
Diff hygiene git diff --check → passed
E2E auto host execute_code child saw real HOME, HERMES_REAL_HOME, and profile HERMES_HOME
E2E profile opt-in execute_code child saw profile HOME plus real HERMES_REAL_HOME

Closes #25114.
Helps #36144 and #29015.
Salvages #25151 with attribution preserved.

Infographic

profile-home-policy

…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
@github-actions

github-actions Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: fix/profile-home-policy vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 10893 on HEAD, 10895 on base (✅ -2)

🆕 New issues (1):

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.

@teknium1 teknium1 force-pushed the fix/profile-home-policy branch from b787939 to 75de214 Compare June 14, 2026 10:12
@teknium1 teknium1 merged commit 723c233 into main Jun 14, 2026
29 checks passed
@teknium1 teknium1 deleted the fix/profile-home-policy branch June 14, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: HOME env corrupted inside Hermes profile runtime context — Path.home() resolves to wrong directory

2 participants