Yeachan-Heo/oh-my-codex · error · Error
run session pointer changed
Error message
run session pointer changed
What it means
The session.json pointer inside the run's state dir no longer matches the session_id recorded in the detached active record, indicating the run's session identity changed under the cancellation caller.
Source
Thrown at src/cli/index.ts:8154
if (!record || file !== `${record.context_key}.json`) continue;
if (!record.session_id || normalizeSessionId(record.session_id) !== record.session_id) continue;
if (!hasMatchingMadmaxDetachedRuntimeBinding(record)) continue;
if (
canonicalizePathForRunDirMatch(record.source_cwd) !== canonicalCwd
&& (!record.worktree_cwd || canonicalizePathForRunDirMatch(record.worktree_cwd) !== canonicalCwd)
) continue;
try {
const canonicalRunDir = realpathSync(resolve(record.run_dir));
if (!isCanonicalPathWithin(canonicalRunsRoot, canonicalRunDir)) {
throw new Error("run directory escapes the authorized runs root");
}
const stateDir = realpathSync(join(canonicalRunDir, ".omx", "state"));
if (!isCanonicalPathWithin(canonicalRunDir, stateDir)) {
throw new Error("state directory escapes the authorized run directory");
}
const session = JSON.parse(await readFile(join(stateDir, "session.json"), "utf-8")) as Record<string, unknown>;
if (session.session_id !== record.session_id) throw new Error("run session pointer changed");
const sessionDir = realpathSync(join(stateDir, "sessions", record.session_id));
if (!isCanonicalPathWithin(stateDir, sessionDir)) {
throw new Error("session directory escapes the authorized state directory");
}
candidates.push({ sessionDir, sessionId: record.session_id, record });
} catch (err) {
throw new Error(`Refusing cancellation because detached run authority is invalid: ${record.run_dir}.`, { cause: err });
}
}
if (candidates.length > 1) throw new Error("Refusing cancellation because multiple detached run authorities match.");
if (candidates.length === 0) return null;
const [{ sessionDir, sessionId, record }] = candidates;
const refs: ModeStateFileRef[] = [];
const stateFiles = await readdir(sessionDir).catch(() => [] as string[]);
for (const file of stateFiles) {
if (!isModeStateFilename(file)) continue;
const path = join(sessionDir, file);View on GitHub (pinned to 3ad79a8a6f)
Solutions
- Delete the stale detached active record and retry cancellation against the current session
- Re-run with the CLI's discovery flow so records and session.json stay in sync
- Ensure one session per run dir; clean old active records after restarts
Defensive patterns
Strategy: validation
Validate before calling
const session = JSON.parse(await readFile(join(stateDir, 'session.json'), 'utf8'));
if (session.session_id !== record.session_id) throw new Error('record is stale — refresh records'); Prevention
- Prune active records after session restarts
- One session per run dir
- Re-discover sessions through the CLI, not manual record edits
When it happens
Trigger: session.json was rewritten by a newer run in the same run dir, or the active record references an old session_id after the session was restarted.
Common situations: Session restarted/upgraded in place, leftover active record from a previous session, or multiple sessions sharing one run dir.
AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27).
Data as JSON: /api/errors/edc0a2b16f06db48.
Report an issue: GitHub.