openai/codex · error · anyhow::Error

code cell start referenced unknown thread

Error message

code cell start referenced unknown thread {thread_id}

What it means

Referential guard in validate_code_cell_turn: the code cell start names a thread id that does not exist in the reduced rollout graph, so the cell has no owner. The unknown thread id in the start event is the input at fault.

Solutions

  1. Check the rollout for a missing thread-start event preceding the code cell
  2. Fix event ordering so thread records are emitted before code cells referencing them
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

        &self,
        thread_id: &str,
        requester: RawToolCallRequester,
    ) -> Result<ToolCallRequester> {
        match requester {
            RawToolCallRequester::Model => Ok(ToolCallRequester::Model),
            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,

View on GitHub (pinned to 339751715c)