can1357/oh-my-pi · error · Error
Cannot load ${info.source} session with CodexSessionStore
Error message
Cannot load ${info.source} session with CodexSessionStore What it means
CodexSessionStore.load() only accepts foreign session infos whose source is 'codex'. Passing an info discovered by another store (claude, gemini, etc.) throws immediately. Each foreign-session store is source-specific by design.
Source
Thrown at packages/coding-agent/src/session/codex-session-store.ts:544
sessions.push({
source: "codex",
id,
path: filePath,
cwd,
title: indexed?.thread_name,
created,
modified,
});
}
sessions.sort(
(left, right) => right.modified.getTime() - left.modified.getTime() || left.id.localeCompare(right.id),
);
return sessions;
}
/** Converts one Codex rollout into a non-persistent OMP session. */
async load(info: ForeignSessionInfo): Promise<SessionManager> {
if (info.source !== "codex") throw new Error(`Cannot load ${info.source} session with CodexSessionStore`);
let records: Record<string, unknown>[];
try {
records = await readJsonLines(info.path);
} catch (error) {
throw new Error(`Unable to read Codex session ${info.id} at ${info.path}`, { cause: error });
}
if (records.length === 0) throw new Error(`Codex session ${info.id} at ${info.path} is empty or malformed`);
const metadata = records.find(record => record.type === "session_meta" && isRecord(record.payload));
const cwd =
metadata && isRecord(metadata.payload) ? (stringField(metadata.payload, "cwd") ?? info.cwd) : info.cwd;
const manager = SessionManager.inMemory(cwd);
const canonical = canonicalTexts(records);
const converted: ConvertedRecord[] = [];
const toolNames = new Map<string, string>();
let model = "codex";
let fallbackTimestamp = info.created.getTime();
let title = info.title;View on GitHub (pinned to 9690622007)
Solutions
- Route each ForeignSessionInfo to the store matching its source (info.source === 'codex' → CodexSessionStore)
- Check info.source before calling load, or use a dispatch map from source to store
- Fix the code that produced the info with the wrong source value
Example fix
// before const manager = await codexStore.load(anyInfo); // after const store = anyInfo.source === 'codex' ? codexStore : claudeStore; const manager = await store.load(anyInfo);
Defensive patterns
Strategy: type-guard
Validate before calling
function canLoadWithCodex(info: ForeignSessionInfo): boolean {
return info.source === 'codex';
} Type guard
function isCodexSessionInfo(info: ForeignSessionInfo): info is ForeignSessionInfo & { source: 'codex' } {
return info.source === 'codex';
} Try / catch
try {
const manager = await codexStore.load(info);
} catch (err) {
if (err instanceof Error && err.message.startsWith('Cannot load')) {
throw new Error(`route ${info.source} sessions to their own store, not CodexSessionStore`);
}
throw err;
} Prevention
- Build a source→store dispatch map instead of hardcoding one store in generic code
- Brand per-source session info types so mismatches fail at compile time
- Unit-test session routing to assert each source reaches its matching store
When it happens
Trigger: Calling `codexSessionStore.load(info)` where info.source is anything other than "codex" — typically because the info object came from listing a different provider's sessions or from a hand-constructed ForeignSessionInfo with the wrong source value.
Common situations: Generic session-picker code iterating a mixed list of foreign sessions and routing all of them to one store; refactor that swapped ClaudeSessionStore for CodexSessionStore; manual info construction with source left at its default.
Related errors
- Unable to read Codex session ${info.id} at ${info.path}
- Codex session ${info.id} at ${info.path} is empty or malform
- No messages to continue from
- Cannot continue from message role: assistant
- Gemini Files API cannot delete a handle from another provide
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/c082b4d20fff402e.
Report an issue: GitHub.