nikivdev/code · error

failed to resume {} session {}

Error message

failed to resume {} session {}

What it means

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.

Source

Thrown at src/ai.rs:14982

        }
        if !has_tty {
            bail!(
                "failed to resume claude session {} (non-interactive shell; fallback continue unavailable)",
                session_id
            );
        }
        eprintln!("Falling back to `claude --continue` in this directory...");
        let continued = launch_claude_continue()?;
        if continued {
            return Ok(());
        }
        bail!(
            "failed to resume claude session {} and fallback `claude --continue` also failed",
            session_id
        );
    }

    bail!(
        "failed to resume {} session {}",
        provider_name(session_provider),
        session_id
    );
}

/// Resume a session by name or ID.
fn resume_session(session: Option<String>, path: Option<String>, provider: Provider) -> Result<()> {
    let explicit_session_requested = session.is_some();
    let requested_target = path
        .as_deref()
        .map(|value| resolve_session_target_path(Some(value)))
        .transpose()?;
    let index = load_index()?;

    if !session_query_matches_saved_name(session.as_deref(), &index) {
        if let Some((session_id, codex_launch_target)) = maybe_resolve_direct_codex_resume(
            provider,

View on GitHub (pinned to a747e741ae)

Solutions

  1. Verify the session id exists in the provider's session directory and re-create the session if it was deleted
  2. Run `f ai sessions list` (or equivalent) to confirm the saved session entry and its provider are correct
  3. Remove the stale saved session and start a new one instead of resuming
  4. Check that the provider CLI (codex/cursor) works standalone with its own resume/continue flag

Example fix

// before
f ai sessions resume mysession
// after
f ai sessions list          # confirm session + provider
f ai sessions remove mysession
f ai                        # start a fresh session
Defensive patterns

Strategy: fallback

Validate before calling

// shell: verify the provider session exists before resuming
f ai sessions list | grep -F "$SESSION_ID"
ls ~/.codex/sessions ~/.cursor 2>/dev/null | grep -F "$SESSION_ID" || echo 'provider session missing'

Try / catch

// rust caller pattern
match resume_session(provider, session_id) {
    Err(e) if e.to_string().contains("failed to resume") => {
        eprintln!("stale session {session_id}; starting a new one instead");
        start_new_session(provider);
    }
    Err(e) => return Err(e),
    Ok(s) => s,
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/98c74d41073d3b71. Report an issue: GitHub.