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

Resolved 💬 2 comments Opened Apr 8, 2026 by jgrantJump Closed Apr 8, 2026

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.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗