openai/codex · error · anyhow::Error

Session not found: {}

Error message

Session not found: {}

What it means

Error "Session not found: {}" thrown in openai/codex.

Source

Thrown at codex-rs/exec/src/lib.rs:863

                .await
                .map_err(anyhow::Error::msg)?;
            let session_configured =
                session_configured_from_thread_start_response(&response, &config)
                    .map_err(anyhow::Error::msg)?;
            (session_configured.thread_id, session_configured)
        }
    } else if let Some(ExecCommand::Fork(args)) = command.as_ref() {
        let source_args = crate::cli::ResumeArgs {
            session_id: Some(args.session_id.clone()),
            last: false,
            all: true,
            images: Vec::new(),
            prompt: None,
        };
        let source_thread_id =
            resolve_resume_thread_id(&client, &config, state_db.as_ref(), &source_args)
                .await?
                .ok_or_else(|| anyhow::anyhow!("Session not found: {}", args.session_id))?;
        let permissions = permissions_selection_from_config(&config);
        let sandbox = permissions.is_none().then(|| {
            sandbox_mode_from_permission_profile(
                &config.permissions.effective_permission_profile(),
                config.cwd.as_path(),
            )
        });
        let response: ThreadForkResponse = send_request_with_response(
            &client,
            ClientRequest::ThreadFork {
                request_id: request_ids.next(),
                params: ThreadForkParams {
                    thread_id: source_thread_id,
                    model: config.model.clone(),
                    model_provider: Some(config.model_provider_id.clone()),
                    cwd: Some(config.cwd.to_string_lossy().to_string()),
                    runtime_workspace_roots: Some(config.workspace_roots.clone()),
                    approval_policy: Some(config.permissions.approval_policy.value().into()),

View on GitHub (pinned to 339751715c)

Solutions

  1. Use a valid, existing session ID to resume.

When it happens

Trigger: Thrown at codex-rs/exec/src/lib.rs:863 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/5f4a08ec10252a09. Report an issue: GitHub.