AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Temperature Silently Dropped From Responses API Payload For Gpt-5.2 When Reasoning_effort Not Supplied (Defaults To None)

When using ChatOpenAI with use_responses_api=True and model='gpt-5.2', specifying temperature=0.5 results in the temperature parameter being omitted from the API request payload. This occurs because langchain-openai's temperature validation logic removes temperature for models that support reasoning parameters without considering that gpt-5.2 defaults to reasoning_effort='none', which permits temperature usage.

mediumConfidence 95%LangchainVector StoresRetrieversAffected V1.1.10

Origin Analysis

In langchain_openai/chat_models/base.py, the methods validate_temperature and _construct_responses_api_payload contain conditional logic that drops the temperature field for any model that supports reasoning parameters (e.g., _supports_reasoning returns True). This logic does not account for the fact that newer OpenAI models like gpt-5.2 support temperature when reasoning is disabled (reasoning_effort is None or 'none'). As a result, the temperature parameter is removed even though it is valid and intended by the user.
1. Install langchain-openai 1.1.10 and openai 2.23.0. 2. Set OPENAI_API_KEY environment variable. 3. Run the following Python code: ```python from langchain_openai import ChatOpenAI model = ChatOpenAI(model='gpt-5.2', use_responses_api=True, temperature=0.5) model.invoke([{'role': 'user', 'content': 'Hello, world'}]) ``` 4. Observe the debug output or inspect the HTTP request payload; the 'temperature' field is absent from the JSON body sent to the /responses endpoint.

Fixing Code Block

def _should_drop_temperature(self, reasoning_effort=None): if not self._supports_reasoning(): return False # For gpt-5.x models, temperature is allowed when reasoning_effort is None or 'none' if self.model_name and self.model_name.startswith('gpt-5'): return reasoning_effort is not None and reasoning_effort != 'none' # For other reasoning models, keep existing behavior (drop temperature) return True # In validate_temperature method, replace the temperature removal condition: # Instead of: # if self._supports_reasoning(): # values.pop('temperature', None) # Use: if self._should_drop_temperature(reasoning_effort): values.pop('temperature', None) # In _construct_responses_api_payload method, replace the temperature removal condition: # Instead of: # if self._supports_reasoning(): # payload.pop('temperature', None) # Use: if self._should_drop_temperature(reasoning_effort): payload.pop('temperature', None)
The hotfix introduces a helper method `_should_drop_temperature` that determines whether temperature should be removed based on both the model's reasoning support and the effective reasoning effort. For gpt-5.x models, temperature is allowed when reasoning_effort is None or 'none' (the default). For all other reasoning-capable models, the existing conservative behavior of dropping temperature is preserved. This minimal change ensures that user-specified temperature is included for gpt-5.2 when reasoning is off, without affecting other models.

Edge Case Audit

This change only relaxes temperature dropping for models with names starting 'gpt-5'. If there are other models (e.g., future gpt-5 variants or o-series) that do not support temperature even with reasoning_effort='none', this could lead to API errors or unexpected behavior. Ensure thorough testing with the specific model list before release. The change does not introduce concurrency or multi-threading issues as it only affects request payload construction. To rollback, revert this patch and restore the original unconditional removal for reasoning models.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state