Skip to content

Responses API replay can fail on orphan reasoning item after interrupted turn #17161

Closed

Description

@jgrantJump

Summary

Codex can resend an orphan reasoning item when replaying history after an interrupted turn, which causes the Responses API request to fail instead of self-healing.

The concrete API error is:

{
  "error": {
    "message": "Item rs_... of type reasoning was provided without its required following item.",
    "type": "invalid_request_error",
    "param": "input"
  }
}

Problem shape

A bad persisted/replayed sequence looks like:

  1. trailing reasoning item
  2. synthetic <turn_aborted> user marker
  3. next real user message

In that shape, the replayed request contains a reasoning item without the model-generated item that originally followed it, and the Responses API rejects the request.

Expected behavior

Codex should detect this narrow invalid-request case, repair the replayed input/history by dropping only the orphan reasoning item, and retry once.

Proposed fix

I implemented a working patch on my fork here:

The patch does two things:

  • normalizes replayed history so incomplete reasoning items are removed while preserving <turn_aborted>
  • retries once for the exact missing-following-item error on both HTTP and websocket Responses transports

Validation on the patch

  • just fmt
  • just fix -p codex-core
  • cargo test -p codex-core missing_reasoning -- --nocapture

I couldn’t upstream the PR directly because this repository limits PR creation to collaborators, but the fork commit above should be enough to review or cherry-pick.

Activity

  1. added
    bugSomething isn't working
    CLIIssues related to the Codex CLI
    on Apr 8, 2026
  2. github-actions commented on Apr 8, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. jgrantJump commented on Apr 8, 2026

    @jgrantJump
    Author

    Closing in favor of #16255

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 CLIbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions