feat(openai/azure): enable temperature when reasoning_effort=none for…#2829
feat(openai/azure): enable temperature when reasoning_effort=none for…#2829henry-fung wants to merge 1 commit intolanggenius:mainfrom
Conversation
… gpt-5.1/5.2/5.4 Starting from GPT-5.2 (and confirmed also for GPT-5.1), when reasoning_effort is set to "none", temperature and top_p become valid parameters. With any other reasoning effort value, passing these parameters causes a 400 API error. Changes: - OpenAI provider: add temperature parameter to gpt-5.1/5.2/5.4 YAML definitions - OpenAI llm.py (_build_responses_api_params): strip temperature/top_p/logprobs when reasoning_effort is active (non-"none") - OpenAI llm.py (_chat_generate): same stripping for standard Chat Completions path - Azure OpenAI constants.py: add temperature ParameterRule to gpt-5.1/5.2/5.4 entries - Azure OpenAI llm.py (_chat_generate_with_responses): restructure reasoning vs temperature/top_p as mutually exclusive — reasoning active → set reasoning param only; reasoning=none or absent → pass temperature/top_p, skip reasoning param Tested against Azure OpenAI (dscgpt.openai.azure.com) with all three deployments: - reasoning=none + temperature=0.7 → success - reasoning=low + temperature=0.7 → expected 400 error Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces support for the reasoning_effort parameter in Azure OpenAI and OpenAI models, specifically targeting GPT-5 variants. It includes logic to conditionally include or strip parameters like temperature, top_p, and logprobs based on whether reasoning is active, as these are mutually exclusive in the underlying APIs. Review feedback highlights the need for consistent top_p parameter rules across model definitions and suggests ensuring logprobs is consistently stripped in the standard chat generation path when reasoning is enabled.
| ParameterRule( | ||
| name="temperature", | ||
| **PARAMETER_RULE_TEMPLATE[DefaultParameterName.TEMPERATURE], | ||
| ), |
There was a problem hiding this comment.
The PR description states that top_p is also a valid parameter for GPT-5.1 when reasoning_effort is set to none. However, it is missing from the parameter_rules for the gpt-5.1 model entry here, while it was correctly added (or already present) for gpt-5.2 and gpt-5.4.
ParameterRule(
name="temperature",
**PARAMETER_RULE_TEMPLATE[DefaultParameterName.TEMPERATURE],
),
ParameterRule(
name="top_p",
**PARAMETER_RULE_TEMPLATE[DefaultParameterName.TOP_P],
),| - name: temperature | ||
| use_template: temperature |
| model_parameters.pop("temperature", None) | ||
| model_parameters.pop("top_p", None) |
There was a problem hiding this comment.
The PR description mentions that logprobs is also restricted when reasoning is active. While it is correctly stripped in _build_responses_api_params, it is missing from the stripping logic here in the standard _chat_generate path. This could lead to a 400 error if a user provides logprobs with a non-none reasoning effort.
| model_parameters.pop("temperature", None) | |
| model_parameters.pop("top_p", None) | |
| model_parameters.pop("temperature", None) | |
| model_parameters.pop("top_p", None) | |
| model_parameters.pop("logprobs", None) |
Summary
Starting from GPT-5.2 (confirmed also for GPT-5.1), when
reasoning_effortisset to
"none",temperatureandtop_pbecome valid parameters. Passing themwith any other reasoning effort value causes a
400API error. This PR implementsthe conditional logic for gpt-5.1, gpt-5.2, and gpt-5.4 in both the OpenAI
and Azure OpenAI providers.
OpenAI provider
gpt-5.1.yaml,gpt-5.2.yaml,gpt-5.4.yaml: addtemperaturetoparameter_rulesllm.py(_build_responses_api_params): striptemperature/top_p/logprobswhen reasoning is active (non-
"none")llm.py(_chat_generate): same stripping for the standard Chat Completions pathAzure OpenAI provider
constants.py: addtemperatureParameterRuletogpt-5.1,gpt-5.2,gpt-5.4entriesllm.py(_chat_generate_with_responses): restructure reasoning vstemperature/top_p as mutually exclusive — reasoning active → set
reasoning: {effort}only; reasoning="none"or absent → passtemperature/top_p, skip reasoning param
Related Issues or Context
Implements the parameter constraints documented by OpenAI:
Verified via direct API testing that GPT-5.1 follows the same rules.
This PR contains Changes to Non-Plugin
This PR contains Changes to Non-LLM Models Plugin
This PR contains Changes to LLM Models Plugin
gpt-5.1/5.2/5.4 —
reasoning_effortvstemperaturebehavior:none(default)low/medium/highVersion Control
models/openai/manifest.yaml:0.3.4→0.3.5models/azure_openai/manifest.yaml:0.0.49→0.0.50Dify Plugin SDK Version
dify_plugin>=0.3.0,<0.6.0is in requirements.txtEnvironment Verification
Local Deployment Environment
SaaS Environment