Skip to content

Sandbox agents in egg repo lack working .venv, silently fall back to system Python #2087

Closed

Description

@jwbron

Observation

Sandbox agents running against the egg repo do not have access to the project's .venv. From a recent issue-1962 coder container:

  • ls .venv/ → No such file or directory
  • python3 -c "import sys; print('\n'.join(sys.path))" resolves to /usr/lib/python313 (system Python), with /opt/egg-runtime/{sandbox,shared} on the path but no project venv.

.venv is gitignored, so the gateway worktree mount does not bring it into the container, and restore_prebuilt_deps does not populate it for jwbron/egg repos.

Impact

  • Agents that run make lint, make test, make security, or any direct Python tooling get system Python, missing project dev dependencies (ruff, mypy, pytest, bandit, etc.).
  • Symptoms surface inconsistently — e.g., .venv/bin/python permission denied breaks custom lint checks #1541 reported .venv/bin/python: Permission denied from make lint-custom, but the underlying problem is broader: agents don't have a working project Python environment.
  • Behavior diverges from host development (where make deps produces a usable .venv), so an agent's local pass signal is not equivalent to CI.

Possible causes

This may be a tool-availability problem, a prompting problem, or both:

  1. Tool availability — the .venv is not part of the gateway-mounted worktree (gitignored) and does not appear under /opt/prebuilt-deps/jwbron--egg/. Options: prebuild .venv into the prebuilt-deps snapshot, run make deps on container start, or otherwise expose project deps to whatever Python the agent invokes.
  2. Prompting — even if .venv were present, agents are not told to use it. The Makefile's PYTHON := $(if $(wildcard $(VENV_BIN)/python),$(VENV_BIN)/python,python3) auto-detects, but agents that invoke python3 / pytest / ruff directly will bypass it.

Acceptance criteria

  • A fresh sandbox container working in the egg repo can:
    • Import a project dev dependency without falling back to system site-packages (e.g., python -c "import ruff" succeeds and resolves from project deps).
    • Run make lint and make test against the same toolchain CI uses, without Permission denied or ModuleNotFoundError for project dev deps.
  • The choice of fix (prebuilt snapshot, on-start install, image-baked deps, etc.) is open.

Background

Supersedes #1541, which was filed against the symptom (.venv/bin/python: Permission denied from make lint-custom). The actual problem is that no .venv exists in the agent's working tree at all, so any path through it fails — permission denied is one of several possible failure modes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions