Files
coder/coderd
Ethan b4d485bdb6 fix: send max_completion_tokens to Azure OpenAI reasoning models (#31952)
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).
2026-12-02 20:37:20 +11:00
..