fix: auto-detect GPT-5/o-series Azure deployments for max_completion_tokens - #651
Open
mathurshubham wants to merge 1 commit into
Open
fix: auto-detect GPT-5/o-series Azure deployments for max_completion_tokens#651mathurshubham wants to merge 1 commit into
mathurshubham wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #610
Closes #589
Problem
Azure OpenAI GPT-5.x / o-series chat requests failed with:
...unless the user manually set the Azure model family to
gpt5. The family defaults toauto, butautoonly 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 andmax_tokenswas sent unchanged.Fix
On the Azure
autopath, infer the family from the deployment name with a boundary-aware match anywhere in the string (also accepting the dashlessgpt5spelling). The explicitgpt5override 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 tomax_completion_tokens, plus a negativegpt-4o-chatcase that keepsmax_tokens.src/lib/llm-providers.test.ts+src/lib/__tests__/llm-providers.test.ts: 123 passingtsc --build: clean