openai/codex · error

tool call start did not include thread or Codex turn context

Error message

tool call start did not include thread or Codex turn context

What it means

The tool call start event carried neither a thread_id nor a codex_turn_id, so the owning thread cannot be resolved for the tool call.

Solutions

  1. Ensure the producer stamps thread or turn context on tool call starts
  2. Attach the tool call to a fallback/unknown thread
Defensive patterns

Strategy: fallback

When it happens

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

Appendix: source

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

                }
            }
            ConversationItemKind::Message
            | ConversationItemKind::Reasoning
            | ConversationItemKind::CompactionMarker => {}
        }
        Ok(())
    }

    fn tool_thread_id(
        &self,
        thread_id: Option<String>,
        codex_turn_id: Option<&str>,
    ) -> Result<String> {
        if let Some(thread_id) = thread_id {
            return Ok(thread_id);
        }
        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}");
            };

View on GitHub (pinned to 339751715c)