Skip to content

codex debug trace-reduce fails when request history adds internal metadata to a prior tool_search_call #30766

Open

Description

@anton-kalshi

What version of Codex CLI is running?

Running codex app-server and codex debug trace-reduce on the trace.

Occurred on servers running both codex-cli 0.143.0-alpha.21 and codex-cli 0.143.0-alpha.31

What subscription do you have?

Pay-as-you-go API key

Which model were you using?

Observed on trace output of gpt-5.5

What terminal emulator and version are you using (if applicable)?

Not terminal-dependent. Repro is a noninteractive codex debug trace-reduce command.

What platform is your computer?

Original trace producer:

  • AWS
  • m6i.4xlarge, x86_64
  • Ubuntu 22.04 LTS / Jammy
  • AMI: ami-04680790a315cd58d
  • AMI name: ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-20260218

Explanation

codex debug trace-reduce fails on a rollout trace produced by codex --strict-config app-server

The app-server produced trace contains this shape. First, an inference response records a completed tool_search_call:

{
  "response_id": "resp_example",
  "output_items": [
    {
      "type": "tool_search_call",
      "status": "completed",
      "call_id": "call_example",
      "arguments": {
        "query": "spawn subagent launch manage agents report result",
        "limit": 10
      },
      "execution": "client"
    }
  ]
}

Then the next inference request replays the same logical call in its input array, but with internal metadata attached:

{
  "input": [
    {
      "type": "message",
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "start"
        }
      ]
    },
    {
      "type": "tool_search_call",
      "status": "completed",
      "call_id": "call_example",
      "arguments": {
        "query": "spawn subagent launch manage agents report result",
        "limit": 10
      },
      "execution": "client",
      "internal_chat_message_metadata_passthrough": {
        "turn_id": "turn_example"
      }
    }
  ]
}

Problematic difference:

 {
   "type": "tool_search_call",
   "status": "completed",
   "call_id": "call_example",
   "arguments": {
     "query": "spawn subagent launch manage agents report result",
     "limit": 10
   },
-  "execution": "client"
+  "execution": "client",
+  "internal_chat_message_metadata_passthrough": {
+    "turn_id": "turn_example"
+  }
 }

The original production trace had real generated IDs; this report uses call_example, resp_example, and turn_example in the sanitized repro.

Reducer output:

$ npx -y @openai/codex@0.143.0-alpha.31 debug trace-reduce \
    -o /tmp/codex-trace-reducer-repro-min/state.json \
    /tmp/codex-trace-reducer-repro-min

Error: model-visible call id call_example was reused with different content

Why it appears to fail:

  1. The same logical tool_search_call appears once in a response and later in a request.
  2. The call_id, arguments, status, and execution are the same.
  3. The later request-side copy has extra internal metadata.
  4. The reducer appears to compare the full JSON body for tool_search_call.
  5. That makes internal_chat_message_metadata_passthrough part of equality.
  6. The reducer then sees the same model-visible call_id with different content and aborts.

Activity

  1. changed the title [-]codex debug trace-reduce fails when tool_search_call is replayed with ResponseItem metadata[/-] [+]codex debug trace-reduce fails when request history adds internal metadata to a prior tool_search_call[/+] on Jun 30, 2026
  2. added
    bugSomething isn't working
    CLIIssues related to the Codex CLI
    app-serverIssues involving app server protocol or interfaces
    tool-callsIssues related to tool calling
    on Jun 30, 2026
  3. RaghunandanKumar commented on Jul 1, 2026

    @RaghunandanKumar

    I tracked this to the reducer comparing the full JSON body for model-visible JSON tool calls. When request history re-adds a prior tool_search_call with internal_chat_message_metadata_passthrough, the call id is the same but the body hash differs, so trace reduction reports the reused call as different content.

    I put up a small branch here: https://github.com/RaghunandanKumar/codex/tree/fix-trace-reduce-tool-call-metadata

    Patch shape:

    • strip internal_chat_message_metadata_passthrough only when normalizing model-visible JSON tool call bodies (tool_search_call, web_search_call, image_generation_call, local_shell_call)
    • keep the actual model-visible call identity fields (type, status, call_id, arguments, execution) in the comparison
    • add a regression test covering the failing tool_search_call reuse case

    Verification run:

    • PATH="$HOME/.cargo/bin:$PATH" just test -p codex-rollout-trace request_reuses_prior_tool_call_when_only_internal_metadata_differs (failed before the fix, passed after)
    • PATH="$HOME/.cargo/bin:$PATH" just test -p codex-rollout-trace
    • PATH="$HOME/.cargo/bin:$PATH" just fmt
    • PATH="$HOME/.cargo/bin:$PATH" just fix -p codex-rollout-trace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLIapp-serverIssues involving app server protocol or interfacesbugSomething isn't workingtool-callsIssues related to tool calling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions