{"record":{"id":"b04063f591787603","repo":"Yeachan-Heo/oh-my-codex","slug":"tmux-instance-mismatch","errorCode":"tmux_instance_mismatch","errorMessage":"tmux_instance_mismatch:${tmuxSessionName}:${instanceId || \"missing\"}","messagePattern":"tmux_instance_mismatch:(.+?):(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mcp/hermes-bridge.ts","lineNumber":215,"sourceCode":"  sessionId: string,\n  prompt: string,\n  deps: HermesBridgeDeps,\n): Promise<HermesTmuxPromptResult | null> {\n  const rawSession = await readSessionState(cwd);\n  if (!rawSession || !sessionMatchesRequested(rawSession, sessionId)) return null;\n  const tmuxSessionName = optionalString(rawSession.tmux_session_name);\n  const tmuxPaneId = optionalString(rawSession.tmux_pane_id);\n  if (!tmuxSessionName || !tmuxPaneId) return null;\n  if (!isTmuxPaneId(tmuxPaneId)) {\n    throw new Error(`unsupported_session_kind:invalid_tmux_pane_binding:${tmuxSessionName}`);\n  }\n\n  const execTmux = deps.execTmuxFileSync ?? defaultExecTmuxFileSync;\n  try {\n    execTmux([\"has-session\", \"-t\", tmuxSessionName]);\n    const instanceId = String(execTmux([\"show-options\", \"-qv\", \"-t\", tmuxSessionName, OMX_INSTANCE_OPTION]) ?? \"\").trim();\n    if (instanceId !== rawSession.session_id) {\n      throw new Error(`tmux_instance_mismatch:${tmuxSessionName}:${instanceId || \"missing\"}`);\n    }\n    const paneSession = String(execTmux([\"display-message\", \"-p\", \"-t\", tmuxPaneId, \"#{session_name}\"]) ?? \"\").trim();\n    if (paneSession !== tmuxSessionName) {\n      throw new Error(`pane_session_mismatch:${tmuxPaneId}:${paneSession || \"missing\"}`);\n    }\n    for (const argv of buildSendPaneArgvs(tmuxPaneId, prompt, true)) {\n      execTmux(argv);\n    }\n  } catch (error) {\n    const message = errorMessage(error);\n    const reason = message.startsWith(\"tmux_instance_mismatch\") || message.startsWith(\"pane_session_mismatch\")\n      ? message\n      : \"tmux_send_failed\";\n    throw new Error(`unsupported_session_kind:tmux_prompt_delivery_failed:${tmuxSessionName}:${tmuxPaneId}:${reason}`);\n  }\n  return {\n    session_id: rawSession.session_id,\n    tmux_session_name: tmuxSessionName,","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/mcp/hermes-bridge.ts#L197-L233","documentation":"Before sending a prompt to a bound tmux session, the bridge verifies the tmux session's OMX instance option matches the recorded session_id, ensuring prompts go to the right agent instance. A mismatch (or missing option) throws with the session name and detected instance id.","triggerScenarios":"execTmux show-options -qv on the bound tmux session returns an instance id different from rawSession.session_id, or returns nothing ('missing') because the option was never set.","commonSituations":"The tmux session was reused/recreated by a newer instance, the option was cleared, or two agent instances share a tmux session name.","solutions":["Restart the target session so the tmux option is set correctly","Kill the stale tmux session if it belongs to a dead instance","Avoid reusing tmux session names across instances"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"const inst = execSync(`tmux show-options -qv -t ${sessionName} ${OMX_INSTANCE_OPTION}`).toString().trim();\nif (inst !== state.session_id) { /* rebind or restart before calling */ }","typeGuard":null,"tryCatchPattern":"catch (e) { if ((e as Error).message.startsWith('tmux_instance_mismatch')) { /* restart target session, then retry send */ } }","preventionTips":["Never reuse tmux session names across agent instances","Kill dead instances' tmux sessions","Verify the instance option before sending prompts"],"tags":["mcp","hermes-bridge","tmux","instance-mismatch"],"backgroundTag":"tmux-instance-mismatch","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}