fix(translator): support message.reasoning fallback in responses non-stream - #191
Open
warelik wants to merge 3 commits into
Open
fix(translator): support message.reasoning fallback in responses non-stream#191warelik wants to merge 3 commits into
warelik wants to merge 3 commits into
Conversation
added 2 commits
August 20, 2026 13:14
Add message.reasoning fallback to ConvertOpenAIChatCompletionsResponseToOpenAIResponsesNonStream to match the fallback behavior in the streaming path. Refs router-for-me/CLIProxyAPI#5105
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.
Problem
When translating OpenAI Chat Completions responses to OpenAI Responses API in non-streaming mode (
ConvertOpenAIChatCompletionsResponseToOpenAIResponsesNonStream), reasoning content was extracted solely fromchoices.0.message.reasoning_content. When upstream providers (such as o1/o3 via compatible gateways, Grok, DeepSeek, OpenRouter, or third-party OpenAI endpoints) return reasoning underchoices.0.message.reasoning, the reasoning text was completely omitted from the converted Responses output.In the same file, the streaming converter (
ConvertOpenAIChatCompletionsResponseToOpenAIResponses) already fell back toreasoningwhenreasoning_contentwas absent or empty, causing an unintended discrepancy between streaming and non-streaming responses.Fix
internal/translator/openai/openai/responses/openai_openai-responses_response.go:889: UpdatedConvertOpenAIChatCompletionsResponseToOpenAIResponsesNonStreamto checkchoices.0.message.reasoning_contentand fall back tochoices.0.message.reasoningif missing or empty, establishing stream/non-stream parity while preservingreasoning_contentpriority.Tests
TestConvertOpenAIChatCompletionsResponseToOpenAIResponsesNonStream_ReasoningFallback:reasoning_content field present: Verifies standardreasoning_contentextraction.reasoning fallback field present: Verifies fallback toreasoningwhenreasoning_contentis absent.both reasoning_content and reasoning present (reasoning_content priority): Verifies priority.empty reasoning_content falls back to reasoning: Verifies fallback whenreasoning_contentis"".neither field present without request reasoning: Verifies no reasoning item is emitted.neither field present with request reasoning produces empty summary: Verifies empty summary when requested.Reverse bite-check
Reverting
internal/translator/openai/openai/responses/openai_openai-responses_response.goto the pre-fix state causesTestConvertOpenAIChatCompletionsResponseToOpenAIResponsesNonStream_ReasoningFallbackto fail on both fallback subtests:Verification
Output:
Tooling note
The
jbcontextsemantic-search CLI is installed but non-functional in this environment(
jbcontext searchfails withthe OS keychain is not accessible). The equivalentreview passes were performed with the repository's own tooling and manual inspection
instead; this is disclosed for transparency about how the change was reviewed.