Fix token param handling for official GPT-5 model IDs#950
Conversation
Apply max_completion_tokens only to official GPT-5 model IDs. Keep provider-prefixed names such as openai/gpt-5.2 on the max_tokens path so namespaced model IDs are not treated as official OpenAI GPT-5 identifiers.
Review Summary by QodoFix token parameter handling for official GPT-5 model IDs
WalkthroughsDescription• Fix regex pattern to match only official GPT-5 model IDs • Exclude provider-prefixed models like openai/gpt-5.2 from max_completion_tokens • Update test expectations to reflect corrected token parameter handling Diagramflowchart LR
A["Model ID Pattern"] -->|Official GPT-5| B["max_completion_tokens"]
A -->|Provider-prefixed| C["max_tokens"]
D["Regex: /^gpt-5([.-]|$)/"] -->|Matches| B
E["openai/gpt-5.2"] -->|Excluded| C
File Changes1. src/services/apis/openai-token-params.mjs
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewⓘ The new review experience is currently in Beta. Learn more |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the token parameter handling for OpenAI models, specifically addressing how 'max_completion_tokens' and 'max_tokens' are applied based on model identification. The changes ensure that only official GPT-5 model IDs trigger the 'max_completion_tokens' logic, while provider-prefixed model names correctly fall back to using 'max_tokens', preventing unintended behavior with third-party model variations. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe GPT-5 model pattern matching logic in the OpenAI token parameters service was narrowed to require strings starting with "gpt-5" instead of matching any position. The corresponding test was updated to reflect this stricter matching behavior. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request refines the logic for identifying official GPT-5 model IDs by adjusting the regular expression. The change correctly ensures that only model IDs that start with gpt-5 are matched, excluding namespaced IDs like openai/gpt-5.2. The test suite has been updated accordingly to verify the new behavior. The implementation is sound and effectively achieves the stated goal.
There was a problem hiding this comment.
Pull request overview
Updates OpenAI chat-completions token-limit parameter selection so max_completion_tokens is only used for official (non-namespaced) GPT‑5 model IDs, keeping provider-prefixed model names (e.g. openai/gpt-5.2) on the max_tokens path.
Changes:
- Tighten GPT‑5 model matching to only model IDs starting with
gpt-5(no provider prefix). - Update unit test coverage/expectations for provider-prefixed GPT‑5 model names to use
max_tokens.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/services/apis/openai-token-params.mjs |
Adjusts the GPT‑5 model regex so provider-prefixed model IDs no longer trigger max_completion_tokens. |
tests/unit/services/apis/openai-token-params.test.mjs |
Updates the provider-prefixed GPT‑5 test to expect max_tokens instead of max_completion_tokens. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
cc #922 |
Apply max_completion_tokens only to official GPT-5 model IDs.
Keep provider-prefixed names such as openai/gpt-5.2 on the max_tokens path so namespaced model IDs are not treated as official OpenAI GPT-5 identifiers.
Summary by CodeRabbit
Bug Fixes