{"record":{"id":"98c74d41073d3b71","repo":"nikivdev/code","slug":"failed-to-resume-session","errorCode":null,"errorMessage":"failed to resume {} session {}","messagePattern":"failed to resume (.+?) session (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ai.rs","lineNumber":14982,"sourceCode":"        }\n        if !has_tty {\n            bail!(\n                \"failed to resume claude session {} (non-interactive shell; fallback continue unavailable)\",\n                session_id\n            );\n        }\n        eprintln!(\"Falling back to `claude --continue` in this directory...\");\n        let continued = launch_claude_continue()?;\n        if continued {\n            return Ok(());\n        }\n        bail!(\n            \"failed to resume claude session {} and fallback `claude --continue` also failed\",\n            session_id\n        );\n    }\n\n    bail!(\n        \"failed to resume {} session {}\",\n        provider_name(session_provider),\n        session_id\n    );\n}\n\n/// Resume a session by name or ID.\nfn resume_session(session: Option<String>, path: Option<String>, provider: Provider) -> Result<()> {\n    let explicit_session_requested = session.is_some();\n    let requested_target = path\n        .as_deref()\n        .map(|value| resolve_session_target_path(Some(value)))\n        .transpose()?;\n    let index = load_index()?;\n\n    if !session_query_matches_saved_name(session.as_deref(), &index) {\n        if let Some((session_id, codex_launch_target)) = maybe_resolve_direct_codex_resume(\n            provider,","sourceCodeStart":14964,"sourceCodeEnd":15000,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ai.rs#L14964-L15000","documentation":"This error is thrown when a saved AI session cannot be resumed for a provider other than Claude (e.g. Codex or Cursor). The code tries provider-specific resume logic first, and if resume fails and there is no Claude fallback (which has its own earlier error message), it bails with the provider name and session id. It signals that the session id or provider session store is invalid or the provider CLI could not restore the session.","triggerScenarios":"Calling the session-resume command with a saved session whose provider is not Claude and the provider's own resume command fails (bad session id, deleted provider session file, provider CLI error).","commonSituations":"The session file was deleted or rotated by the provider (e.g. ~/.codex or ~/.cursor sessions cleaned up); the session id was manually edited; the provider CLI was upgraded and changed its session format; running on a machine where the provider never recorded the session.","solutions":["Verify the session id exists in the provider's session directory and re-create the session if it was deleted","Run `f ai sessions list` (or equivalent) to confirm the saved session entry and its provider are correct","Remove the stale saved session and start a new one instead of resuming","Check that the provider CLI (codex/cursor) works standalone with its own resume/continue flag"],"exampleFix":"// before\nf ai sessions resume mysession\n// after\nf ai sessions list          # confirm session + provider\nf ai sessions remove mysession\nf ai                        # start a fresh session","handlingStrategy":"fallback","validationCode":"// shell: verify the provider session exists before resuming\nf ai sessions list | grep -F \"$SESSION_ID\"\nls ~/.codex/sessions ~/.cursor 2>/dev/null | grep -F \"$SESSION_ID\" || echo 'provider session missing'","typeGuard":null,"tryCatchPattern":"// rust caller pattern\nmatch resume_session(provider, session_id) {\n    Err(e) if e.to_string().contains(\"failed to resume\") => {\n        eprintln!(\"stale session {session_id}; starting a new one instead\");\n        start_new_session(provider);\n    }\n    Err(e) => return Err(e),\n    Ok(s) => s,\n}","preventionTips":["Don't hand-edit session ids in the index","Confirm the provider CLI can resume on its own before relying on `f`","Prune saved sessions whose provider files no longer exist","Keep provider CLI versions stable across machines that share the index"],"tags":["session","resume","provider","cli"],"backgroundTag":"session-resume-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}