Skip to content

fix: match gpt-5 and o-series model names case-insensitively#12138

Open
Igralino wants to merge 2 commits intocontinuedev:mainfrom
Igralino:fix/case-insensitive-gpt5-oseries-regex
Open

fix: match gpt-5 and o-series model names case-insensitively#12138
Igralino wants to merge 2 commits intocontinuedev:mainfrom
Igralino:fix/case-insensitive-gpt5-oseries-regex

Conversation

@Igralino
Copy link
Copy Markdown

@Igralino Igralino commented Apr 14, 2026

Summary

  • isOSeriesOrGpt5PlusModel in core/llm/llms/OpenAI.ts and the equivalent check in packages/openai-adapters/src/apis/OpenAI.ts are case-sensitive, so model names like GPT-5, Gpt-5-mini, or O1 slip past the regex and never get their max_tokens rewritten to max_completion_tokens.
  • In practice this breaks Azure OpenAI deployments, which are commonly named in uppercase (e.g. an Azure deployment literally called GPT-5). The provider then returns 400 Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.
  • Fix: add the i flag to the regexes in isOSeriesOrGpt5PlusModel, and normalize to lower-case before the startsWith("o") / includes("gpt-5") / startsWith("o3") checks in the adapter. Added uppercase/mixed-case test cases.

This mirrors the existing case-insensitive pattern in packages/openai-adapters/src/apis/openaiResponses.ts (/^(?:gpt-5|gpt-5-codex|o[0-9])/i).


Summary by cubic

Make GPT-5 and o‑series model detection case-insensitive. This fixes max_tokensmax_completion_tokens rewriting for uppercase Azure deployments (e.g., GPT-5) and prevents 400 errors.

  • Bug Fixes
    • core/llm/llms/OpenAI.ts: add i flag to o[0-9]+ and gpt-[5-9] regexes.
    • packages/openai-adapters/src/apis/OpenAI.ts: use model.toLowerCase() for startsWith("o"), includes("gpt-5"), and startsWith("o3").
    • Extend unit tests with uppercase/mixed-case models (GPT-5, Gpt-5.4, O1, O3-mini).

Written for commit 0576ec7. Summary will update on new commits.

Azure deployments are frequently named in uppercase (e.g. "GPT-5"),
which failed the previous regex checks and caused Continue to send
max_tokens instead of max_completion_tokens, triggering a 400 from
the provider.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Igralino Igralino requested a review from a team as a code owner April 14, 2026 15:00
@Igralino Igralino requested review from sestinj and removed request for a team April 14, 2026 15:00
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

@Igralino
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant