{"record":{"id":"003856c7463b2072","repo":"openai/codex","slug":"reserved-thread-id-cannot-be-used-when-resuming-a","errorCode":null,"errorMessage":"reserved thread ID cannot be used when resuming a thread","messagePattern":"reserved thread ID cannot be used when resuming a thread","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/core/src/session/session.rs","lineNumber":753,"sourceCode":"            Some(ThreadSource::Subagent | ThreadSource::GuardianReview)\n        );\n        if let InitialHistory::Forked(items) = &mut initial_history {\n            Self::assign_missing_rollout_response_item_ids(items);\n        }\n        let multi_agent_version = multi_agent_version.map(OnceLock::from).unwrap_or_default();\n        let initial_multi_agent_version = multi_agent_version.get().copied();\n\n        let thread_id = match (&initial_history, reserved_thread_id) {\n            (\n                InitialHistory::New | InitialHistory::Cleared | InitialHistory::Forked(_),\n                Some(thread_id),\n            ) => thread_id,\n            (InitialHistory::New | InitialHistory::Cleared | InitialHistory::Forked(_), None) => {\n                agent_control.generate_thread_id()\n            }\n            (InitialHistory::Resumed(resumed_history), None) => resumed_history.conversation_id,\n            (InitialHistory::Resumed(_), Some(_)) => {\n                return Err(anyhow::anyhow!(\n                    \"reserved thread ID cannot be used when resuming a thread\"\n                ));\n            }\n        };\n        let resumed_session_id = match &initial_history {\n            InitialHistory::Resumed(resumed) => {\n                resumed.history.iter().find_map(|item| match item {\n                    RolloutItem::SessionMeta(meta_line) => Some(meta_line.meta.session_id),\n                    _ => None,\n                })\n            }\n            InitialHistory::New | InitialHistory::Cleared | InitialHistory::Forked(_) => None,\n        };\n        // Legacy subagent rollouts synthesize session_id from their own thread id.\n        let resumed_session_id = resumed_session_id.filter(|session_id| {\n            !session_configuration.session_source.is_non_root_agent()\n                || *session_id != SessionId::from(thread_id)\n        });","sourceCodeStart":735,"sourceCodeEnd":771,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/core/src/session/session.rs#L735-L771","documentation":"Error \"reserved thread ID cannot be used when resuming a thread\" thrown in openai/codex.","triggerScenarios":"Thrown at codex-rs/core/src/session/session.rs:753 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Resume with a valid, non-reserved thread ID."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}