[Bug] PRIME_AGENT_KERNEL_PYTHON makes every kernel start about 0.6 s slower #2875
Replies: 1 comment
|
Investigated this report and produced a candidate fix, validated on a fork of this repository. Root cause, fix and validation from the working notes:
Diff: awhite0030/prime-agent@main...fix-issue-2875-kernel-bootstrap-perf-1594963900057117039 The change passes |
Uh oh!
There was an error while loading. Please reload this page.
Affected area
Coding agent and CLI
What happened?
When
PRIME_AGENT_KERNEL_PYTHONis set,ensureKernelPythoninpackages/coding-agent/src/core/kernel/bootstrap.tsstarts a new Python process for each of the 12 default packages (python -c "import pandas", and so on). It does this one after another, and then once more for each Python skill. This runs before every kernel start. Without the override, the uv venv path checks its marker file and skips all of this.With the same Python, the override path is about 6 times slower.
Steps to reproduce
With the 0.9.6 release and
uvonPATH:I get 125 ms without the override and 747 ms with it. It is the same interpreter with the same packages. A real session also probes the 9 bundled skills, so the gap there is bigger.
Expected behavior
Pointing prime-agent at a ready Python should not cost more than letting it manage its own venv.
I patched our build to check all modules in one Python process with
importlib.util.find_spec. It returns the same missing-package labels and warnings.--prime-agent-bootstrapwent from 1.1 s to about 150 ms with our Nix-built Python, which is slower to import than the uv one. Batching the real imports in one process also works, at about 450 ms. I'm happy to share the patch.Prime Agent version
0.9.6
Installation method
From source
Operating system
macOS
Operating system version
macOS 27.0 (26A428)
CPU architecture
arm64 / aarch64
Shell and terminal
fish 4.9.3 (not terminal-specific)
All reactions