Skip to content

fix(openai): omit temperature when no custom value is set (#242)#247

Open
proyectoauraorg wants to merge 1 commit into
Zoo-Code-Org:mainfrom
proyectoauraorg:fix/242-omit-temperature-when-unset
Open

fix(openai): omit temperature when no custom value is set (#242)#247
proyectoauraorg wants to merge 1 commit into
Zoo-Code-Org:mainfrom
proyectoauraorg:fix/242-omit-temperature-when-unset

Conversation

@proyectoauraorg
Copy link
Copy Markdown
Contributor

@proyectoauraorg proyectoauraorg commented May 22, 2026

Summary

When "use custom temperature" is off, the OpenAI-Compatible provider still sent temperature: 0 (the fallback), so the model's server-side default never applied. Per the discussion on #242 (option A, which @edelauna preferred), this omits the temperature field in that case.

Behavior

temperature is now included only when either the user set a custom temperature or the model needs a specific default (e.g. deepseek-reasoner); otherwise it is omitted.

  • Preserves the supportsTemperature capability gate from fix(openai): omit temperature for models that don't support it (#215) #233 (still omitted when supportsTemperature === false).
  • Preserves model-required defaults (deepseek-reasonerDEEP_SEEK_DEFAULT_TEMPERATURE).
  • A deliberately-set 0 is distinguished from "unset" and is still sent.
  • Behavioral note: OpenAI-Compatible users who never set a temperature now get the model's server-side default instead of 0.

Scope

Targets the OpenAI-Compatible provider (the case reported in #242). The same ?? <default> pattern exists in the shared getModelParams and a few other providers (lite-llm, openai-native, lm-studio, vercel-ai-gateway, …); happy to converge them on this behavior in a follow-up — poe and moonshot already omit, so there is precedent.

Tests

api/providers/__tests__/openai.spec.ts: omitted by default, custom value sent, deliberate 0 sent, deepseek-reasoner default preserved, supportsTemperature === false still omitted. 53 pass.

Refs #242

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved temperature parameter handling for OpenAI-compatible providers. The temperature field is now omitted when no custom value is set, allowing server-side defaults to apply instead of forcing a value of 0. Explicit temperature values and model-specific defaults remain preserved.

Review Change Stack

…rg#242)

When "use custom temperature" is off, the OpenAI-Compatible provider still sent temperature: 0 (the fallback), so the model's server-side default never applied. Per the discussion on Zoo-Code-Org#242 (option A), omit the temperature field in that case. Preserves the supportsTemperature gate (Zoo-Code-Org#233), model-required defaults (deepseek-reasoner), and a deliberately-set 0.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f8eeb87a-0d90-4864-8e88-7974bfc613f9

📥 Commits

Reviewing files that changed from the base of the PR and between 45b239c and 5bb3ac8.

📒 Files selected for processing (3)
  • .changeset/omit-temperature-when-unset.md
  • src/api/providers/__tests__/openai.spec.ts
  • src/api/providers/openai.ts

📝 Walkthrough

Walkthrough

This PR modifies the OpenAI-compatible provider to omit the temperature parameter when not explicitly set, allowing server-side defaults to apply instead of forcing 0. The implementation preserves model-required defaults and explicit 0 values, tests are updated to validate the new behavior, and a changeset documents the change.

Changes

Temperature Omission for OpenAI-Compatible Provider

Layer / File(s) Summary
Temperature parameter omission logic
src/api/providers/openai.ts
OpenAiHandler.createMessage now conditionally includes temperature only when supported and either explicitly set or required for DeepSeek; otherwise omits the field to allow server defaults.
Test coverage for omission and explicit values
src/api/providers/__tests__/openai.spec.ts
Test cases verify temperature is absent when no custom value is configured, explicitly set 0 is still transmitted, and Azure AI Service expectations reflect the omission of default temperature.
Changeset documentation
.changeset/omit-temperature-when-unset.md
Changeset entry documents the provider behavior change to omit temperature when unset while preserving capability gating and explicit values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • Zoo-Code-Org/Zoo-Code#233: Both PRs modify OpenAiHandler.createMessage temperature payload construction for the streaming request path.

Suggested reviewers

  • taltas
  • JamesRobert20
  • navedmerchant
  • hannesrudolph
  • edelauna

Poem

🐰 A whisper of warmth, now softly withdrawn,
Let servers decide what defaults are drawn,
Unless you command, or DeepSeek must play,
Temperature's unset shall have its own way!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is missing the required 'Related GitHub Issue' section and 'Test Procedure' section from the template, though it provides detailed explanation of changes and behavior. Add the 'Related GitHub Issue' section (Closes: #242) and 'Test Procedure' section explaining how to verify the fix and test results.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: omitting the temperature field when no custom value is set in the OpenAI provider, which is the core fix in this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/api/providers/__tests__/openai.spec.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

src/api/providers/openai.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@edelauna edelauna left a comment

Choose a reason for hiding this comment

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

Thanks for addressing this, just had some nits around documentation and comments.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

😅 i haven't been too strict about including changesets, can provide some rationale for providing this as part of this PR? I've kind of been thinking we'll update this as part of our release process, since it requires localization.

stream: true,
stream_options: { include_usage: true },
temperature: 0,
// #242 (option A): no custom temperature set → `temperature` is omitted.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's ok not to document the specific issue in code, it'll be handled in commit history.

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.

2 participants