{"record":{"id":"0d2cee4424e57543","repo":"can1357/oh-my-pi","slug":"cleanse-session-could-not-be-persisted","errorCode":null,"errorMessage":"Cleanse session could not be persisted","messagePattern":"Cleanse session could not be persisted","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cleanse/agent.ts","lineNumber":98,"sourceCode":"\tconst [settings, authStorage] = await Promise.all([Settings.init({ cwd }), discoverAuthStorage()]);\n\tconst modelRegistry = new ModelRegistry(authStorage);\n\tawait modelRegistry.refresh();\n\tconst resolved = resolveCliModel({ cliModel: options.model, modelRegistry, settings });\n\tif (resolved.error || !resolved.model) {\n\t\tthrow new Error(resolved.error ?? `Model \"${options.model}\" not found`);\n\t}\n\tconst modelSelector = resolved.selector ?? formatModelString(resolved.model);\n\tconst modelDisplay = formatModelString(resolved.model);\n\tconst sessionManager = SessionManager.create(cwd);\n\tawait sessionManager.setSessionName(\"Cleanse\", \"auto\");\n\tsessionManager.appendCustomEntry(\"cleanse\", {\n\t\tstatus: \"running\",\n\t\tmodel: modelDisplay,\n\t\tselector: options.model,\n\t});\n\tawait sessionManager.ensureOnDisk();\n\tconst sessionFile = sessionManager.getSessionFile();\n\tif (!sessionFile) throw new Error(\"Cleanse session could not be persisted\");\n\tconst eventBus = new EventBus();\n\tconst toolSession: ToolSession = {\n\t\tcwd,\n\t\thasUI: false,\n\t\tsuppressSpawnAdvisory: true,\n\t\tenableLsp: true,\n\t\tenableIrc: true,\n\t\tenableMCP: false,\n\t\teventBus,\n\t\tgetSessionFile: () => sessionFile,\n\t\tgetSessionId: () => sessionManager.getSessionId(),\n\t\tgetArtifactsDir: () => sessionManager.getArtifactsDir(),\n\t\tgetArtifactManager: () => sessionManager.getArtifactManager(),\n\t\tgetAgentId: () => MAIN_AGENT_ID,\n\t\tgetSessionSpawns: () => \"sonic,task\",\n\t\tgetModelString: () => modelSelector,\n\t\tgetActiveModelString: () => modelSelector,\n\t\tgetActiveModel: () => resolved.model,","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cleanse/agent.ts#L80-L116","documentation":"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.","triggerScenarios":"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.","commonSituations":"Read-only project directory or HOME; permission errors in the sessions/storage path; full disk; sandboxed environment blocking writes to the session directory.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const sessionFile = sessionManager.getSessionFile();\nif (!sessionFile) {\n  await sessionManager.ensureOnDisk();\n  if (!sessionManager.getSessionFile()) throw new Error(\"session storage not writable\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  await sessionManager.ensureOnDisk();\n  const file = sessionManager.getSessionFile();\n  if (!file) throw new Error(\"Cleanse session could not be persisted\");\n} catch (err) {\n  logger.error(\"session persistence failed\", { err });\n  throw new Error(`cleanse needs writable session storage: ${err instanceof Error ? err.message : err}`);\n}","preventionTips":["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"],"tags":["persistence","session","filesystem"],"backgroundTag":"session-persist-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}