{"record":{"id":"89918062cf3036c0","repo":"openai/codex","slug":"conversation-item-item-id-was-referenced-before","errorCode":null,"errorMessage":"conversation item {item_id} was referenced before it was created","messagePattern":"conversation item (.+?) was referenced before it was created","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/rollout-trace/src/reducer/conversation.rs","lineNumber":439,"sourceCode":"                channel: item.channel,\n                kind: item.kind,\n                agent_message: item.agent_message,\n                body: item.body,\n                call_id: item.call_id,\n                produced_by,\n            },\n        );\n        item_id\n    }\n\n    fn update_conversation_item_from_sighting(\n        &mut self,\n        item_id: &str,\n        normalized: &NormalizedConversationItem,\n        produced_by: &[ProducerRef],\n    ) -> Result<()> {\n        let Some(item) = self.rollout.conversation_items.get_mut(item_id) else {\n            bail!(\"conversation item {item_id} was referenced before it was created\");\n        };\n\n        if item.kind == ConversationItemKind::Reasoning {\n            merge_reasoning_body(&mut item.body, &normalized.body)?;\n        }\n        for producer in produced_by {\n            if !item.produced_by.contains(producer) {\n                item.produced_by.push(producer.clone());\n            }\n        }\n        Ok(())\n    }\n\n    fn append_thread_conversation_items(\n        &mut self,\n        thread_id: &str,\n        item_ids: &[String],\n    ) -> Result<()> {","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/rollout-trace/src/reducer/conversation.rs#L421-L457","documentation":"The reducer tried to update a conversation item by id, but that id is not in rollout.conversation_items — an internal invariant break where a sighting references an item before its creation was recorded.","triggerScenarios":"Thrown at codex-rs/rollout-trace/src/reducer/conversation.rs:439 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify item creation is always applied before sighting updates","Create the item on demand if it is missing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}