Skip to content

fix: auto-detect GPT-5/o-series Azure deployments for max_completion_tokens - #651

Open
mathurshubham wants to merge 1 commit into
nashsu:mainfrom
mathurshubham:fix/azure-auto-max-completion-tokens
Open

fix: auto-detect GPT-5/o-series Azure deployments for max_completion_tokens#651
mathurshubham wants to merge 1 commit into
nashsu:mainfrom
mathurshubham:fix/azure-auto-max-completion-tokens

Conversation

@mathurshubham

Copy link
Copy Markdown

Fixes #610
Closes #589

Problem

Azure OpenAI GPT-5.x / o-series chat requests failed with:

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

...unless the user manually set the Azure model family to gpt5. The family defaults to auto, but auto only matched a GPT-5/o-series prefix on the deployment name. Azure deployment names are user-chosen and frequently don't start with the model id (e.g. prod-gpt5, my-gpt-5-chat, o3-reasoning), so detection silently fell through and max_tokens was sent unchanged.

Fix

On the Azure auto path, infer the family from the deployment name with a boundary-aware match anywhere in the string (also accepting the dashless gpt5 spelling). The explicit gpt5 override and the canonical-OpenAI prefix match are unchanged, so non-Azure routes keep their existing behavior.

Tests

Added tests for opaque Azure deployment names (my-gpt-5-chat, prod-gpt5, o3-reasoning) mapping to max_completion_tokens, plus a negative gpt-4o-chat case that keeps max_tokens.

  • src/lib/llm-providers.test.ts + src/lib/__tests__/llm-providers.test.ts: 123 passing
  • tsc --build: clean

…tokens

Azure OpenAI GPT-5.x and o-series chat requests failed with
"'max_tokens' is not supported with this model. Use
'max_completion_tokens' instead." unless the user manually set the Azure
model family to "gpt5".

The family defaults to "auto", but "auto" only matched a GPT-5/o-series
prefix on the deployment name. Azure deployment names are user-chosen
and frequently don't start with the model id (e.g. "prod-gpt5",
"my-gpt-5-chat", "o3-reasoning"), so detection silently fell through and
max_tokens was sent unchanged.

On the Azure auto path, infer the family from the deployment name with a
boundary-aware match anywhere in the string (also accepting the dashless
"gpt5" spelling). The explicit "gpt5" override and the canonical-OpenAI
prefix match are unchanged, so non-Azure routes keep their behavior.

Fixes nashsu#610
Closes nashsu#589
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant