feat: support preserving reasoning content in OpenAI format conversion#5055
Merged
kevinvandijk merged 7 commits intoKilo-Org:mainfrom Feb 12, 2026
Merged
Conversation
Add support for handling custom reasoning type content blocks when converting Anthropic messages to OpenAI format. This enables OpenAI provider to preserve reasoning/thinking content from models that use custom reasoning blocks. - Handle thinking type with part.thinking property - Handle reasoning type with part.text/thinking property for compatibility - Use type assertion to avoid TypeScript errors for custom types
🦋 Changeset detectedLatest commit: 74d904e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
kevinvandijk
approved these changes
Feb 12, 2026
Collaborator
kevinvandijk
left a comment
There was a problem hiding this comment.
Thank you @Leoyzen!
This was referenced Feb 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for handling custom reasoning type content blocks when converting Anthropic messages to OpenAI format. This enables OpenAI provider to preserve reasoning/thinking content from models that use custom reasoning blocks.
Release Notes:
Context
Some AI models (like DeepSeek, Gemini, and others) use custom
reasoningtype content blocks to represent their internal thinking process during response generation. The existingconvertToOpenAiMessagesfunction only supported the standard Anthropicthinkingtype, which caused these custom reasoning blocks to be lost during message format conversion. This prevented the OpenAI provider from preserving and displaying the reasoning content from these models.Implementation
The fix modifies the
convertToOpenAiMessagesfunction insrc/api/transform/openai-format.tsto:thinkingtype and customreasoningtype by usinganytype union and type assertionsthinkingblocks: extracts content frompart.thinking(Anthropic standard)reasoningblocks: extracts content frompart.textorpart.thinking(custom provider format)(part as any).typeassertion to avoid TypeScript errors when checking for the non-standardreasoningtypeThe reasoning content is wrapped with
<thinking>...</thinking>tags to maintain the same format as standard thinking blocks, ensuring consistent display in the UI.Screenshots
How to Test
preserveReasoning: true)Get in Touch