{"record":{"id":"37608618387ccc50","repo":"openai/codex","slug":"tool-call-start-used-thread-thread-id-but-codex","errorCode":null,"errorMessage":"tool call start used thread {thread_id}, but Codex turn {codex_turn_id} belongs to {}","messagePattern":"tool call start used thread (.+?), but Codex turn (.+?) belongs to (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"codex-rs/rollout-trace/src/reducer/tool.rs","lineNumber":401,"sourceCode":"        self.rollout\n            .codex_turns\n            .get(codex_turn_id)\n            .map(|turn| turn.thread_id.clone())\n            .with_context(|| {\n                format!(\"tool call start referenced unknown Codex turn {codex_turn_id}\")\n            })\n    }\n\n    fn validate_tool_turn(&self, thread_id: &str, codex_turn_id: Option<&str>) -> Result<()> {\n        if !self.rollout.threads.contains_key(thread_id) {\n            bail!(\"tool call start referenced unknown thread {thread_id}\");\n        }\n        if let Some(codex_turn_id) = codex_turn_id {\n            let Some(turn) = self.rollout.codex_turns.get(codex_turn_id) else {\n                bail!(\"tool call start referenced unknown Codex turn {codex_turn_id}\");\n            };\n            if turn.thread_id != thread_id {\n                bail!(\n                    \"tool call start used thread {thread_id}, but Codex turn {codex_turn_id} \\\n                     belongs to {}\",\n                    turn.thread_id\n                );\n            }\n        }\n        Ok(())\n    }\n\n    fn ensure_unique_model_visible_tool_call(\n        &self,\n        model_visible_call_id: Option<&str>,\n        tool_call_id: &str,\n    ) -> Result<()> {\n        let Some(model_visible_call_id) = model_visible_call_id else {\n            return Ok(());\n        };\n        if let Some(existing) = self.single_tool_for_model_visible_call(model_visible_call_id)?","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/rollout-trace/src/reducer/tool.rs#L383-L419","documentation":"Error \"tool call start used thread {thread_id}, but Codex turn {codex_turn_id} belongs to {}\" thrown in openai/codex.","triggerScenarios":"Thrown at codex-rs/rollout-trace/src/reducer/tool.rs:401 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"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"}