Skip to content

fix(v1): isolate Bash commands from harness venv - #2251

Open
eigenpaul wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
eigenpaul:fix/v1-bash-harness-env-leak
Open

fix(v1): isolate Bash commands from harness venv#2251
eigenpaul wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
eigenpaul:fix/v1-bash-harness-env-leak

Conversation

@eigenpaul

@eigenpaul eigenpaul commented Aug 4, 2026

Copy link
Copy Markdown

Fixes #2250

This PR runs Bash subprocesses with a copy of the controller environment that removes VIRTUAL_ENV and the harness added PATH entries. The controller environment itself is unchanged.

Verified in a Prime python:3.11-slim sandbox:

command -v python3
python3 --version
command -v pip
command -v pip3
python3 -m pip --version

Current main:

/root/.cache/uv/environments-v2/<environment-id>/bin/python3
Python 3.11.15
/usr/local/bin/pip
/usr/local/bin/pip3
/root/.cache/uv/environments-v2/<environment-id>/bin/python3: No module named pip

With this patch:

/usr/local/bin/python3
Python 3.11.15
/usr/local/bin/pip
/usr/local/bin/pip3
pip 24.0 from /usr/local/lib/python3.11/site-packages/pip (python 3.11)

#2011 identified the same root cause but that PR targets the old default harness path.


Note

Low Risk
Small, localized change to bash tool env handling with no auth or data-path impact; main risk is edge cases if PATH stripping is incomplete on unusual layouts.

Overview
Bash tool subprocesses no longer inherit the harness’s uv virtualenv. run_bash now runs bash -c with a copied environment that drops VIRTUAL_ENV and strips the harness-added PATH prefix ({venv}/bin and $HOME/.local/bin), so agent commands resolve to the sandbox’s system Python and pip instead of the controller interpreter.

The harness process environment is unchanged; only the bash tool’s child process gets the sanitized copy.

Reviewed by Cursor Bugbot for commit 87f3994. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Isolate Bash harness subprocess execution from the harness virtualenv

The run_bash helper in program.py now strips harness virtualenv paths from the subprocess environment before running user commands. It removes VIRTUAL_ENV and strips the leading venv and ~/.local/bin entries from PATH, so user scripts resolve executables from the system environment rather than the harness venv. Risk: changes which executables are resolved for any bash command run through this harness.

Macroscope summarized 87f3994.

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.

v1: Bash harness leaks its uv environment into agent commands

1 participant