Skip to content

refactor(aliases): migrate to pattern-based model alias resolution#2843

Open
code-yeongyu wants to merge 1 commit intodevfrom
refactor/model-alias-pattern-matching
Open

refactor(aliases): migrate to pattern-based model alias resolution#2843
code-yeongyu wants to merge 1 commit intodevfrom
refactor/model-alias-pattern-matching

Conversation

@code-yeongyu
Copy link
Owner

Summary

Migrates from hardcoded exact aliases to pattern-based canonicalization, as discussed in #2835.

Changes

src/shared/model-capability-aliases.ts

  • PATTERN_ALIAS_RULES populated with regex-based patterns:
    • claude-thinking-legacy-alias: claude-opus-4-6-thinkingclaude-opus-4-6
    • gemini-3.1-pro-tier-alias: gemini-3.1-pro-{high,low}gemini-3.1-pro
  • stripProviderPrefixForAliasLookup() added: strips provider prefix (e.g., anthropic/) for capability lookup while preserving the full requestedModelID for API transport
  • EXACT_ALIAS_RULES reduced to exceptional cases only (gemini-3-pro-{high,low}gemini-3-pro-preview)

Tests (4 files)

  • Pattern matching coverage (positive + negative cases)
  • Provider prefix stripping
  • Guardrail regression tests updated

Verification

  • 41 targeted tests pass
  • 4467 full suite tests pass
  • tsc --noEmit clean

Addresses #2835 | Related to #2834

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.
Copy link

@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 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant