can1357/oh-my-pi · error · SessionResolutionError

--from-${foreignSource} is not supported in ${mode} mode

Error message

--from-${foreignSource} is not supported in ${mode} mode

What it means

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.

Source

Thrown at packages/coding-agent/src/main.ts:1618

			parsedArgs,
			modelRegistry,
			settingsInstance,
		);

		// Resolve an explicit `--continue <id>` before extension flags are loaded.
		// Reading the token immediately after `--continue` distinguishes the session
		// id from UUID-shaped values owned by later extension flags.
		normalizeContinueSessionArgs(parsedArgs, rawArgs);

		// Resolve native resume/fork flags or import one foreign transcript into a
		// fresh persisted OMP session before constructing the AgentSession.
		let sessionManager: SessionManager | undefined;
		let foreignSource: ForeignSessionSource | undefined;
		try {
			foreignSource = resolveForeignSessionSource(parsedArgs);
			if (foreignSource) {
				if (isProtocolMode) {
					throw new SessionResolutionError(`--from-${foreignSource} is not supported in ${mode} mode`);
				}
				const sourceName = foreignSessionSourceName(foreignSource);
				const store = (deps.createForeignSessionStore ?? createForeignSessionStore)(foreignSource);
				let foreignSessions: ForeignSessionInfo[];
				try {
					foreignSessions = await logger.time(`list${sourceName}Sessions`, () => store.list());
				} catch (error) {
					const message = error instanceof Error ? error.message : String(error);
					throw new SessionResolutionError(`Failed to list ${sourceName} sessions: ${message}`);
				}
				if (foreignSessions.length === 0) {
					writeStartupNotice(parsedArgs, `${chalk.dim(`No ${sourceName} sessions found`)}\n`);
					stopStartupWatchdog();
					process.exit(0);
				}
				const choices = foreignSessions.map(foreignSessionInfoToSessionInfo);
				pauseStartupWatchdog();
				let selected: SessionInfo | null;

View on GitHub (pinned to 9690622007)

Solutions

  1. Remove the `--from-<source>` flag when launching in protocol mode.
  2. Import the session in an interactive run first, then continue programmatically via the resulting session.
  3. Split wrapper scripts so automation invocations don't inherit interactive-only flags.

Example fix

// before (protocol mode)
omp --rpc --from-claude

// after
omp --from-claude   # interactive mode
Defensive patterns

Strategy: validation

Validate before calling

const isProtocolMode = process.argv.includes("--rpc") /* or your mode detection */;
const usesForeignSource = process.argv.some(a => a.startsWith("--from-"));
if (isProtocolMode && usesForeignSource) throw new Error("--from-* flags are interactive-only; drop them in protocol mode");

Try / catch

try {
  await startProtocolServer(argv);
} catch (err) {
  if (err instanceof SessionResolutionError && err.message.includes("is not supported in")) {
    console.error("Remove --from-* flags when running in protocol mode.");
  } else throw err;
}

Prevention

When it happens

Trigger: Running the CLI in protocol/RPC/SDK mode while passing `--from-claude`/`--from-codex` (or another `--from-*` source flag).

Common situations: Programmatic embedding (RPC server, SDK harness) inheriting extra argv from a shell wrapper; scripts that reuse an interactive alias in automation.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/fb388b2a8e8e4372. Report an issue: GitHub.