Skip to content

fix: prefer active provider for anthropic sonnet switches#19950

Draft
aideautomation wants to merge 1 commit into
NousResearch:mainfrom
aideautomation:fix/anthropic-sonnet-provider-detection
Draft

fix: prefer active provider for anthropic sonnet switches#19950
aideautomation wants to merge 1 commit into
NousResearch:mainfrom
aideautomation:fix/anthropic-sonnet-provider-detection

Conversation

@aideautomation

Copy link
Copy Markdown

Summary

Fixes #19858 by preferring the active provider when a requested model can be normalized into one of that provider's native model IDs.

Before this change, ambiguous Claude Sonnet inputs such as claude-sonnet-4.6 or anthropic/claude-sonnet-4.6 could fall through to generic provider detection and get remapped to an aggregator catalog entry instead of staying on the already-active Anthropic provider.

What changed

  • normalize the requested model against the current provider before cross-provider detection
  • if the normalized ID already belongs to the current provider catalog, keep the provider unchanged and reuse the native ID
  • add regression coverage for both:
    • anthropic/claude-sonnet-4.6 while already on anthropic
    • claude-sonnet-4.6 while already on anthropic

Validation

  • scripts/run_tests.sh tests/hermes_cli/test_models.py tests/hermes_cli/test_model_switch_variant_tags.py
  • direct reproduction check:
    • detect_provider_for_model('anthropic/claude-sonnet-4.6', 'anthropic')
    • detect_provider_for_model('claude-sonnet-4.6', 'anthropic')
    • both now resolve to ('anthropic', 'claude-sonnet-4-6')

Notes

This keeps the existing fallback behavior for true cross-provider switches, but stops same-provider Claude inputs from being hijacked by later OpenRouter-style detection.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels May 5, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #19858 (same bug report) and #19904 (competing fix for the gateway side). This PR fixes the CLI/models.py side of the same issue.

1 similar comment
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #19858 (same bug report) and #19904 (competing fix for the gateway side). This PR fixes the CLI/models.py side of the same issue.

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

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model switcher ignores current provider — ambiguous name resolves to OpenRouter instead of active provider

2 participants