Skip to content

OpenAI GPT-5.2: reasoning item without required following item #1158

@odrobnik

Description

@odrobnik

Error

After a few messages with openai/gpt-5.2, requests fail with:

400 Item 'rs_01ffdd9de32ec9b800696c2a431af0819884f91c2413996fab' of type 'reasoning' was provided without its required following item.

Observations

  • Only reproduced with openai/gpt-5.2
  • Not observed with openai-codex/gpt-5.2
  • Happens after a few messages in a session, not on the first turn

Investigation

The error originates from OpenAI's Responses API rejecting the conversation history. OpenAI requires reasoning items to be immediately followed by a message or function_call item.

In @mariozechner/pi-ai (openai-responses.js), assistant message content blocks are pushed to output in their original order from msg.content. If content blocks are stored in order [text, thinking], the output becomes [message, reasoning] — with reasoning at the end having no following item.

Potentially related: sessions with mixed provider history (e.g., started with Claude, switched to GPT-5.2) may have content blocks stored in unexpected orders.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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