Skip to content

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

Open
proyectoauraorg wants to merge 1 commit into
Zoo-Code-Org:mainfrom
proyectoauraorg:fix/215-openai-compat-temperature
Open

fix(openai): omit temperature for models that don't support it (#215)#233
proyectoauraorg wants to merge 1 commit 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
    • Fixed temperature parameter handling for AI models that don't support temperature configuration, ensuring the system properly adapts to each model's capabilities and maintains compatibility across all supported providers.

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: c4337351-f2d4-48b8-a023-0414f24e7861

📥 Commits

Reviewing files that changed from the base of the PR and between 3bd1a80 and 6b87fd5.

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

📝 Walkthrough

Walkthrough

This PR fixes conditional temperature parameter handling in the OpenAI-compatible provider. The implementation omits the temperature parameter from streaming chat requests when modelInfo.supportsTemperature is false, preserving the existing behavior when the flag is not set. Tests validate both branches of the new behavior.

Changes

Conditional Temperature Parameter Support

Layer / File(s) Summary
Conditional temperature parameter inclusion
src/api/providers/openai.ts, src/api/providers/__tests__/openai.spec.ts
OpenAiHandler.createMessage now conditionally includes temperature in the streaming request payload only when modelInfo.supportsTemperature is not false. Test cases verify that temperature is omitted for unsupported models and included by default when support is not configured.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • taltas
  • navedmerchant
  • hannesrudolph

Poem

🐰 A rabbit hops through parameters wise,
Knows when to send, when to omit with eyes,
Claude Opus nods—no temperature here!—
The fix is simple, the tests crystal clear. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: conditionally omitting the temperature parameter for models that don't support it, which directly addresses the linked issue.
Description check ✅ Passed The PR description includes linked issue, clear implementation details, behavior matrix, and comprehensive testing results, though pre-submission checklist items are not explicitly marked.
Linked Issues check ✅ Passed The changes directly address issue #215 by implementing conditional temperature omission in OpenAiHandler.createMessage() when supportsTemperature is false, with tests verifying both supported and unsupported cases.
Out of Scope Changes check ✅ Passed All changes are narrowly scoped to fix the temperature parameter handling in OpenAI provider, with test additions validating the fix—no extraneous modifications detected.
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

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

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/api/providers/openai.ts 75.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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

1 participant