Skip to content

fix: strip VIRTUAL_ENV from subprocess environment to avoid venv contamination (#23473)#23905

Closed
LiWeny16 wants to merge 1 commit into
NousResearch:mainfrom
LiWeny16:fix/23473-virtual-env-leak
Closed

fix: strip VIRTUAL_ENV from subprocess environment to avoid venv contamination (#23473)#23905
LiWeny16 wants to merge 1 commit into
NousResearch:mainfrom
LiWeny16:fix/23473-virtual-env-leak

Conversation

@LiWeny16

Copy link
Copy Markdown

Summary

When Hermes Agent spawns subprocesses (e.g., for code execution in the local.py environment), the VIRTUAL_ENV environment variable leaks from the parent process into the child. If the child process uses a different Python virtual environment, this causes import errors and unexpected behavior.

Root cause

The _build_provider_env_blocklist() function in tools/environments/local.py blocked several environment variables from leaking into subprocesses, but VIRTUAL_ENV was not included.

Fix

Added "VIRTUAL_ENV" to the blocked environment variables set, ensuring subprocesses get a clean environment without parent venv contamination.

Fixes #23473

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent loop, run_agent.py, prompt builder backend/local Local shell execution P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels May 11, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #23474 — same VIRTUAL_ENV strip fix. This PR bundles 3 unrelated fixes (identical diff to #23904 and #23903) from a stacked branch.

When Hermes Agent spawns subprocesses for code execution, VIRTUAL_ENV
leaks from the parent process, causing import errors when the child
uses a different virtual environment.

Added "VIRTUAL_ENV" to the blocked environment variables set in
_build_provider_env_blocklist().

Fixes: NousResearch#23473
@LiWeny16 LiWeny16 force-pushed the fix/23473-virtual-env-leak branch from 305feb8 to ed66023 Compare May 11, 2026 17:44
@LiWeny16

Copy link
Copy Markdown
Author

Thanks for the review. I've rebuilt the branches from latest main — each PR now contains only its single targeted fix instead of stacked commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend/local Local shell execution comp/agent Core agent loop, run_agent.py, prompt builder duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway leaks VIRTUAL_ENV into subprocesses; agent's uv sync in any project bricks Hermes' own venv

2 participants