Skip to content

Conversation

@ibetitsmike
Copy link
Contributor

@ibetitsmike ibetitsmike commented Dec 16, 2025

Problem

When using OpenAI reasoning models (o1, o3-mini, etc.), mux was showing warnings:

AI SDK Warning: Non-OpenAI reasoning parts are not supported. Skipping reasoning part: {"type":"reasoning","text":"..."}

This occurred because:

  1. OpenAI's Responses API returns reasoning parts with providerMetadata.openai.itemId which is required when sending reasoning parts back in subsequent requests. mux wasn't capturing this metadata.
  2. When conversation history contained reasoning from non-OpenAI models (e.g., Claude extended thinking), those parts would cause warnings when sent to OpenAI since they don't have the required itemId.

Solution

Capture providerMetadata from OpenAI reasoning streams

  • Add providerMetadata field to MuxReasoningPart type
  • Update streamManager.ts to capture providerMetadata from reasoning-delta events
  • Use SDK's delta field (not text) for reasoning content

Filter non-OpenAI reasoning before sending to OpenAI

  • Add filterNonOpenAIReasoningParts() function that strips reasoning parts without providerOptions.openai.itemId
  • Apply filter BEFORE coalescing to prevent mixing non-OpenAI reasoning with valid OpenAI reasoning

The AI SDK's convertToModelMessages() maps providerMetadataproviderOptions, so storing it on reasoning parts ensures proper round-tripping.

Testing

  • All unit tests pass (1851 tests)
  • Static checks pass
  • Added 3 new tests for non-OpenAI reasoning filtering
  • Updated existing tests to include required providerOptions.openai.itemId

Generated with mux • Model: claude-sonnet-4-20250514 • Thinking: low

@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@ibetitsmike
Copy link
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link

To use Codex here, create a Codex account and connect to github.

@ibetitsmike
Copy link
Contributor Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

…AI reasoning

When OpenAI's Responses API returns reasoning parts, they include
providerMetadata.openai.itemId which is required when sending
reasoning parts back to continue a conversation. Without this,
the AI SDK warns 'Non-OpenAI reasoning parts are not supported'
and skips the reasoning content.

Root causes:
1. mux wasn't capturing providerMetadata from reasoning-delta events
2. When history contained reasoning from non-OpenAI models (e.g., Claude),
   those parts caused warnings when sent to OpenAI

Fixes:
- Add providerMetadata field to MuxReasoningPart type
- Update ReasoningDeltaPart to capture providerMetadata from SDK
- Use SDK's 'delta' field (not 'text') for reasoning content
- Add filterNonOpenAIReasoningParts() to strip reasoning without itemId
- Filter non-OpenAI reasoning BEFORE coalescing to prevent mixing

The AI SDK's convertToModelMessages() maps providerMetadata → providerOptions,
so storing it on reasoning parts ensures proper round-tripping.

---
_Generated with `mux` • Model: `claude-sonnet-4-20250514` • Thinking: `low`_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant