fix: omit temperature from OpenAI-compatible requests when not explicitly set#12143
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
fix: omit temperature from OpenAI-compatible requests when not explicitly set#12143roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
…itly set When no custom temperature is configured, the OpenAI handler was always sending temperature: 0 in API requests. Some OpenAI-compatible APIs (e.g. Kimi Coding) require specific temperature values and reject others. This change omits the temperature parameter entirely when the user has not explicitly set one, letting upstream APIs use their own model-specific defaults. When a user configures a custom temperature, it is still sent. Fixes #12141
This was referenced Apr 17, 2026
Open
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.
Related GitHub Issue
Closes: #12141
Description
This PR attempts to address Issue #12141. Feedback and guidance are welcome.
Problem: The OpenAI-compatible handler always sent
temperature: 0in API requests when no custom temperature was configured. Some OpenAI-compatible APIs (e.g. Kimi Coding) require specific temperature values and reject all others with a 400 error.Fix: When
modelTemperatureis not explicitly set by the user (nullorundefined), thetemperatureparameter is now omitted entirely from the request. This lets upstream APIs use their own model-specific defaults. When the user explicitly configures a temperature (including0), it is still sent as before.Changes:
src/api/providers/openai.ts: Modified both streaming and non-streaming request paths to conditionally includetemperatureonly when the user has explicitly setmodelTemperature, or when using a DeepSeek reasoner model (which has its own default).src/api/providers/__tests__/openai.spec.ts: Added 6 new tests covering the temperature omission behavior for both streaming and non-streaming modes. Updated 1 existing Azure AI Inference test to match the new behavior.Test Procedure
cd src && npx vitest run api/providers/__tests__/openai.spec.ts-- all 53 tests passcd src && npx vitest run api/providers/__tests__/) -- all 812 tests passPre-Submission Checklist
Documentation Updates
Additional Notes
The DeepSeek provider has its own
createMessage()override and is not affected by this change -- it already falls back toDEEP_SEEK_DEFAULT_TEMPERATUREindependently.Interactively review PR in Roo Code Cloud