{"record":{"id":"fbce36c17c6254e0","repo":"can1357/oh-my-pi","slug":"fork-requires-session-persistence","errorCode":null,"errorMessage":"--fork requires session persistence","messagePattern":"--fork requires session persistence","errorType":"exception","errorClass":"SessionResolutionError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/main.ts","lineNumber":942,"sourceCode":"\tif (!message || !SESSION_ID_ARG_RE.test(message)) return;\n\n\tconst messageIndex = parsed.messages.indexOf(message);\n\tif (messageIndex === -1) return;\n\tparsed.resume = message;\n\tparsed.continue = false;\n\tparsed.messages.splice(messageIndex, 1);\n}\n\n/** Resolves CLI session flags into an existing, forked, in-memory, or cancelled session manager. */\nexport async function createSessionManager(\n\tparsed: Args,\n\tcwd: string,\n\tactiveSettings: Settings = settings,\n\taskToMoveSession: SessionPrompt = promptMoveSession,\n): Promise<SessionManager | undefined> {\n\tif (parsed.fork) {\n\t\tif (parsed.noSession) {\n\t\t\tthrow new SessionResolutionError(\"--fork requires session persistence\");\n\t\t}\n\t\tconst forkSource = parsed.fork;\n\t\tif (forkSource.includes(\"/\") || forkSource.includes(\"\\\\\") || forkSource.endsWith(\".jsonl\")) {\n\t\t\treturn await SessionManager.forkFrom(forkSource, cwd, parsed.sessionDir);\n\t\t}\n\t\tconst match = await resolveResumableSession(forkSource, cwd, parsed.sessionDir);\n\t\tif (!match) {\n\t\t\tthrow new SessionResolutionError(\n\t\t\t\t`Session \"${forkSource}\" not found.`,\n\t\t\t\t\"Run `omp --resume` without an argument to pick from recent sessions, or `omp` to start a new one.\",\n\t\t\t);\n\t\t}\n\t\treturn await SessionManager.forkFrom(match.session.path, cwd, parsed.sessionDir);\n\t}\n\n\tif (parsed.noSession) {\n\t\treturn SessionManager.inMemory();\n\t}","sourceCodeStart":924,"sourceCodeEnd":960,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/main.ts#L924-L960","documentation":"--fork creates a new session branching from an existing one, which inherently requires session persistence. Passing --no-session with --fork throws this SessionResolutionError before any fork lookup occurs.","triggerScenarios":"Running `omp --fork <session> --no-session` — parsed.fork set and parsed.noSession set.","commonSituations":"Scripts that blanket-append --no-session; users believing a fork is a read-only copy that needs no storage.","solutions":["Remove --no-session; a fork must write a new session file.","If you want to inspect an old session without forking, open the .jsonl directly instead of using --fork."],"exampleFix":"// before\nomp --fork abc123 --no-session\n// after\nomp --fork abc123","handlingStrategy":"validation","validationCode":"if (process.argv.includes(\"--fork\") && process.argv.includes(\"--no-session\"))\n  throw new Error(\"Forking writes a new session; --no-session is incompatible\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never combine --fork with --no-session in wrapper scripts.","If you only need to read an old session, inspect the .jsonl file instead of forking.","Document fork as a persistence-requiring operation."],"tags":["cli","flag-conflict","session-persistence"],"backgroundTag":"flag-requires-session-persistence","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}