feat: empty-container spawn (scratch workspace, no repo volume); fix bridge session isolation — explicit SessionManager per spawn stops SDK resuming the repo's old session (which also overrode LVMH_MODEL)

This commit is contained in:
Raphael Westphal
2026-08-20 15:12:45 +02:00
parent bdfa61a8b2
commit f5ee3a0f2d
7 changed files with 134 additions and 46 deletions
+9 -1
View File
@@ -7,6 +7,7 @@ import { existsSync } from "node:fs";
import {
createAgentSession,
ModelRuntime,
SessionManager,
} from "/usr/local/lib/node_modules/@earendil-works/pi-coding-agent/dist/index.js";
const SETUP_PATH = "/workspace/.lvmh/setup.sh";
@@ -85,8 +86,15 @@ try {
console.error(`[lvmh-bridge] model resolution failed:`, err);
}
}
// Fresh session per spawn: without an explicit sessionManager the SDK
// picks up an existing session file for the cwd — sharing one transcript
// (and its saved model) across every spawn of the repo. A dedicated dir
// per daemon session id keeps spawns isolated and LVMH_MODEL authoritative.
const sessionRoot = process.env.PI_SESSION_DIR ?? "/pi-sessions";
const sessionDir = `${sessionRoot}/${process.env.LVMH_SESSION_ID ?? "default"}`;
const sessionManager = SessionManager.create(process.cwd(), sessionDir);
const { session } = await createAgentSession(
model === undefined ? {} : { model },
model === undefined ? { sessionManager } : { model, sessionManager },
);
// SDK does not bind extensions implicitly (unlike TUI/RPC modes); without
// bindExtensions the session_start event never fires, so the lvmh plugin