Skip to content

Windows: kernel bootstrap uses venv bin/python, so the IPython kernel never starts and each retry wipes the venv #660

Description

@skulitom

Summary

On Windows, bootstrapVenv builds the kernel interpreter path as <venv>/bin/python, which is the POSIX venv layout. Windows venvs put the interpreter at <venv>/Scripts/python.exe, so the path never exists, uv pip install --python <that path> exits 2, and the kernel never starts.

Because the persistent IPython kernel is Prime Agent's only tool, the agent comes up with no ability to read files, grep, or run commands at all. It still answers from context files, which makes the failure easy to misread as a model problem rather than a bootstrap problem.

There is a second effect that makes it worse: each attempt re-runs uv venv --seed before it fails, so every retry recreates the venv and discards anything installed into it. Manually populating the venv appears to work and then silently vanishes on the next launch.

Environment

  • Prime Agent 0.7.0 (installed via the official install.shnpm install -g path)
  • Windows 11 Pro 26200, Node 22.14.0, npm 10.9.2
  • Git Bash present at C:\Program Files\Git\bin\bash.exe (satisfies docs/windows.md)
  • uv 0.12.2, Python 3.13.9
  • Kernel bootstrap ran at install time with PRIME_AGENT_BOOTSTRAP_KERNEL_ON_INSTALL=1 PRIME_AGENT_INSTALL_UV=1

Reproduce

prime-agent -p --cwd /path/to/any/repo "Use your Python kernel to grep this repo for the definition of some function. Report the file and line."

The agent replies that its kernel could not start and that it will not guess. ~/.prime/agent/kernel-venv/Lib/site-packages/ contains only pip, setuptools, and wheel — the --seed packages — and no ipykernel.

Observed errors

Straight out of the box:

Failed to set up the Python kernel runtime.
uv.exe pip install --python C:\Users\<user>\.prime\agent\kernel-venv\bin\python ipykernel ... failed with exit code 2

Note kernel-venv\bin\python: that path does not exist on Windows, and it has no .exe.

Setting PRIME_AGENT_KERNEL_PYTHON to the real interpreter (...\kernel-venv\Scripts\python.exe) moves past that, but then surfaces the remaining requirements one set at a time, so it takes three separate runs to discover the full list:

PRIME_AGENT_KERNEL_PYTHON points to a Python missing ipykernel and a current prime-agent-runtime: ...
PRIME_AGENT_KERNEL_PYTHON points to a Python missing default Python packages
  (requests, httpx, yaml, tomli, dotenv, pandas, numpy, scipy, bs4, lxml, pydantic): ...

Root cause

packages/coding-agent/src/core/kernel/bootstrap.ts:

  • L728const python = path.join(venv, "bin", "python"); in bootstrapVenv, then passed as --python to uv pip install at L735-744.
  • L889 — the same join in ensureKernelPython, feeding kernelReady(python, ...) at L891.

Neither branches on platform, although the same file does exactly that elsewhere — L503 (process.platform === "win32" ? [name, ${name}.exe] : [name]) and L518 for locating uv.

The wipe-on-retry follows from the same bad path: kernelReady at L891 is checked against <venv>/bin/python, so on Windows it is always false, the code always falls through to bootstrapVenv, and L734 runs uv venv <venv> --seed again, recreating the directory before the install fails.

The existing tests bake in the POSIX layout too — test/ipython-bootstrap.test.ts and test/kernel-state-roundtrip.test.ts both assert join(homedir(), ".prime", "agent", "kernel-venv", "bin", "python"), and test/kernel-bootstrap.test.ts writes its fake interpreter to $venv/bin/python with chmod +x, so no test would catch this.

Suggested fix

A platform-aware helper used by both sites, matching the L503 pattern:

const venvPython = (venv: string) =>
  process.platform === "win32"
    ? path.join(venv, "Scripts", "python.exe")
    : path.join(venv, "bin", "python");

Two things worth pairing with it:

  1. Don't run uv venv --seed until the interpreter path resolves, so a failed bootstrap can't destroy a working venv.
  2. Report the full missing-requirement set at once instead of one group per run.

Workaround

For anyone hitting this before a fix lands — provision the venv directly and pin the override, since letting auto-bootstrap run again will clear it:

P="$HOME/.prime/agent/kernel-venv/Scripts/python.exe"
R="<npm-global>/node_modules/prime-agent/dist/prime-agent-runtime"
uv pip install --python "$P" ipykernel "$R"
uv pip install --python "$P" requests httpx pyyaml tomli python-dotenv pandas numpy scipy beautifulsoup4 lxml pydantic
export PRIME_AGENT_KERNEL_PYTHON='C:\Users\<user>\.prime\agent\kernel-venv\Scripts\python.exe'

With that in place the kernel starts and works correctly — verified by having the agent grep a repo and return a function's defining file and line number, which matched an independent grep exactly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions