Yeachan-Heo/oh-my-codex · error

job_not_input_accepting:session_mismatch:${active.session_id

Error message

job_not_input_accepting:session_mismatch:${active.session_id}

What it means

Thrown by injectExecFollowup when the supplied session id does not match the currently usable session in that cwd. The active session's session_id and native_session_id both differ from the requested id, so the library refuses to inject into a session that is no longer the active one (unless allowInactiveSession is set). The message embeds the actual active session id for diagnosis.

Source

Thrown at src/exec/followup.ts:235

  options: InjectExecFollowupOptions,
): Promise<InjectExecFollowupResult> {
  const sessionId = normalizeSessionId(options.sessionId);
  const prompt = normalizePrompt(options.prompt);
  const actor = normalizeActor(options.actor);
  const nowIso = options.nowIso ?? new Date().toISOString();

  const active = await readUsableSessionState(options.cwd);
  const activeUsable = active && isSessionStateUsable(active, options.cwd);
  if (!activeUsable && !options.allowInactiveSession) {
    throw new Error("job_not_input_accepting:no_active_exec_session");
  }
  if (
    activeUsable
    && active.session_id !== sessionId
    && active.native_session_id !== sessionId
    && !options.allowInactiveSession
  ) {
    throw new Error(`job_not_input_accepting:session_mismatch:${active.session_id}`);
  }

  const canonicalSessionId = activeUsable && (active.session_id === sessionId || active.native_session_id === sessionId)
    ? active.session_id
    : sessionId;
  const queuePath = sessionQueuePath(options.cwd, canonicalSessionId);
  const queued: ExecFollowupRecord = {
    id: randomUUID(),
    session_id: canonicalSessionId,
    actor,
    prompt,
    created_at: nowIso,
  };
  await withQueueLock(queuePath, async () => {
    const queue = await readQueue(queuePath, canonicalSessionId, {
      cwd: options.cwd,
      nowIso,
      recoverCorrupt: true,

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Re-read the current session id from the active session state (or the error message, which contains active.session_id) and retry with that id.
  2. If injecting into a superseded session is intentional, pass allowInactiveSession: true.
  3. Make your orchestrator re-resolve the session id immediately before each injection rather than caching it.
  4. Guard against races by retrying once with the freshly resolved id on session_mismatch.

Example fix

// before
await injectExecFollowup(cwd, cachedSessionId, { prompt });

// after
const active = await readUsableSessionState(cwd);
if (!active) throw new Error('no active session');
await injectExecFollowup(cwd, active.session_id, { prompt });
Defensive patterns

Strategy: validation

Validate before calling

const active = await readUsableSessionState(cwd);
if (!active) throw new Error('no active session');
const id = (active.session_id === wanted || active.native_session_id === wanted) ? active.session_id : active.session_id;
await injectExecFollowup(cwd, id, { prompt });

Type guard

function sessionMatches(active: SessionState, id: string): boolean {
  return active.session_id === id || active.native_session_id === id;
}

Try / catch

try { await injectExecFollowup(cwd, sessionId, { prompt }); }
catch (e) {
  const m = e instanceof Error && e.message.match(/^job_not_input_accepting:session_mismatch:(.+)$/);
  if (m) return injectExecFollowup(cwd, m[1]!, { prompt }); // retry with active id
  throw e;
}

Prevention

When it happens

Trigger: Passing a stale session id from a previous exec session while a new one is active in the same cwd; hardcoding or caching a session id that has since been rotated; copy-pasting an id from another checkout; racing with a session restart between reading the id and injecting.

Common situations: Scripts cache the session id from an earlier run and reuse it after the session was restarted; orchestrator reads the id at job start but the session rotates mid-job; multiple sessions historically ran in the directory and an old id is used.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/2e2cc964d25033b5. Report an issue: GitHub.