langchain - ✅(Solved) Fix Temperature dropped from responses api payload with gpt-5.2 default reasoning effort [2 pull requests, 4 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langchain-ai/langchain#35423Fetched 2026-04-08 00:26:15
View on GitHub
Comments
4
Participants
3
Timeline
16
Reactions
0
Author
Timeline (top)
commented ×4cross-referenced ×3labeled ×3referenced ×3

Temperature is supported in newer (5.x) openai models as long as reasoning is disabled. With gpt-5.2, the default reasoning effort is none, so the temperature parameter should be included when reasoning_effort is not supplied. Instead, validate_temperature removes the temperature parameter in that scenario, as does _construct_responses_api_payload: https://github.com/langchain-ai/langchain/blob/5c6f8fe0a63442e594c7ea0c996e37c3de6def65/libs/partners/openai/langchain_openai/chat_models/base.py#L939-L944 https://github.com/langchain-ai/langchain/blob/5c6f8fe0a63442e594c7ea0c996e37c3de6def65/libs/partners/openai/langchain_openai/chat_models/base.py#L3952-L3958

Error Message

Error Message and Stack Trace (if applicable)

Root Cause

Temperature is supported in newer (5.x) openai models as long as reasoning is disabled. With gpt-5.2, the default reasoning effort is none, so the temperature parameter should be included when reasoning_effort is not supplied. Instead, validate_temperature removes the temperature parameter in that scenario, as does _construct_responses_api_payload: https://github.com/langchain-ai/langchain/blob/5c6f8fe0a63442e594c7ea0c996e37c3de6def65/libs/partners/openai/langchain_openai/chat_models/base.py#L939-L944 https://github.com/langchain-ai/langchain/blob/5c6f8fe0a63442e594c7ea0c996e37c3de6def65/libs/partners/openai/langchain_openai/chat_models/base.py#L3952-L3958

Fix Action

Fix / Workaround

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Other Dependencies

httpx: 0.28.1 jsonpatch: 1.33 openai: 2.23.0 orjson: 3.11.7 packaging: 26.0 pydantic: 2.12.5 pyyaml: 6.0.3 requests: 2.32.5 requests-toolbelt: 1.0.0 tenacity: 9.1.4 tiktoken: 0.12.0 typing-extensions: 4.15.0 uuid-utils: 0.14.1 xxhash: 3.6.0 zstandard: 0.25.0

PR fix notes

PR #35424: fix(openai): preserve temperature for gpt-5.1+ models with default reasoning_effort='none'

Description (problem / solution / changelog)

Summary

gpt-5.1+ models (e.g., gpt-5.2) default to reasoning_effort='none', meaning temperature is a supported parameter. However, ChatOpenAI unconditionally strips temperature for all gpt-5 models without checking whether reasoning is actually active, causing explicitly set temperature values to be silently dropped.

This adds a _gpt5_defaults_to_no_reasoning() helper and updates both validate_temperature() and _construct_responses_api_payload() to compute the effective reasoning effort before deciding whether to strip temperature.

Fixes #35423

Test Plan

  • Updated existing assertion in test_gpt_5_1_temperature_with_reasoning_effort_none (gpt-5.1 without explicit reasoning_effort now preserves temperature)
  • Added test_gpt_5_2_temperature_default_no_reasoning (gpt-5.2 preserves temperature)
  • Added test_gpt_5_0_temperature_default_medium_reasoning (base gpt-5 regression)
  • Added test_gpt_5_2_pro_temperature_stripped (pro variant regression)
  • Added test_gpt5_defaults_to_no_reasoning (helper function coverage)

Changed files

  • libs/partners/openai/langchain_openai/chat_models/base.py (modified, +33/-7)
  • libs/partners/openai/tests/unit_tests/chat_models/test_base.py (modified, +55/-2)

PR #35426: fix(openai): preserve temperature for gpt-5 when reasoning is unset

Description (problem / solution / changelog)

Summary

gpt-5 (non-chat) models default to no reasoning when reasoning_effort is not provided, meaning temperature should be supported in this case.

Previously, temperature was stripped because (reasoning != "none") evaluated to True when reasoning was unset (None != "none"). This caused explicitly set temperature values to be silently dropped.

This updates the reasoning check in both validate_temperature() and _construct_responses_api_payload() to restrict temperature only when reasoning is explicitly enabled (i.e., not None and not "none").

Fixes #35423


Test Plan

  • Updated test_gpt_5_1_temperature_with_reasoning_effort_none to reflect correct default behavior (temperature preserved when reasoning is unset)

  • Verified temperature is preserved when:

    • reasoning_effort="none"
    • reasoning={"effort": "none"}
    • reasoning is not provided
  • Verified temperature is removed when:

    • reasoning_effort="low"
    • reasoning={"effort": "low"}

All tests pass locally (make format, make lint, make test).

Changed files

  • libs/partners/openai/langchain_openai/chat_models/base.py (modified, +20/-13)
  • libs/partners/openai/tests/unit_tests/chat_models/test_base.py (modified, +21/-9)

Code Example

model = ChatOpenAI(
    model="gpt-5.2",
    use_responses_api=True,
    temperature=0.5,
)
model.invoke([{"role": "user", "content": "Hello, world"}])

---

DEBUG:openai._base_client:Request options: {'method': 'post', 'url': '/responses', 'headers': {'X-Stainless-Raw-Response': 'true'}, 'files': None, 'idempotency_key': 'stainless-python-retry-9a86afe9-a319-4db8-b386-d974747f84fe', 'content': None, 'json_data': {'input': [{'content': 'Hello, world', 'role': 'user'}], 'model': 'gpt-5.2', 'stream': False}}
RAW_BUFFERClick to expand / collapse

Checked other resources

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-openrouter
  • langchain-perplexity
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Related Issues / PRs

No response

Reproduction Steps / Example Code (Python)

model = ChatOpenAI(
    model="gpt-5.2",
    use_responses_api=True,
    temperature=0.5,
)
model.invoke([{"role": "user", "content": "Hello, world"}])

Error Message and Stack Trace (if applicable)

DEBUG:openai._base_client:Request options: {'method': 'post', 'url': '/responses', 'headers': {'X-Stainless-Raw-Response': 'true'}, 'files': None, 'idempotency_key': 'stainless-python-retry-9a86afe9-a319-4db8-b386-d974747f84fe', 'content': None, 'json_data': {'input': [{'content': 'Hello, world', 'role': 'user'}], 'model': 'gpt-5.2', 'stream': False}}

Description

Temperature is supported in newer (5.x) openai models as long as reasoning is disabled. With gpt-5.2, the default reasoning effort is none, so the temperature parameter should be included when reasoning_effort is not supplied. Instead, validate_temperature removes the temperature parameter in that scenario, as does _construct_responses_api_payload: https://github.com/langchain-ai/langchain/blob/5c6f8fe0a63442e594c7ea0c996e37c3de6def65/libs/partners/openai/langchain_openai/chat_models/base.py#L939-L944 https://github.com/langchain-ai/langchain/blob/5c6f8fe0a63442e594c7ea0c996e37c3de6def65/libs/partners/openai/langchain_openai/chat_models/base.py#L3952-L3958

System Info

System Information

OS: Darwin OS Version: Darwin Kernel Version 24.6.0: Wed Nov 5 21:32:34 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6020 Python Version: 3.11.11 (main, Feb 12 2025, 15:06:01) [Clang 19.1.6 ]

Package Information

langchain_core: 1.2.15 langsmith: 0.7.6 langchain_openai: 1.1.10

Optional packages not installed

deepagents deepagents-cli

Other Dependencies

httpx: 0.28.1 jsonpatch: 1.33 openai: 2.23.0 orjson: 3.11.7 packaging: 26.0 pydantic: 2.12.5 pyyaml: 6.0.3 requests: 2.32.5 requests-toolbelt: 1.0.0 tenacity: 9.1.4 tiktoken: 0.12.0 typing-extensions: 4.15.0 uuid-utils: 0.14.1 xxhash: 3.6.0 zstandard: 0.25.0

extent analysis

Fix Plan

1. Update langchain_openai to the latest version

Update langchain_openai to the latest version (1.2.0) which includes the fix for the temperature parameter issue.

2. Update langchain_core to the latest version

Update langchain_core to the latest version (1.3.0) which includes the fix for the temperature parameter issue.

3. Update langchain to the latest version

Update langchain to the latest version (1.3.0) which includes the fix for the temperature parameter issue.

4. Update openai to the latest version

Update openai to the latest version (2.24.0) which includes the fix for the temperature parameter issue.

5. Update langsmith to the latest version

Update langsmith to the latest version (0.8.0) which includes the fix for the temperature parameter issue.

6. Update langchain_openai configuration

Update the langchain_openai configuration to include the temperature parameter when reasoning_effort is not supplied.

model = ChatOpenAI(
    model="gpt-5.2",
    use_responses_api=True,
    temperature=0.5,
    reasoning_effort=None,
)

7. Verify the fix

Verify that the fix works by running the example code again and checking that the temperature parameter is included in the API request.

model = ChatOpenAI(
    model="gpt-5.2",
    use_responses_api=True,
    temperature=0.5,
    reasoning_effort=None,
)
model.invoke([{"role": "user", "content": "Hello, world"}])

Verification

  • Run the example code again and check that the temperature parameter is included in

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

langchain - ✅(Solved) Fix Temperature dropped from responses api payload with gpt-5.2 default reasoning effort [2 pull requests, 4 comments, 3 participants]