fix(coding-agent): scoped python kernel cleanup to sessions

scoped retained-kernel ownership to agent sessions and cleaned it up on session disposal

cleaned up warmed python owners on session startup failure and rejected new direct and tool-based python starts during disposal, including async hook, preflight, and warmup races
This commit is contained in:
Carl
2026-04-12 13:29:17 +02:00
parent f96422d911
commit 379064a0c9
18 changed files with 3593 additions and 1156 deletions
@@ -11,6 +11,7 @@ import {
import {
type KernelExecuteOptions,
type KernelExecuteResult,
type KernelShutdownResult,
type PreludeHelper,
PythonKernel,
} from "@oh-my-pi/pi-coding-agent/ipy/kernel";
@@ -175,7 +176,7 @@ describe("warmPythonEnvironment", () => {
introspectPrelude: vi.fn().mockResolvedValue(docs),
ping: vi.fn().mockResolvedValue(true),
isAlive: () => true,
shutdown: vi.fn().mockResolvedValue(undefined),
shutdown: vi.fn(async (): Promise<KernelShutdownResult> => ({ confirmed: true })),
};
const startSpy = vi.spyOn(PythonKernel, "start").mockResolvedValue(kernel as unknown as PythonKernel);