Skip to content

feat(openai/azure): enable temperature when reasoning_effort=none for…#2829

Open
henry-fung wants to merge 1 commit intolanggenius:mainfrom
henry-fung:feat/gpt5x-temperature-reasoning-effort-none
Open

feat(openai/azure): enable temperature when reasoning_effort=none for…#2829
henry-fung wants to merge 1 commit intolanggenius:mainfrom
henry-fung:feat/gpt5x-temperature-reasoning-effort-none

Conversation

@henry-fung
Copy link
Copy Markdown

Summary

Starting from GPT-5.2 (confirmed also for GPT-5.1), when reasoning_effort is
set to "none", temperature and top_p become valid parameters. Passing them
with any other reasoning effort value causes a 400 API error. This PR implements
the 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: add temperature to
    parameter_rules
  • llm.py (_build_responses_api_params): strip temperature/top_p/logprobs
    when reasoning is active (non-"none")
  • llm.py (_chat_generate): same stripping for the standard Chat Completions path

Azure OpenAI provider

  • constants.py: add temperature ParameterRule to gpt-5.1, gpt-5.2,
    gpt-5.4 entries
  • llm.py (_chat_generate_with_responses): restructure reasoning vs
    temperature/top_p as mutually exclusive — reasoning active → set
    reasoning: {effort} only; reasoning="none" or absent → pass
    temperature/top_p, skip reasoning param

Related Issues or Context

Implements the parameter constraints documented by OpenAI:

"The following parameters are only supported when using GPT-5.4 with reasoning
effort set to none: temperature, top_p, logprobs. Requests to GPT-5.4 or GPT-5.2
with any other reasoning effort setting … will raise an error."

Verified via direct API testing that GPT-5.1 follows the same rules.

This PR contains Changes to Non-Plugin

  • Documentation
  • Other

This PR contains Changes to Non-LLM Models Plugin

  • I have Run Comprehensive Tests Relevant to My Changes

This PR contains Changes to LLM Models Plugin

  • My Changes Affect Message Flow Handling (System Messages and User→Assistant Turn-Taking)
  • My Changes Affect Tool Interaction Flow (Multi-Round Usage and Output Handling, for both Agent App and Agent Node)
  • My Changes Affect Multimodal Input Handling (Images, PDFs, Audio, Video, etc.)
  • My Changes Affect Multimodal Output Generation (Images, Audio, Video, etc.)
  • My Changes Affect Structured Output Format (JSON, XML, etc.)
  • My Changes Affect Token Consumption Metrics
  • My Changes Affect Other LLM Functionalities (Reasoning Process, Grounding, Prompt Caching, etc.)
  • Other Changes (Add New Models, Fix Model Parameters etc.)

gpt-5.1/5.2/5.4 — reasoning_effort vs temperature behavior:

reasoning_effort temperature sent to API Result
none (default) ✅ included Success
low / medium / high ❌ stripped Would cause 400 error

Version Control

  • I have Bumped Up the Version in Manifest.yaml
    • models/openai/manifest.yaml: 0.3.40.3.5
    • models/azure_openai/manifest.yaml: 0.0.490.0.50

Dify Plugin SDK Version

  • I have Ensured dify_plugin>=0.3.0,<0.6.0 is in requirements.txt

Environment Verification

Local Deployment Environment

  • Dify Version is: , I have Tested My Changes on Local Deployment Dify

SaaS Environment

  • I have Tested My Changes on cloud.dify.ai

… 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>
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 4, 2026
@henry-fung henry-fung temporarily deployed to models/azure_openai April 4, 2026 02:18 — with GitHub Actions Inactive
@dosubot dosubot bot added the enhancement New feature or request label Apr 4, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +2589 to +2592
ParameterRule(
name="temperature",
**PARAMETER_RULE_TEMPLATE[DefaultParameterName.TEMPERATURE],
),
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.

medium

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],
                ),

Comment on lines +20 to +21
- name: temperature
use_template: temperature
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.

medium

Similar to the Azure OpenAI constants, top_p should be added to the parameter rules for GPT-5.1 to allow users to configure it when reasoning is disabled.

  - name: temperature
    use_template: temperature
  - name: top_p
    use_template: top_p

Comment on lines +784 to +785
model_parameters.pop("temperature", None)
model_parameters.pop("top_p", None)
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.

medium

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.

Suggested change
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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant