Skip to content

fix(openai): omit temperature for models that don't support it (#215)#233

Merged
edelauna merged 2 commits into
Zoo-Code-Org:mainfrom
proyectoauraorg:fix/215-openai-compat-temperature
May 21, 2026
Merged

fix(openai): omit temperature for models that don't support it (#215)#233
edelauna merged 2 commits into
Zoo-Code-Org:mainfrom
proyectoauraorg:fix/215-openai-compat-temperature

Conversation

@proyectoauraorg
Copy link
Copy Markdown
Contributor

@proyectoauraorg proyectoauraorg commented May 21, 2026

Summary

Fixes #215. Using claude-opus-4-7 through the OpenAI-Compatible provider fails with a 400 error because the upstream API (e.g. via LiteLLM/Bedrock) rejects temperature as deprecated/unsupported for that model.

OpenAiHandler.createMessage() always included temperature in the streaming request. This honors the model's existing supportsTemperature flag — already respected by openai-native, gemini, lite-llm and vercel-ai-gateway — and omits temperature when it is explicitly set to false.

Behavior

  • supportsTemperature: falsetemperature is omitted from the request.
  • undefined / truetemperature is sent exactly as before (no behavior change for existing models).

Users hitting this can set Supports temperature → off on the OpenAI-Compatible model (the flag already exists in ModelInfo and the settings UI).

Testing

vitest run api/providers/__tests__/openai.spec.ts
# Test Files 1 passed (1) · Tests 50 passed (50)

Added tests asserting temperature is omitted when supportsTemperature: false and included by default.

Summary by CodeRabbit

  • Bug Fixes
    • Omit temperature for models that don't support temperature while preserving prior behavior for others; ensure DeepSeek reasoner models use the correct default temperature.
  • Tests
    • Added tests covering temperature behavior: omitted when unsupported, included by default, honored when explicitly set, and defaulted for DeepSeek models.

Review Change Stack

…ode-Org#215)

claude-opus-4-7 (and similar) reject requests through the OpenAI-Compatible
provider with a 400 error because 'temperature' is deprecated/unsupported.
Honor the model's existing supportsTemperature flag (already respected by
openai-native, gemini, lite-llm and vercel-ai-gateway) and omit temperature
from the streaming request when it is explicitly set to false. undefined keeps
sending temperature, preserving current behavior for all other models.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 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: c20efa18-7df7-4779-b5c9-2d642251afad

📥 Commits

Reviewing files that changed from the base of the PR and between 6b87fd5 and 5cbdc52.

📒 Files selected for processing (1)
  • src/api/providers/__tests__/openai.spec.ts

📝 Walkthrough

Walkthrough

This PR makes OpenAiHandler.createMessage omit the temperature parameter when modelInfo.supportsTemperature is false; otherwise it includes temperature using options.modelTemperature or the deepseek default for deepseek-reasoner. Tests covering omission, default inclusion, explicit temperature, and deepseek default were added.

Changes

Conditional Temperature Parameter Support

Layer / File(s) Summary
Conditional temperature parameter inclusion
src/api/providers/openai.ts
OpenAiHandler.createMessage now only includes temperature in the streaming request payload when modelInfo.supportsTemperature is not false; value is options.modelTemperature or deepseek default when applicable.
Tests and import update
src/api/providers/__tests__/openai.spec.ts
Added tests to assert temperature is omitted when supportsTemperature is false, included by default when unset, set when modelTemperature is provided, and defaults to DEEP_SEEK_DEFAULT_TEMPERATURE for deepseek-reasoner. Also imported DEEP_SEEK_DEFAULT_TEMPERATURE.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • taltas
  • navedmerchant
  • hannesrudolph

Poem

🐰 I sniff the payload, cheeky and bright,
When models dislike warmth I hold it from sight,
If deepseek's the reasoner, a default I bring,
Else I obey whatever the options sing,
Tests hop along—now the behavior is right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: omitting temperature for models that don't support it, addressing the core issue (#215).
Description check ✅ Passed The PR description is comprehensive, covering the problem, solution, behavior changes, and testing details. However, it lacks explicit link formatting for the related GitHub issue in the template.
Linked Issues check ✅ Passed The implementation fully addresses issue #215 by respecting the supportsTemperature flag and conditionally omitting temperature from requests, with comprehensive test coverage added.
Out of Scope Changes check ✅ Passed All changes are directly scoped to addressing issue #215: modifications to OpenAiHandler.createMessage and corresponding test coverage with no extraneous changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.


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 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…ure gate (Zoo-Code-Org#215)

Add two tests so the temperature expression's branches are fully exercised:
- explicit modelTemperature (left side of the `??`)
- deepseek-reasoner default of DEEP_SEEK_DEFAULT_TEMPERATURE (truthy ternary)

Closes the partial-branch gap codecov/patch flagged on line 162.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@edelauna edelauna added this pull request to the merge queue May 21, 2026
Merged via the queue into Zoo-Code-Org:main with commit 513f47d May 21, 2026
10 checks passed
@proyectoauraorg proyectoauraorg deleted the fix/215-openai-compat-temperature branch May 21, 2026 22:57
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.

[BUG] OpenAI Compatible - Claude Opus 4.7 - temperature deprecated

2 participants