fix: strip VIRTUAL_ENV from subprocess environment to avoid venv contamination (#23473)#23905
Closed
LiWeny16 wants to merge 1 commit into
Closed
fix: strip VIRTUAL_ENV from subprocess environment to avoid venv contamination (#23473)#23905LiWeny16 wants to merge 1 commit into
LiWeny16 wants to merge 1 commit into
Conversation
Collaborator
This was referenced May 11, 2026
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
305feb8 to
ed66023
Compare
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. |
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
When Hermes Agent spawns subprocesses (e.g., for code execution in the
local.pyenvironment), theVIRTUAL_ENVenvironment 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 intools/environments/local.pyblocked several environment variables from leaking into subprocesses, butVIRTUAL_ENVwas not included.Fix
Added
"VIRTUAL_ENV"to the blocked environment variables set, ensuring subprocesses get a clean environment without parent venv contamination.Fixes #23473