fix(aiCore): normalize model ID before looking up thinking token limits#13843
Merged
fix(aiCore): normalize model ID before looking up thinking token limits#13843
Conversation
findTokenLimit() was called with the raw model.id instead of the normalized (lowercased, base-name) variant, causing token limit lookups to miss for models whose IDs contain provider prefixes or mixed casing. Fixes #13831 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: icarus <[email protected]>
6 tasks
alephpiece
approved these changes
Mar 27, 2026
DeJeune
approved these changes
Mar 27, 2026
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.
What this PR does
Before this PR:
findTokenLimit()ingetReasoningEffort()was called with the rawmodel.id, which may contain provider prefixes or mixed casing (e.g.,openai/qwen3.5-397b-a17b). This caused token limit lookups to fail, soeffortwas never correctly converted tothinking_budgetfor generic (OpenAI-compatible) providers.After this PR:
The model ID is normalized via
getLowerBaseModelName()before being passed tofindTokenLimit(), ensuring correct token limit resolution and propereffort → thinking_budgetconversion.Fixes #13831
Why we need it and why it was done in this way
The following tradeoffs were made:
The normalization is applied early in
getReasoningEffort()and reuses the existinggetLowerBaseModelName()utility, which is already used elsewhere in the same file. This is the minimal, consistent fix.The following alternatives were considered:
findTokenLimit()itself to normalize internally — rejected because it would change the contract for all callers, some of which may already pass normalized IDs.Breaking changes
None.
Special notes for your reviewer
While this fix correctly resolves the token limit lookup, there is a known follow-up concern: for some models (e.g., Qwen3.5), even a correctly computed low
thinking_budgetcan paradoxically cause more thinking than not passing the parameter at all. See the linked issue discussion for details. See #13844 for tracking improvements to the effort mapping strategy.Checklist
/gh-pr-review,gh pr diff, or GitHub UI) before requesting review from othersRelease note