Skip to content

The agent that grows with you

fix: import managed_python_env at the git-path site; assert the managed-env contract in the repair test

Teknium0c14f060dbd3
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.py
index 4bb78f9dab7..7b40ed03de6 100644
--- a/hermes_cli/update_cmd.py
+++ b/hermes_cli/update_cmd.py
@@ -6652,6 +6652,8 @@ def _cmd_update_impl(args, gateway_mode: bool):
# Use official managed_python_env() isolation so third-party
# UV_PYTHON_INSTALL_DIR (e.g. WorkBuddy) cannot hijack uv; then
# point VIRTUAL_ENV at this install's venv.
+ from hermes_cli.managed_uv import managed_python_env
+
uv_env = managed_python_env()
uv_env["VIRTUAL_ENV"] = str(_m().PROJECT_ROOT / "venv")
if _m()._is_termux_env(uv_env):
diff --git a/tests/hermes_cli/test_lazy_refresh_venv_repair.py b/tests/hermes_cli/test_lazy_refresh_venv_repair.py
index 3c18fd95995..a7e7ff9a90c 100644
--- a/tests/hermes_cli/test_lazy_refresh_venv_repair.py
+++ b/tests/hermes_cli/test_lazy_refresh_venv_repair.py
@@ -232,10 +232,17 @@ def test_cmd_update_captures_and_propagates_pre_rebuild_snapshot(
with pytest.raises(RestoreReached):
m._cmd_update_impl(args, gateway_mode=False)
+ # The repair env is now built via managed_python_env (#83914): third-party
+ # UV vars are stripped, managed pins set, then VIRTUAL_ENV re-pointed at
+ # the install's venv. Assert the CONTRACT, not the raw environ copy.
+ from hermes_cli.managed_uv import managed_python_env
+
+ expected_env = managed_python_env()
+ expected_env["VIRTUAL_ENV"] = str(tmp_path / "venv")
assert refresh_calls == [
(
["uv", "pip"],
- {**m.os.environ, "VIRTUAL_ENV": str(tmp_path / "venv")},
+ expected_env,
snapshot,
)
]
@@ -243,7 +250,7 @@ def test_cmd_update_captures_and_propagates_pre_rebuild_snapshot(
(
tool_snapshot,
["uv", "pip"],
- {**m.os.environ, "VIRTUAL_ENV": str(tmp_path / "venv")},
+ expected_env,
)
]