A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
fix(coding-agent): preserve the recorded skill map in no-skill bootstrap calls (#2409)
Seth Karten1df880d81934
diff --git a/packages/coding-agent/.changes/preserve-no-skill-marker.md b/packages/coding-agent/.changes/preserve-no-skill-marker.mdnew file mode 100644index 0000000000..eecb1c5285--- /dev/null+++ b/packages/coding-agent/.changes/preserve-no-skill-marker.md@@ -0,0 +1 @@+- Fixed no-skill kernel bootstrap calls (postinstall, runtime-bootstrap) wiping the recorded Python skill map from the .bootstrap-version marker, which forced the next real session to re-sync every skill: a no-skill call now leaves the recorded skill set untouched and only skill-syncing callers rewrite the marker.diff --git a/packages/coding-agent/src/core/kernel/bootstrap.ts b/packages/coding-agent/src/core/kernel/bootstrap.tsindex 98d44ef69f..28f052c698 100644--- a/packages/coding-agent/src/core/kernel/bootstrap.ts+++ b/packages/coding-agent/src/core/kernel/bootstrap.ts@@ -928,11 +928,19 @@ async function ensureKernelPythonUncached(const venv = await resolveWritableKernelVenvDir();const python = kernelVenvPython(venv);const runtimeIdentity = await resolveRuntimeIdentity();- if (await kernelReady(python, venv, runtimeIdentity, pythonSkills)) return python;+ // No-skill callers (postinstall, runtime-bootstrap, bootstrap-cli) never sync skills;+ // letting them reach syncPythonSkills would rewrite the marker with an empty list,+ // wiping the recorded skills and forcing the next real session to re-sync every+ // skill. They only need the base kernel to be ready.+ const readyForCaller = async (): Promise<boolean> =>+ pythonSkills.length === 0+ ? kernelBaseReady(python, venv, runtimeIdentity)+ : kernelReady(python, venv, runtimeIdentity, pythonSkills);+ if (await readyForCaller()) return python;const releaseLock = await acquireBootstrapLock(venv);try {- if (await kernelReady(python, venv, runtimeIdentity, pythonSkills)) return python;+ if (await readyForCaller()) return python;if (await kernelBaseReady(python, venv, runtimeIdentity)) {await syncPythonSkills(await ensureUv(options), venv, python, runtimeIdentity, pythonSkills, options);return python;diff --git a/packages/coding-agent/test/kernel-bootstrap.test.ts b/packages/coding-agent/test/kernel-bootstrap.test.tsindex be460add56..9b81e7a83d 100644--- a/packages/coding-agent/test/kernel-bootstrap.test.ts+++ b/packages/coding-agent/test/kernel-bootstrap.test.ts@@ -261,6 +261,44 @@ dependencies = ["httpx"]expect(version.pythonSkills[0].pyprojectHash).toBe(pyprojectHash(pythonSkill.pyprojectPath));});+ it("preserves recorded Python skills when a no-skill bootstrap call reuses a warm venv", async () => {+ installFakeUv();+ const venv = join(tempDir, "kernel-venv");+ const python = join(venv, "bin", "python");+ const pythonSkill = createPythonSkill();+ mkdirSync(join(venv, "bin"), { recursive: true });+ writeFakePython(python, ["rlm", ...DEFAULT_RLM_EXTRA_IMPORT_NAMES]);+ writeBootstrapVersion(venv, [pythonSkill]);+ process.env.PRIME_AGENT_KERNEL_VENV = venv;++ await expect(ensureKernelPython()).resolves.toBe(python);++ const version = JSON.parse(readFileSync(join(venv, ".bootstrap-version"), "utf8"));+ expect(version.pythonSkills).toEqual([+ {+ importName: pythonSkill.importName,+ packagePath: pythonSkill.packagePath,+ pyprojectPath: pythonSkill.pyprojectPath,+ pyprojectHash: pyprojectHash(pythonSkill.pyprojectPath),+ },+ ]);+ });++ it("keeps a skill-synced venv fast for real sessions after a no-skill bootstrap call", async () => {+ const logPath = installFakeUv();+ const venv = join(tempDir, "kernel-venv");+ const pythonSkill = createPythonSkill();+ process.env.PRIME_AGENT_KERNEL_VENV = venv;++ await expect(ensureKernelPython({ pythonSkills: [pythonSkill] })).resolves.toBe(join(venv, "bin", "python"));+ const syncedLog = readFileSync(logPath, "utf8");++ await expect(ensureKernelPython()).resolves.toBe(join(venv, "bin", "python"));+ await expect(ensureKernelPython({ pythonSkills: [pythonSkill] })).resolves.toBe(join(venv, "bin", "python"));++ expect(readFileSync(logPath, "utf8")).toBe(syncedLog);+ });+it("continues when a Python skill editable install fails and retries it next startup", async () => {const logPath = installFakeUv();const venv = join(tempDir, "kernel-venv");