Skip to content

Fix v1 MCP setup in task sandboxes#1391

Open
xeophon wants to merge 1 commit into
mainfrom
fix/v1-clean-pip-install
Open

Fix v1 MCP setup in task sandboxes#1391
xeophon wants to merge 1 commit into
mainfrom
fix/v1-clean-pip-install

Conversation

@xeophon
Copy link
Copy Markdown
Member

@xeophon xeophon commented May 15, 2026

Summary

  • make v1 sandbox package installs ignore image-level pip config/env settings
  • provision Python 3.11 for MCP proxy packages when a task image has python3 < 3.10
  • have MCP proxy commands use the recorded interpreter path

Testing

  • uv run ruff format
  • uv run ruff check --fix
  • uv run pytest tests/test_v1_runtime_lifecycle.py -q
  • uv run pytest tests/test_v1_harbor_cli.py -q
  • uv run pre-commit run --files tests/test_v1_runtime_lifecycle.py tests/test_v1_harbor_cli.py verifiers/v1/utils/sandbox_utils.py verifiers/v1/utils/mcp_proxy_utils.py
  • targeted old-Python SWE-bench Pro sandbox setup: installed mcp/requests and imported both with /tmp/vf_mcp_python
  • 3x1 GPT-5.5 + OpenCode smoke got past the original pip-index failure and ran real rollouts; remaining 0-turn failure was traced to python3 < 3.10 and fixed by the targeted setup check

Note

Medium Risk
Changes sandbox package installation and MCP proxy invocation logic, which can affect how user programs/tools run inside task sandboxes (dependency resolution and interpreter selection). Risk is mitigated by added/updated unit tests but could still surface in diverse base images/environments.

Overview
Fixes v1 MCP execution in task sandboxes by recording and reusing a sandbox-resolved Python interpreter for the MCP proxy instead of hardcoding python3. proxy_command() now runs via /bin/sh -lc, reads the interpreter path from MCP_PROXY_PYTHON_PATH (fallback to python3), and tests are updated to assert the new command shape.

Hardens sandbox dependency installation: python_package_install_command() now ignores image-level pip configuration (clears PIP_CONFIG_FILE and related PIP_* env vars) and, when mcp is requested, bootstraps uv to install MCP under Python 3.11, writing that interpreter path to MCP_PROXY_PYTHON_PATH. Adds targeted tests plus a real-sandbox test that runs MCP via the recorded interpreter path.

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

Note

Fix MCP proxy setup in v1 task sandboxes to use a dynamically installed Python interpreter

  • Refactors python_package_install_command in sandbox_utils.py to separate mcp* packages from others: mcp packages are installed via uv tool install with a pinned Python 3.11, while non-mcp packages use pip.
  • Writes the resulting tool interpreter path to /tmp/vf_mcp_python (constant MCP_PROXY_PYTHON_PATH) so it can be referenced at runtime.
  • Rewrites proxy_command in mcp_proxy_utils.py to wrap execution in /bin/sh -lc, reading the interpreter path from MCP_PROXY_PYTHON_PATH and falling back to python3 if missing.
  • Adds a preamble to the install command that exports PIP_CONFIG_FILE=/dev/null and unsets pip index env vars to prevent image-level pip config from interfering.
  • Behavioral Change: MCP proxy commands are now shell-wrapped (/bin/sh -lc) instead of direct python3 invocations, and pip config from the sandbox image is explicitly ignored during package installation.

Macroscope summarized 284a2cc.

@macroscopeapp
Copy link
Copy Markdown

macroscopeapp Bot commented May 15, 2026

Approvability

Verdict: Needs human review

This PR significantly changes how MCP packages are installed and executed in task sandboxes, including new isolated installation via uv, shell command generation, and Python path discovery logic. These runtime infrastructure changes warrant careful human review.

You can customize Macroscope's approvability policy. Learn more.

@xeophon xeophon force-pushed the fix/v1-clean-pip-install branch from 1049158 to 284a2cc Compare May 20, 2026 09:33
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 284a2cc075

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +538 to +540
'env PYTHONPATH="$VF_UV_SITE_PACKAGES" "$PYTHON" -m uv --no-config tool install '
f"--python 3.11 --with {shlex.quote(requests_package)} {mcp_package_args}\n"
f'printf "%s\\n" "$UV_TOOL_DIR/mcp/bin/python" > {shlex.quote(MCP_PROXY_PYTHON_PATH)}\n'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Pass a single tool package to uv tool install

This builds uv ... tool install ... {mcp_package_args} from every sandbox.packages entry starting with mcp, but uv tool install --help shows Usage: uv tool install [OPTIONS] <PACKAGE> (exactly one positional package). If a sandbox includes more than one mcp* requirement (for example the default mcp>=... plus mcp-agent), setup will fail with unexpected argument ... before installation completes, which breaks MCP-enabled rollouts that previously accepted multiple packages via pip install.

Useful? React with 👍 / 👎.

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.

1 participant