fix(openai): recognize gpt-6 models as reasoning models - #11625
Open
Vladimir Babin (chiliec) wants to merge 1 commit into
Open
Vladimir Babin (chiliec) wants to merge 1 commit into
Vladimir Babin (chiliec) wants to merge 1 commit into
Conversation
Fixes langchain-ai#11624 ## What `ChatOpenAI` drops explicitly configured `reasoning` for `gpt-6-astra`. The profile added in langchain-ai#11555 marks it `reasoningOutput: true`, but `_getReasoningParams()` first gates on `isReasoningModel()`, which only recognises `o*` and non-chat `gpt-5*` names — so the caller's reasoning object never reaches the Responses request body. ## Fix Extend `isReasoningModel()` in `libs/providers/langchain-openai/src/utils/misc.ts` with a `gpt-6` branch mirroring the existing `gpt-5` one (same `-chat` exclusion). One line. ## Tests `index.test.ts`: - `isReasoningModel`: `gpt-6-astra` / `gpt-6` → true, `gpt-6-chat-latest` → false - request construction: the issue's network-free repro — `gpt-6-astra` + `useResponsesApi` + `reasoning: { effort, summary }` → the request body carries the reasoning object unchanged (mirrors the sibling `reasoningEffort` tests using a mocked `fetch`) Existing non-reasoning / gpt-5 / o-series cases unchanged. ## Validation ``` $ cd libs/providers/langchain-openai $ npx vitest run Test Files 29 passed (29) Tests 345 passed (345) Type Errors no errors $ oxfmt --check / oxlint on the two touched files: clean ``` RED→GREEN: with the source change reverted (tests kept) both new cases fail (`expected false to be true`, `expected undefined to deeply equal { effort: 'high', summary: 'auto' }`); restoring the one-line fix turns them green. Happy to adjust. Signed-off-by: Vladimir Babin <vovababin@gmail.com>
🦋 Changeset detectedLatest commit: dd527d9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #11624
What
ChatOpenAIdrops explicitly configuredreasoningforgpt-6-astra. Theprofile added in #11555 marks it
reasoningOutput: true, but_getReasoningParams()first gates onisReasoningModel(), which onlyrecognises
o*and non-chatgpt-5*names — so the caller's reasoningobject never reaches the Responses request body.
Fix
Extend
isReasoningModel()inlibs/providers/langchain-openai/src/utils/misc.tswith a
gpt-6branch mirroring the existinggpt-5one (same-chatexclusion). One line.
Tests
index.test.ts:isReasoningModel:gpt-6-astra/gpt-6→ true,gpt-6-chat-latest→ falsegpt-6-astra+useResponsesApi+reasoning: { effort, summary }→ the request bodycarries the reasoning object unchanged (mirrors the sibling
reasoningEfforttests using a mockedfetch)Existing non-reasoning / gpt-5 / o-series cases unchanged.
Validation
RED→GREEN: with the source change reverted (tests kept) both new cases fail
(
expected false to be true,expected undefined to deeply equal { effort: 'high', summary: 'auto' }); restoring the one-line fix turns them green.Happy to adjust.