openai/codex · error · anyhow::Error

code cell start used thread

Error message

code cell start used thread {thread_id}, but Codex turn {codex_turn_id} belongs to {}

What it means

Cross-reference guard in validate_code_cell_turn: the start's thread id exists, but the referenced Codex turn belongs to a different thread, so ownership is inconsistent. Mismatched thread/turn ids in the code cell start event are the inputs at fault.

Solutions

  1. Correct the thread id or turn id recorded with the code cell start
  2. Fix the producer that emits inconsistent thread/turn pairs
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/rollout-trace/src/reducer/code_cell.rs:648 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/c6f1f7d4758eb03e. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/rollout-trace/src/reducer/code_cell.rs:648

            RawToolCallRequester::CodeCell { runtime_cell_id } => Ok(ToolCallRequester::CodeCell {
                code_cell_id: self.code_cell_id_for_runtime_cell_id(
                    thread_id,
                    &runtime_cell_id,
                    "code-mode nested tool",
                )?,
            }),
        }
    }

    fn validate_code_cell_turn(&self, thread_id: &str, codex_turn_id: &str) -> Result<()> {
        if !self.rollout.threads.contains_key(thread_id) {
            bail!("code cell start referenced unknown thread {thread_id}");
        }
        let Some(turn) = self.rollout.codex_turns.get(codex_turn_id) else {
            bail!("code cell start referenced unknown Codex turn {codex_turn_id}");
        };
        if turn.thread_id != thread_id {
            bail!(
                "code cell start used thread {thread_id}, but Codex turn {codex_turn_id} belongs \
                 to {}",
                turn.thread_id
            );
        }
        Ok(())
    }

    fn model_visible_code_cell_item_ids(
        &self,
        thread_id: &str,
        call_id: &str,
        kind: ConversationItemKind,
    ) -> Vec<String> {
        self.rollout
            .conversation_items
            .values()
            .filter(|item| {

View on GitHub (pinned to 339751715c)