{"record":{"id":"3645c145e095041b","repo":"nikivdev/code","slug":"failed-to-resume-codex-session","errorCode":null,"errorMessage":"failed to resume codex session {}","messagePattern":"failed to resume codex session (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ai.rs","lineNumber":11749,"sourceCode":"                .session_id\n                .as_deref()\n                .ok_or_else(|| anyhow::anyhow!(\"missing session id for resume plan\"))?;\n            println!(\n                \"Opening Codex session {} in {}...\",\n                truncate_recover_id(session_id),\n                launch_path.display()\n            );\n            if launch_session_for_target(\n                session_id,\n                Provider::Codex,\n                plan.prompt.as_deref(),\n                Some(&launch_path),\n                plan.runtime_state_path.as_deref(),\n                plan.trace.as_ref(),\n            )? {\n                Ok(())\n            } else {\n                bail!(\"failed to resume codex session {}\", session_id);\n            }\n        }\n        \"new\" | \"recover-new\" => {\n            maybe_open_cursor_for_pr_feedback_check(plan);\n            new_session_for_target(\n                Provider::Codex,\n                plan.prompt.as_deref(),\n                Some(&launch_path),\n                plan.runtime_state_path.as_deref(),\n                plan.trace.as_ref(),\n            )\n        }\n        other => bail!(\"unsupported codex open action: {}\", other),\n    }\n}\n\nfn maybe_open_cursor_for_pr_feedback_check(plan: &CodexOpenPlan) {\n    let Some(query) = plan","sourceCodeStart":11731,"sourceCodeEnd":11767,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ai.rs#L11731-L11767","documentation":"After computing a resume plan, the tool attempts to resume the existing codex session via the resume bridge. If the bridge reports that no session was actually resumed/launched, it bails with the failing session ID. It signals the stored session could not be attached to.","triggerScenarios":"`f codex open <session>` with action resume/recover where `run_codex_resume...` returns false — e.g. the runtime state or rollout file for that session ID is missing, corrupted, or the underlying process could not be launched.","commonSituations":"Resuming a session from an old machine after upgrading codex (rollout format/path changed); deleted `~/.codex/sessions` history; passing an ID copied from logs that was never persisted.","solutions":["Verify the session ID exists in the codex session/runtime state listing","Start a fresh session (`new` action) if the old rollout is gone","Check codex CLI version compatibility and re-login/repair the runtime"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// confirm the session/runtime state exists before resuming\nlet states = codex_runtime::load_runtime_states()?;\nif !states.iter().any(|s| s.session_id == session_id) {\n    eprintln!(\"{} has no runtime state; use new session\", session_id);\n}","typeGuard":"fn resumable(states: &[RuntimeState], id: &str) -> bool {\n    states.iter().any(|s| s.session_id == id)\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().starts_with(\"failed to resume codex session\") => new_session_for_target(Provider::Codex, ...),\n    other => other,\n}","preventionTips":["Don't prune ~/.codex session/rollout files while sessions are active","Keep codex CLI version consistent between machines","Treat resume failure as a signal to start a new session"],"tags":["codex","session","resume-failed"],"backgroundTag":"session-resume-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}