refactor(aliases): migrate to pattern-based model alias resolution#2843
Open
code-yeongyu wants to merge 1 commit intodevfrom
Open
refactor(aliases): migrate to pattern-based model alias resolution#2843code-yeongyu wants to merge 1 commit intodevfrom
code-yeongyu wants to merge 1 commit intodevfrom
Conversation
Move from hardcoded exact aliases to pattern-based canonicalization:
- Populate PATTERN_ALIAS_RULES with regex patterns for:
- Claude thinking variants (claude-opus-4-6-thinking → claude-opus-4-6)
- Gemini tier suffixes (gemini-3.1-pro-{high,low} → gemini-3.1-pro)
- Add stripProviderPrefixForAliasLookup() for provider-prefixed models
(anthropic/claude-sonnet-4-6 → claude-sonnet-4-6 for capability lookup)
- Preserve requestedModelID (with prefix) for API transport
- Reduce EXACT_ALIAS_RULES to exceptional cases only
(gemini-3-pro-{high,low} → gemini-3-pro-preview)
- Comprehensive test coverage for patterns, prefix stripping, negatives
Addresses Discussion #2835 (pattern matching architecture)
Related to PR #2834 (alias guardrails)
41 targeted tests pass, 4467 full suite tests pass, tsc clean.
There was a problem hiding this comment.
No issues found across 5 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Refactor migrates to pattern-based aliases and handles provider prefixes for lookups. Extensively tested with 41 targeted and 4467 suite tests passing, ensuring no regressions.
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.
Summary
Migrates from hardcoded exact aliases to pattern-based canonicalization, as discussed in #2835.
Changes
src/shared/model-capability-aliases.tsPATTERN_ALIAS_RULESpopulated with regex-based patterns:claude-thinking-legacy-alias:claude-opus-4-6-thinking→claude-opus-4-6gemini-3.1-pro-tier-alias:gemini-3.1-pro-{high,low}→gemini-3.1-prostripProviderPrefixForAliasLookup()added: strips provider prefix (e.g.,anthropic/) for capability lookup while preserving the fullrequestedModelIDfor API transportEXACT_ALIAS_RULESreduced to exceptional cases only (gemini-3-pro-{high,low}→gemini-3-pro-preview)Tests (4 files)
Verification
tsc --noEmitcleanAddresses #2835 | Related to #2834