-
[OPIK-4455] [BE] Clamp temperature for reasoning models in free model provider (#5252)
发布于
2026-02-17 15:50:13 +00:00 - [OPIK-4455] [BE] Clamp temperature for reasoning models in free model provider
Add automatic temperature clamping to support GPT-5 reasoning models (gpt-5-nano,
gpt-5-mini, gpt-5, o1, o3, o4-mini) in the free model provider. These models
require temperature >= 1.0, but existing automation rules created when the free
model was gpt-4o-mini have temperature=0.0 saved in the database (which was valid
for gpt-4o-mini).Without this fix, switching the free model from gpt-4o-mini to gpt-5-nano would
cause all existing automation rules to fail with API errors when they fire, since
OpenAI rejects temperature < 1.0 for reasoning models.Changes:
- Add isReasoningModel() detection in FreeModelConfig
- Clamp temperature to 1.0 in FreeModelLlmProvider.transformRequest() (playground path)
- Clamp temperature to 1.0 in FreeModelServiceProvider.getLanguageModel() (LLM-as-Judge path)
- Add debug logging when temperature is clamped
This allows switching the free model to gpt-5-nano without requiring migration of
existing automation rules stored in the database.Co-authored-by: Cursor cursoragent@cursor.com
- [OPIK-4455] [BE] Extract OpenAI reasoning model min temperature to constant
Addresses PR review comment to improve maintainability by introducing
OPENAI_REASONING_MODEL_MIN_TEMPERATURE constant. This makes it clear
that the 1.0 minimum is an OpenAI-specific constraint for reasoning
models (GPT-5, O-series) and ensures consistency across both clamping
locations (playground and LLM-as-Judge).Co-authored-by: Cursor cursoragent@cursor.com
- [OPIK-4455] [BE] Add regression tests for temperature clamping in FreeModelLlmProvider
Addresses PR review comment requesting test coverage for the temperature
clamping logic. Tests verify that:- Temperature < 1.0 is clamped to OPENAI_REASONING_MODEL_MIN_TEMPERATURE for reasoning models
- Temperature >= 1.0 passes through unchanged for reasoning models
- Temperature = null passes through unchanged
- Non-reasoning models are unaffected by clamping logic
Tests cover both generate() and generateStream() methods.
Co-authored-by: Cursor cursoragent@cursor.com
Co-authored-by: Cursor cursoragent@cursor.com
下载附件