{"record":{"id":"fb388b2a8e8e4372","repo":"can1357/oh-my-pi","slug":"from-foreignsource-is-not-supported-in-mode","errorCode":null,"errorMessage":"--from-${foreignSource} is not supported in ${mode} mode","messagePattern":"--from-(.+?) is not supported in (.+?) mode","errorType":"exception","errorClass":"SessionResolutionError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/main.ts","lineNumber":1618,"sourceCode":"\t\t\tparsedArgs,\n\t\t\tmodelRegistry,\n\t\t\tsettingsInstance,\n\t\t);\n\n\t\t// Resolve an explicit `--continue <id>` before extension flags are loaded.\n\t\t// Reading the token immediately after `--continue` distinguishes the session\n\t\t// id from UUID-shaped values owned by later extension flags.\n\t\tnormalizeContinueSessionArgs(parsedArgs, rawArgs);\n\n\t\t// Resolve native resume/fork flags or import one foreign transcript into a\n\t\t// fresh persisted OMP session before constructing the AgentSession.\n\t\tlet sessionManager: SessionManager | undefined;\n\t\tlet foreignSource: ForeignSessionSource | undefined;\n\t\ttry {\n\t\t\tforeignSource = resolveForeignSessionSource(parsedArgs);\n\t\t\tif (foreignSource) {\n\t\t\t\tif (isProtocolMode) {\n\t\t\t\t\tthrow new SessionResolutionError(`--from-${foreignSource} is not supported in ${mode} mode`);\n\t\t\t\t}\n\t\t\t\tconst sourceName = foreignSessionSourceName(foreignSource);\n\t\t\t\tconst store = (deps.createForeignSessionStore ?? createForeignSessionStore)(foreignSource);\n\t\t\t\tlet foreignSessions: ForeignSessionInfo[];\n\t\t\t\ttry {\n\t\t\t\t\tforeignSessions = await logger.time(`list${sourceName}Sessions`, () => store.list());\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tthrow new SessionResolutionError(`Failed to list ${sourceName} sessions: ${message}`);\n\t\t\t\t}\n\t\t\t\tif (foreignSessions.length === 0) {\n\t\t\t\t\twriteStartupNotice(parsedArgs, `${chalk.dim(`No ${sourceName} sessions found`)}\\n`);\n\t\t\t\t\tstopStartupWatchdog();\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t}\n\t\t\t\tconst choices = foreignSessions.map(foreignSessionInfoToSessionInfo);\n\t\t\t\tpauseStartupWatchdog();\n\t\t\t\tlet selected: SessionInfo | null;","sourceCodeStart":1600,"sourceCodeEnd":1636,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/main.ts#L1600-L1636","documentation":"Foreign-session import flags (`--from-claude`, `--from-codex`, etc.) are only supported in interactive mode. main.ts detects `resolveForeignSessionSource(parsedArgs)` and throws a `SessionResolutionError` when the current run is a protocol mode (e.g. RPC/SDK mode), because importing a foreign session there is unsupported. Use the flag in a normal interactive launch.","triggerScenarios":"Running the CLI in protocol/RPC/SDK mode while passing `--from-claude`/`--from-codex` (or another `--from-*` source flag).","commonSituations":"Programmatic embedding (RPC server, SDK harness) inheriting extra argv from a shell wrapper; scripts that reuse an interactive alias in automation.","solutions":["Remove the `--from-<source>` flag when launching in protocol mode.","Import the session in an interactive run first, then continue programmatically via the resulting session.","Split wrapper scripts so automation invocations don't inherit interactive-only flags."],"exampleFix":"// before (protocol mode)\nomp --rpc --from-claude\n\n// after\nomp --from-claude   # interactive mode","handlingStrategy":"validation","validationCode":"const isProtocolMode = process.argv.includes(\"--rpc\") /* or your mode detection */;\nconst usesForeignSource = process.argv.some(a => a.startsWith(\"--from-\"));\nif (isProtocolMode && usesForeignSource) throw new Error(\"--from-* flags are interactive-only; drop them in protocol mode\");","typeGuard":null,"tryCatchPattern":"try {\n  await startProtocolServer(argv);\n} catch (err) {\n  if (err instanceof SessionResolutionError && err.message.includes(\"is not supported in\")) {\n    console.error(\"Remove --from-* flags when running in protocol mode.\");\n  } else throw err;\n}","preventionTips":["Keep automation/RPC launch scripts free of interactive-only flags.","Document mode-specific flags in wrapper scripts."],"tags":["cli","session-import","mode-restriction"],"backgroundTag":"flag-unsupported-in-mode","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}