Skip to content

fix(providers/openai): stop treating -chat names as non-reasoning models - #87

Merged
ethanndickson merged 2 commits into
coder_2_33from
ethan/openai-chat-names-reasoning
Dec 2, 2026
Merged

ethanndickson merged 2 commits into
coder_2_33from
ethan/openai-chat-names-reasoning

Conversation

@ethanndickson

@ethanndickson ethanndickson commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Relates to coder/coder#31714

The sync in #86 brought in upstream's rule that a model name containing -chat isn't a reasoning model. Before charmbracelet#386 only the Responses path excluded gpt-5-chat, and the wider rule came out of a refactor there that merged the two checks.

I don't think that rule protects anything anymore. OpenAI has shut down gpt-5-chat-latest and the later -chat-latest snapshots, and Azure has retired every gpt-5*-chat version in favour of gpt-chat-latest, which is a reasoning model. What it does do is send max_tokens to an Azure deployment with -chat in its name, e.g. gpt-5.1-chat. That worked before the sync, and Azure's reasoning models reject max_tokens:

Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.

To fix, we'll just drop -chat from the pattern. Whilst here, chat-latest joins the names we do recognise, as otherwise a deployment named gpt-chat-latest matches nothing and still gets max_tokens. I'll send the same change upstream.

Every model with -chat in its ID that was not a reasoning model has been
shut down: gpt-5-chat-latest on OpenAI, and gpt-5-chat on Azure, where
deployments were upgraded in place to gpt-chat-latest, which rejects
max_tokens. Treating such names as non-reasoning on Chat Completions
sends max_tokens to Azure deployments named like gpt-5.1-chat.
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T07:52:28.323196Z cd94339 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12097724db

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread providers/openai/reasoning.go Resolved
chat-latest, deployed on Azure as gpt-chat-latest, is the replacement for
the retired -chat models and rejects max_tokens, but no rule recognised
the name on Chat Completions.
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cd94339bb6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread providers/openai/reasoning.go Resolved
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

re: Suppress reasoning effort for gpt-chat-latest
Declining. This only happens when the caller sets a reasoning effort for this model, and fantasy sends a caller's effort as given everywhere else: Chat Completions sends it for any model, and no other reasoning model with a restricted set of efforts is special-cased. The API's error names the values it supports. On the Responses path this change also stops sending temperature and top_p to gpt-chat-latest, which it rejects.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: cd94339bb6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ethanndickson
ethanndickson marked this pull request as ready for review December 2, 2026 07:50
@ethanndickson
ethanndickson merged commit 32e0094 into coder_2_33 Dec 2, 2026
6 checks passed
ethanndickson added a commit to coder/coder that referenced this pull request Dec 2, 2026
coder/fantasy#87 stops treating model IDs that contain -chat as
non-reasoning models and recognizes chat-latest, so Azure OpenAI
deployments named like gpt-5.1-chat or gpt-chat-latest get
max_completion_tokens.
ethanndickson added a commit to coder/coder that referenced this pull request Dec 2, 2026
)

Closes #31714
Closes WI-31

Azure OpenAI reasoning models reject `max_tokens`:

```
Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.
```

We pick between `max_tokens` and `max_completion_tokens` from the model
name, and that check only knew names up to `gpt-5`, so a `gpt-6-luna`
deployment failed on default settings. To fix, the fantasy bump
(coder/fantasy#86, coder/fantasy#87 and coder/fantasy#88) extends the
check to `gpt-6` through `gpt-9`. That bump is a full sync with
upstream, so it also brings the other chatd changes listed there, which
is why a few test expectations move here.

On Azure that name is the deployment name though, which doesn't have to
say what model it serves. So the model form now also shows the existing
Reasoning Model setting for Azure models, and we obey it. With it on, we
send `max_completion_tokens` and drop `temperature` and `top_p`,
whatever the deployment is called.

I confirmed against a real Azure `gpt-5.4` deployment that it rejects
`max_tokens` and accepts `max_completion_tokens`, but that test resource
has since gone, so I haven't run this exact change against Azure.

This only fixes the `max_tokens` error. Going by [Microsoft's
docs](https://learn.microsoft.com/en-us/azure/foundry/openai/how-to/reasoning),
I think GPT-6 chats on Azure will then hit a second error, as on Chat
Completions those models only accept tools with the reasoning effort set
to `none`, or not at all. The OpenAI and Bedrock providers use the
Responses API, so they aren't affected. I can't reproduce that for the
same reason, so it's being tracked separately at
[CODAGT-1655](https://linear.app/codercom/issue/CODAGT-1655).
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.

1 participant