openai/codex · error

tool call start referenced unknown Codex turn

Error message

tool call start referenced unknown Codex turn {codex_turn_id}

What it means

Validation guard: with no thread_id on the event, the reducer tried to resolve the thread via the codex turn, but that turn id is unknown.

Solutions

  1. Ensure turn start events precede tool call starts
  2. Require thread_id on tool call starts when the turn may be missing
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

Thrown at codex-rs/rollout-trace/src/reducer/tool.rs:398

        let Some(codex_turn_id) = codex_turn_id else {
            bail!("tool call start did not include thread or Codex turn context");
        };
        self.rollout
            .codex_turns
            .get(codex_turn_id)
            .map(|turn| turn.thread_id.clone())
            .with_context(|| {
                format!("tool call start referenced unknown Codex turn {codex_turn_id}")
            })
    }

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

    fn ensure_unique_model_visible_tool_call(
        &self,
        model_visible_call_id: Option<&str>,
        tool_call_id: &str,
    ) -> Result<()> {
        let Some(model_visible_call_id) = model_visible_call_id else {

View on GitHub (pinned to 339751715c)