How to solve "BadRequestError: 400 Item 'rs_ ... ' of type 'reasoning' was provided without its required following item" error in Responses API

I did some more investigation on this, and I think I figured it out.

The responses API abstracts inputs and outputs into what they’re calling “items.” Items have different validation rules depending on their type. The reasoning item type appears to have a validation rule that causes it to be paired up with some other item in the output. They seem to be requiring an almost exact match for this, so you must populate the complete item, including its ID, or provide an item reference that points to the item. Item references take the following form:

{
  type: "item_reference",
  id: "id_of_the_item"
}

There does seem to be an allowance made for the status field, however. It appears to be ignored when using previous outputs as inputs.

The workaround where we only include reasoning items as input when we also had a computer use item only works for us in LangChain because the reasoning item in that case is always paired with the first computer use item. The real issue was that we weren’t populating the ID for the message item in cases when the reasoning item was produced as a result of a normal text generation.

This will be fixed in the next release of the LangChain OpenAI provider.

Incidentally, this is what _j was trying to tell us the very first reply to this thread.

1 Like