anomalyco / anomalyco/opencode
Azure GPT-5.4 requests use `max_tokens` on some paths, but the model requires `max_completion_tokens`
Open
@nexxeln is already working on this.
Since Aug 27, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Summary
When using opencode with liteLLM/azure/gpt-5.4, some requests fail with:
litellm.BadRequestError: AzureException BadRequestError - Unsupported parameter:
'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.
Short/simple prompts succeed, but longer / higher-context requests can fail.
## Environment
- opencode-ai version: 1.18.23
- platform: Windows x64
- model: liteLLM/azure/gpt-5.4
## Minimal observation
This succeeds:
opencode run -m "liteLLM/azure/gpt-5.4" --agent build --format json "Reply with
exactly OK"
But longer / higher-context requests can fail with the max_tokens vs
max_completion_tokens error above.
This also occurs outside of mission-driver / wrapper tooling, so it does not
appear to be caused by an external runner.
## Likely cause in source
From the current source tree:
- packages/llm/src/protocols/openai-chat.ts sets:
max_tokens: generation?.maxTokens
- packages/llm/src/protocols/openai-responses.ts sets:
max_output_tokens: generation?.maxTokens
- packages/llm/src/providers/azure.ts appears to choose between different request
routes
So it looks like some Azure GPT-5.4 calls are going through a chat/openai-
compatible path that still emits max_tokens, while this model expects
max_completion_tokens.
## Expected behavior
For Azure GPT-5.4, opencode should avoid sending incompatible max_tokens and
instead use the correct token field for the selected endpoint/model, or route the
request through a compatible path.
## Relevant files
- packages/llm/src/protocols/openai-chat.ts
- packages/llm/src/protocols/openai-compatible-chat.ts
- packages/llm/src/protocols/openai-responses.ts
- packages/llm/src/providers/azure.ts
- packages/llm/src/providers/openai-compatible.ts
### Plugins
_No response_
### OpenCode version
_No response_
### Steps to reproduce
_No response_
### Screenshot and/or share link
_No response_
### Operating System
_No response_
### Terminal
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.