Skip to content

fix(openai): recognize gpt-6 models as reasoning models - #11625

Open
Vladimir Babin (chiliec) wants to merge 1 commit into
langchain-ai:mainfrom
chiliec:fix/openai-gpt6-reasoning
Open

Vladimir Babin (chiliec) wants to merge 1 commit into
langchain-ai:mainfrom
chiliec:fix/openai-gpt6-reasoning

Conversation

@chiliec

Copy link
Copy Markdown
Contributor

Fixes #11624

What

ChatOpenAI drops explicitly configured reasoning for gpt-6-astra. The
profile added in #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.

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-bot

changeset-bot Bot commented Sep 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dd527d9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@langchain/openai Patch
@langchain/classic Patch
@langchain/deepseek Patch
@langchain/fireworks Patch
@langchain/openrouter Patch
@langchain/together-ai Patch
@langchain/xai Patch
@langchain/neo4j Patch

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChatOpenAI drops explicit reasoning for gpt-6-astra despite reasoning-enabled model profile

1 participant