openai/codex · error

tool call end referenced unknown call

Error message

tool call end referenced unknown call {tool_call_id}

What it means

A tool call end event referenced a tool_call_id that is not in the registry — its start was never applied, so there is nothing to complete.

Solutions

  1. Ensure tool call starts are applied before ends
  2. Drop end events for unknown tool calls
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

        }
        Ok(())
    }

    /// Completes the canonical tool call and any terminal operation driven by dispatch output.
    ///
    /// Protocol-backed terminal tools end from runtime events; direct tools
    /// may only have the canonical result payload, so this method handles both paths.
    pub(super) fn end_tool_call(
        &mut self,
        seq: RawEventSeq,
        wall_time_unix_ms: i64,
        tool_call_id: ToolCallId,
        status: ExecutionStatus,
        result_payload: Option<RawPayloadRef>,
    ) -> Result<()> {
        let (terminal_operation_id, thread_id, end_terminal_from_result) = {
            let Some(tool_call) = self.rollout.tool_calls.get_mut(&tool_call_id) else {
                bail!("tool call end referenced unknown call {tool_call_id}");
            };
            tool_call.execution.ended_at_unix_ms = Some(wall_time_unix_ms);
            tool_call.execution.ended_seq = Some(seq);
            tool_call.execution.status = status.clone();
            tool_call.raw_result_payload_id = result_payload
                .as_ref()
                .map(|payload| payload.raw_payload_id.clone());
            (
                tool_call.terminal_operation_id.clone(),
                tool_call.thread_id.clone(),
                // Protocol-backed tools end terminal operations from
                // runtime observations. Dispatch result payloads are still kept
                // on ToolCall, but they are caller-facing and may be transformed
                // relative to the raw terminal output.
                tool_call.raw_runtime_payload_ids.is_empty(),
            )
        };
        if end_terminal_from_result && let Some(operation_id) = terminal_operation_id {

View on GitHub (pinned to 339751715c)