Skip to content

fix(langchain): stop dropping temperature on gpt-5.x models [PC-4988] - #134

Open
tudormatei1 wants to merge 1 commit into
mainfrom
fix/gpt5-temperature-dropped-by-langchain-openai
Open

fix(langchain): stop dropping temperature on gpt-5.x models [PC-4988]#134
tudormatei1 wants to merge 1 commit into
mainfrom
fix/gpt5-temperature-dropped-by-langchain-openai

Conversation

@tudormatei1

Copy link
Copy Markdown
Contributor

langchain-openai strips temperature for every gpt-5* model unless reasoning effort is explicitly the string "none". Unset effort is None, not "none", so an agent's configured temperature never reached the dotted variants (gpt-5.2, gpt-5.4), which default to effort none and do accept it. Nothing errored or warned, so the value just vanished between agent.json and the request.

Confirmed the models accept it: a Responses call to gpt-5.4 with temperature: 0.6 and no reasoning_effort returns 200 and echoes back temperature: 0.6 with reasoning.effort: "none".

Affects the langchain package only. Gpt5TemperatureMixin overrides both sites langchain strips at (validate_temperature and _construct_responses_api_payload) on UiPathChatOpenAI and UiPathAzureChatOpenAI, and defers to langchain everywhere it is already right, so base gpt-5, pro variants, models with reasoning explicitly enabled, and models flagged shouldSkipTemperature by discovery keep losing the parameter as before.

Start reading at gpt5_keeps_temperature. The mixin has to go before the vendor class on the MRO, and the _get_request_payload override reinstates a value the layer below deliberately removed, which reads oddly but is unavoidable: the second strip is a module-level function with no hook between it and the request.

Two canary tests assert the upstream bug is still present on unpatched ChatOpenAI. They fail when the upstream fix ships and name the files to delete, so this cannot rot silently.

Verified end to end through the agents runtime against gpt-5.4. ruff check, ruff format --check, pyright and the openai/sampling tests are clean; the pre-existing failures elsewhere in pytest tests need gateway credentials and are unchanged by this branch.

Upstream: langchain-ai/langchain#35423, fix pending in langchain-ai/langchain#35424.

@tudormatei1
tudormatei1 force-pushed the fix/gpt5-temperature-dropped-by-langchain-openai branch from bb800c7 to 2e6e887 Compare September 4, 2026 09:31
@tudormatei1
tudormatei1 deployed to LLMGW_SETTINGS September 4, 2026 09:32 — with GitHub Actions Active
@tudormatei1
tudormatei1 marked this pull request as ready for review September 4, 2026 09:35
langchain-openai strips temperature for every gpt-5* model unless reasoning
effort is explicitly the string "none". Unset effort is None, not "none", so a
configured temperature never reached the dotted variants, which default to
effort none and do accept it. Nothing errored or warned.

Gpt5TemperatureMixin overrides both strip sites on UiPathChatOpenAI and
UiPathAzureChatOpenAI and defers to langchain everywhere it is already right,
so base gpt-5, pro variants, reasoning-enabled models and models flagged
shouldSkipTemperature by discovery are unaffected. Two canary tests assert the
upstream bug is still present, so this gets deleted once the upstream fix lands.

Verified end to end through the agents runtime against gpt-5.4.
@tudormatei1
tudormatei1 force-pushed the fix/gpt5-temperature-dropped-by-langchain-openai branch from 2e6e887 to 011775f Compare September 4, 2026 09:41
@tudormatei1
tudormatei1 deployed to LLMGW_SETTINGS September 4, 2026 09:42 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant