Skip to content

400 error: reasoning item provided without required following item (OpenAI Responses API) #19582

@jameslcowan

Description

@jameslcowan

Description

When using gpt-5.2-codex with thinking enabled (thinkingLevel: low), the agent breaks after the second message in every session with a 400 error from the OpenAI Responses API.

Error

400 Item 'rs_<id>' of type 'reasoning' was provided without its required following item.

Steps to Reproduce

  1. Use gpt-5.2-codex as the primary model with thinkingLevel: low
  2. Send a message to the agent (it responds fine — reasoning block + tool calls on first turn, reasoning block + text on second turn)
  3. Send a second message
  4. The 400 error fires immediately — every subsequent message fails

Root Cause

The first assistant turn contains a reasoning block (rs_...) followed by tool calls. When the next user message arrives, openclaw reconstructs the full conversation history and sends it to the OpenAI Responses API. The API rejects the request because the reasoning block from turn 1 is now considered "orphaned" — it is not immediately followed by a text response.

The OpenAI Responses API requires that reasoning items in the input array be immediately followed by their paired content. Reasoning blocks paired only with tool calls (without a subsequent text response in the same turn) appear to violate this constraint when replayed in conversation history.

Workaround

Setting thinkingLevel: off prevents the issue entirely. Alternatively, manually creating a new session JSONL file and updating sessions.json clears the broken state, but it recurs on the next session start with thinking enabled.

Environment

  • openclaw: 2026.2.15
  • Model: openai/gpt-5.2-codex
  • API: openai-responses
  • OS: Fedora Linux (x86_64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions