can1357/oh-my-pi · error · Error
Cleanse session could not be persisted
Error message
Cleanse session could not be persisted
What it means
After creating the cleanse SessionManager and naming the session, the runtime calls ensureOnDisk() and then getSessionFile(). If the manager still returns no file path, the session was not actually persisted and the runtime throws rather than running an unpersisted session.
Source
Thrown at packages/coding-agent/src/cleanse/agent.ts:98
const [settings, authStorage] = await Promise.all([Settings.init({ cwd }), discoverAuthStorage()]);
const modelRegistry = new ModelRegistry(authStorage);
await modelRegistry.refresh();
const resolved = resolveCliModel({ cliModel: options.model, modelRegistry, settings });
if (resolved.error || !resolved.model) {
throw new Error(resolved.error ?? `Model "${options.model}" not found`);
}
const modelSelector = resolved.selector ?? formatModelString(resolved.model);
const modelDisplay = formatModelString(resolved.model);
const sessionManager = SessionManager.create(cwd);
await sessionManager.setSessionName("Cleanse", "auto");
sessionManager.appendCustomEntry("cleanse", {
status: "running",
model: modelDisplay,
selector: options.model,
});
await sessionManager.ensureOnDisk();
const sessionFile = sessionManager.getSessionFile();
if (!sessionFile) throw new Error("Cleanse session could not be persisted");
const eventBus = new EventBus();
const toolSession: ToolSession = {
cwd,
hasUI: false,
suppressSpawnAdvisory: true,
enableLsp: true,
enableIrc: true,
enableMCP: false,
eventBus,
getSessionFile: () => sessionFile,
getSessionId: () => sessionManager.getSessionId(),
getArtifactsDir: () => sessionManager.getArtifactsDir(),
getArtifactManager: () => sessionManager.getArtifactManager(),
getAgentId: () => MAIN_AGENT_ID,
getSessionSpawns: () => "sonic,task",
getModelString: () => modelSelector,
getActiveModelString: () => modelSelector,
getActiveModel: () => resolved.model,View on GitHub (pinned to 9690622007)
Solutions
- Check disk space and write permissions for the session storage directory (~/.omp or project-local session dir)
- Inspect logs (~/.omp/logs) for the underlying ensureOnDisk failure
- Run the CLI with correct HOME/user so the session directory resolves and is writable
- Retry after fixing the environment; if reproducible, report with the storage path
Defensive patterns
Strategy: validation
Validate before calling
const sessionFile = sessionManager.getSessionFile();
if (!sessionFile) {
await sessionManager.ensureOnDisk();
if (!sessionManager.getSessionFile()) throw new Error("session storage not writable");
} Try / catch
try {
await sessionManager.ensureOnDisk();
const file = sessionManager.getSessionFile();
if (!file) throw new Error("Cleanse session could not be persisted");
} catch (err) {
logger.error("session persistence failed", { err });
throw new Error(`cleanse needs writable session storage: ${err instanceof Error ? err.message : err}`);
} Prevention
- Ensure ~/.omp (or the session dir) exists and is writable before launching
- Monitor disk space in CI/container environments
- Don't run the CLI with a read-only HOME; set a writable HOME/XDG dir
- Check logs for earlier ensureOnDisk warnings
When it happens
Trigger: sessionManager.ensureOnDisk() failing silently or getSessionFile() returning null/undefined — e.g. the session storage directory is not writable, disk full, or the session was never properly initialized on disk.
Common situations: Read-only project directory or HOME; permission errors in the sessions/storage path; full disk; sandboxed environment blocking writes to the session directory.
Related errors
- Session file not found: ${resolved}
- No artifacts directory found: {artifacts_dir}
- No artifacts directory found
- Failed to persist ${sourceName} session
- Failed to delete session: ${error instanceof Error ? error.m
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/0d2cee4424e57543.
Report an issue: GitHub.