Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/coding-agent/docs/rlm-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ The Python side does not call providers or implement an agent loop.
The kernel is created lazily on first IPython use. Python resolution is:

1. `PRIME_AGENT_KERNEL_PYTHON`, when it can import `ipykernel`;
2. `~/.prime/agent/kernel-venv/bin/python`, bootstrapped with `uv`; or
2. `~/.prime/agent/kernel-venv/bin/python` (`Scripts\python.exe` on Windows), bootstrapped with `uv`; or

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 Record the Windows fix in the coding-agent changelog

This is a user-visible fix for Windows kernel startup, but packages/coding-agent/CHANGELOG.md remains unchanged with an empty [Unreleased] section. Add a one-line past-tense entry there so the fix is included in the next package release notes, as required by the root AGENTS.md.

AGENTS.md reference: AGENTS.md:L105-L112

Useful? React with 👍 / 👎.

3. the XDG data location when `~/.prime` is not writable.

The managed environment includes Python 3.11, `ipykernel`, and `prime-agent-runtime`. A bootstrap marker detects stale environments.
Expand Down
8 changes: 6 additions & 2 deletions packages/coding-agent/src/core/kernel/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ function expandHome(filePath: string): string {
return filePath;
}

export function venvPython(venv: string): string {
return process.platform === "win32" ? path.join(venv, "Scripts", "python.exe") : path.join(venv, "bin", "python");
}

function fileContentHash(filePath: string): string {
try {
return `sha256:${createHash("sha256").update(readFileSync(filePath)).digest("hex")}`;
Expand Down Expand Up @@ -725,7 +729,7 @@ async function bootstrapVenv(
): Promise<void> {
await mkdir(path.dirname(venv), { recursive: true });
const uv = await ensureUv(options);
const python = path.join(venv, "bin", "python");
const python = venvPython(venv);
const sourceDir = await resolveRuntimeSourceDir();
const runtimeRequirement = sourceDir ?? RUNTIME_REQUIREMENT;
const runtimeIdentity = await resolveRuntimeIdentity();
Expand Down Expand Up @@ -886,7 +890,7 @@ async function ensureKernelPythonUncached(
}

const venv = await resolveWritableKernelVenvDir();
const python = path.join(venv, "bin", "python");
const python = venvPython(venv);
const runtimeIdentity = await resolveRuntimeIdentity();
if (await kernelReady(python, venv, runtimeIdentity, pythonSkills)) return python;

Expand Down
3 changes: 2 additions & 1 deletion packages/coding-agent/test/ipython-bootstrap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { existsSync, mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync
import { homedir, tmpdir } from "node:os";
import { join } from "node:path";
import { afterAll, describe, expect, it } from "vitest";
import { venvPython } from "../src/core/kernel/bootstrap.js";
import { KernelManager } from "../src/core/kernel/index.js";
import { buildRlmBootstrapCode } from "../src/core/tools/ipython.js";

Expand Down Expand Up @@ -44,7 +45,7 @@ describe("IPython RLM bootstrap", () => {
function resolveKernelPython(): string | null {
const candidates = [
process.env.PRIME_AGENT_KERNEL_PYTHON,
join(homedir(), ".prime", "agent", "kernel-venv", "bin", "python"),
venvPython(join(homedir(), ".prime", "agent", "kernel-venv")),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reuse the platform-aware path in the recursion test

On Windows, test/agent-session-recursion.test.ts:2141 still falls back to kernel-venv/bin/python, so its spawnSync targets a nonexistent interpreter even though the managed environment now uses Scripts/python.exe. The repository-wide search for kernel-venv and bin.*python found this remaining executable-path construction; update it to use venvPython as these two changed tests do.

Useful? React with 👍 / 👎.

].filter((p): p is string => Boolean(p));
for (const python of candidates) {
if (!existsSync(python)) continue;
Expand Down
16 changes: 16 additions & 0 deletions packages/coding-agent/test/kernel-bootstrap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
getKernelVenvDir,
type KernelPythonSkill,
resolveRuntimeIdentity,
venvPython,
} from "../src/core/kernel/bootstrap.js";

let tempDir = "";
Expand Down Expand Up @@ -174,6 +175,21 @@ describe("kernel bootstrap", () => {
expect(getKernelVenvDir()).toBe(venv);
});

it("resolves the venv interpreter using the host platform layout", () => {

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 Run each modified test file to passing

The commit's Testing section reports only a filtered invocation of this new case and explicitly says the complete file still has 17 failures; it also does not report complete runs of the other two modified test files. The root AGENTS.md requires every modified test file to be run and iterated until it passes, so the full affected files need validation before this change is accepted.

AGENTS.md reference: AGENTS.md:L30-L31

Useful? React with 👍 / 👎.

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 Put the issue regression in the required suite directory

This is explicitly the regression for issue #660, but it is added to test/kernel-bootstrap.test.ts rather than test/suite/regressions/660-<slug>.test.ts. The root AGENTS.md requires issue-specific regressions in that directory and requires the suite harness with the faux provider, so move the regression to the prescribed location and structure.

AGENTS.md reference: AGENTS.md:L32-L33

Useful? React with 👍 / 👎.

const originalPlatform = process.platform;
const setPlatform = (value: NodeJS.Platform) =>
Object.defineProperty(process, "platform", { value, configurable: true });
try {
setPlatform("win32");
expect(venvPython("C:\\venv")).toBe(join("C:\\venv", "Scripts", "python.exe"));

setPlatform("linux");
expect(venvPython("/venv")).toBe(join("/venv", "bin", "python"));
} finally {
setPlatform(originalPlatform);
}
});

it("bootstraps a missing venv with uv, ipykernel, prime-agent-runtime, and default extra packages", async () => {
const logPath = installFakeUv();
const venv = join(tempDir, "kernel-venv");
Expand Down
3 changes: 2 additions & 1 deletion packages/coding-agent/test/kernel-state-roundtrip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { existsSync, mkdtempSync, rmSync } from "node:fs";
import { homedir, tmpdir } from "node:os";
import { join } from "node:path";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { venvPython } from "../src/core/kernel/bootstrap.js";
import { KernelManager } from "../src/core/kernel/index.js";

/** Find a python that can launch an ipykernel and has dill, or null to skip. */
function resolveKernelPython(): string | null {
const candidates = [
process.env.PRIME_AGENT_KERNEL_PYTHON,
join(homedir(), ".prime", "agent", "kernel-venv", "bin", "python"),
venvPython(join(homedir(), ".prime", "agent", "kernel-venv")),
].filter((p): p is string => Boolean(p));
for (const python of candidates) {
if (!existsSync(python)) continue;
Expand Down