Skip to content

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

Open
henry-fung wants to merge 10 commits into
langgenius: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 10 commits into
langgenius: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 thread models/azure_openai/models/constants.py
Comment thread models/openai/models/llm/gpt-5.1.yaml
Comment thread models/openai/models/llm/llm.py
henry-fung and others added 2 commits May 10, 2026 13:35
- Add top_p to gpt-5.1 parameter rules (openai yaml and azure constants)
- Strip logprobs when reasoning_effort is active in _chat_generate path

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels May 10, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@henry-fung henry-fung temporarily deployed to models/azure_openai May 10, 2026 05:50 — with GitHub Actions Inactive
@henry-fung henry-fung temporarily deployed to models/azure_openai May 16, 2026 09:43 — with GitHub Actions Inactive
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:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant