Skip to content

fix(runtimes): harness setup reuses an installed uv - #2575

Draft
faresobeid wants to merge 1 commit into
mainfrom
fix/ensure-uv-present
Draft

fix(runtimes): harness setup reuses an installed uv#2575
faresobeid wants to merge 1 commit into
mainfrom
fix/ensure-uv-present

Conversation

@faresobeid

@faresobeid faresobeid commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

What

_ENSURE_UV (runtimes/base.py; also used by mcp/launch.py) now runs command -v uv first and skips both pip install -q -U --user uv and the astral installer when uv is already on PATH. The PATH export still comes first, so a ~/.local/bin/uv from an earlier rollout on the same box counts. Images without uv take the same install path as before.

Why

In a pipeline opening ~90 concurrent rollouts on prime sandboxes, about 3% of opens failed in harness setup because _ENSURE_UV downloads uv on every prepare_uv_script (pip on PyPI, else astral.sh) over flaky egress — even on images that ship uv. A uv that is already present needs no network at all.

Behavior change: uv is no longer upgraded to the latest release when one is present. prepare_uv_script needs a uv that knows uv sync --script / uv python find --script; an image with a very old pre-installed uv would now surface uv's own argument error instead of being silently upgraded.

Validation

  • tests/v1/test_runtimes.py runs the real snippet under sh with a stub pip (leaves a marker, drops a uv into ~/.local/bin) and an optional stub uv: with uv present, pip does not run; without it, pip runs and uv is then found. Also asserts command -v uv precedes pip install in the composed command.
  • e2e test_single_turn[null-harness-in-subprocess] and test_agentic[bash-harness-in-subprocess] pass (they run prepare_uv_script on a host with uv pre-installed).
  • uv run pytest tests/v1 -m "not e2e", ruff, pre-commit pass.

Note

Fix _ENSURE_UV to reuse an installed uv on PATH

  • Changes the shell sequence in base.py to check whether uv is already discoverable before the pip-install branch; the curl/wget fallback still follows.
  • Adds test helpers in test_runtimes.py that stub pip and uv on a temporary PATH, plus a test asserting existing uv is preserved and missing uv triggers installation.
  • Behavioral Change: runtime setup now skips installation when uv is already on PATH, instead of always running the pip branch.

Macroscope summarized b94df19.

`_ENSURE_UV` checks `command -v uv` before installing: an image that
pre-installs uv (or a box a previous rollout already set up) skips both
`pip install -U --user uv` and the astral installer, so harness setup no
longer depends on egress to PyPI / astral.sh when uv is already present.
Images without uv take the same install path as before.
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