Skip to content

fix(openai): include reasoning parts without itemId when encrypted_content is present - #12869

Merged
gr2m merged 1 commit into
vercel:mainfrom
sleitor:fix/openai-responses-reasoning-no-item-id
Feb 26, 2026
Merged

gr2m merged 1 commit into
vercel:mainfrom
sleitor:fix/openai-responses-reasoning-no-item-id

Conversation

@sleitor

@sleitor sleitor commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Summary

When providerOptions.openai.itemId is absent on a reasoning content part, the convertToOpenAIResponsesInput converter previously skipped the part entirely with:

"Non-OpenAI reasoning parts are not supported. Skipping reasoning part"

This breaks multi-turn conversations for users who remove itemId from their reasoning parts to avoid Item with id 'rs_...' not found errors from the OpenAI Responses API.

Root Cause

The reasoning case in the converter required providerOptions.openai.itemId to be present before including the reasoning in the request. When absent, it fell to the generic warning path — even when reasoningEncryptedContent was available.

Fix

The OpenAI Responses API accepts reasoning items without an id field when encrypted_content is supplied. With this change:

  1. If itemId is absent but reasoningEncryptedContent is present → push a reasoning item with only encrypted_content (no id).
  2. If neither is present → existing warning is still emitted (no behaviour change).
  3. Makes id optional on OpenAIResponsesReasoning type to accurately reflect the API.

Testing

Added two new test cases:

  • ✅ Reasoning without itemId but with encrypted_content is included in output
  • ✅ Reasoning without either itemId or encrypted_content still warns

Fixes #12853

…resent

When providerOptions.openai.itemId is absent on a reasoning content part,
the converter previously skipped the part entirely with a warning:

  'Non-OpenAI reasoning parts are not supported. Skipping reasoning part'

This breaks multi-turn conversations for users who remove itemId to avoid
'Item with id ... not found' errors from the OpenAI Responses API.

The OpenAI Responses API accepts reasoning items without an id as long as
encrypted_content is supplied. With this fix:

- If itemId is absent but reasoningEncryptedContent is present, a reasoning
  item is pushed with only encrypted_content (no id field).
- If neither is present, the existing warning is still emitted.
- Makes id optional in OpenAIResponsesReasoning type to reflect the API.

Fixes vercel#12853
@tigent tigent Bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/openai Issues related to the @ai-sdk/openai provider labels Feb 26, 2026
@gr2m gr2m self-assigned this Feb 26, 2026

@gr2m gr2m left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR looks good and I confirmed the tests fail without the code changes.

@gr2m
gr2m merged commit 5e18272 into vercel:main Feb 26, 2026
26 of 27 checks passed
@sleitor
sleitor deleted the fix/openai-responses-reasoning-no-item-id branch February 27, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/openai Issues related to the @ai-sdk/openai provider task-merge-tracking-done

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAI Responses converter drops reasoning parts when itemId is missing

3 participants