fix: auto-detect provider when switching models via /model#1177
Closed
virtaava wants to merge 1 commit intoNousResearch:mainfrom
Closed
fix: auto-detect provider when switching models via /model#1177virtaava wants to merge 1 commit intoNousResearch:mainfrom
virtaava wants to merge 1 commit intoNousResearch:mainfrom
Conversation
When a user types `/model deepseek-chat` while on a different provider (e.g. openai-codex), the model name would change but the provider stayed the same, causing silent API errors. Now `detect_provider_for_model()` checks static catalogs to find which provider serves the requested model and auto-switches. Direct providers are preferred over aggregators (nous, openrouter) that list models from many sources. Explicit `provider:model` syntax still takes precedence — auto-detection only runs when no provider prefix is given. Also adds deepseek, google, nvidia, and ollama to the static provider catalogs and aliases.
teknium1
added a commit
that referenced
this pull request
Mar 16, 2026
When typing /model deepseek-chat while on a different provider, the model name now auto-resolves to the correct provider instead of silently staying on the wrong one and causing API errors. Detection priority: 1. Direct provider with credentials (e.g. DEEPSEEK_API_KEY set) 2. OpenRouter catalog match with proper slug remapping 3. Direct provider without creds (clear error beats silent failure) Also adds DeepSeek as a first-class API-key provider — just set DEEPSEEK_API_KEY and /model deepseek-chat routes directly. Bare model names get remapped to proper OpenRouter slugs: /model gpt-5.4 → openai/gpt-5.4 /model claude-opus-4.6 → anthropic/claude-opus-4.6 Salvages the concept from PR #1177 by @virtaava with credential awareness and OpenRouter slug mapping added. Co-authored-by: virtaava <virtaava@users.noreply.github.com>
Contributor
|
Merged via PR #1506. Your auto-detection concept was salvaged onto current main with credential awareness and OpenRouter slug mapping added. DeepSeek was also registered as a first-class provider. Thanks for the idea! |
teknium1
added a commit
that referenced
this pull request
Mar 16, 2026
When typing /model deepseek-chat while on a different provider, the model name now auto-resolves to the correct provider instead of silently staying on the wrong one and causing API errors. Detection priority: 1. Direct provider with credentials (e.g. DEEPSEEK_API_KEY set) 2. OpenRouter catalog match with proper slug remapping 3. Direct provider without creds (clear error beats silent failure) Also adds DeepSeek as a first-class API-key provider — just set DEEPSEEK_API_KEY and /model deepseek-chat routes directly. Bare model names get remapped to proper OpenRouter slugs: /model gpt-5.4 → openai/gpt-5.4 /model claude-opus-4.6 → anthropic/claude-opus-4.6 Salvages the concept from PR #1177 by @virtaava with credential awareness and OpenRouter slug mapping added. Co-authored-by: virtaava <virtaava@users.noreply.github.com>
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
The
/modelslash command currently requires explicitprovider:modelsyntax to switch providers (e.g.,/model deepseek:deepseek-chat). If the user types just/model deepseek-chatwhile on a different provider (e.g.,openai-codex), the model name changes but the provider stays the same — causing silent API errors because the old provider doesn't serve that model.This PR adds
detect_provider_for_model()which checks static provider catalogs (no network calls) to find which provider serves the requested model and auto-switches. Direct providers are preferred over aggregators (nous,openrouter) that list models from many sources.Changes:
hermes_cli/models.py— Adddetect_provider_for_model()function; adddeepseek,google,nvidia,ollamato static provider catalogs and aliasesgateway/run.py— Call auto-detection afterparse_model_input()in_handle_model_command()cli.py— Same auto-detection in the CLI's/modelhandlertests/hermes_cli/test_models.py— 5 tests covering direct match, aggregator deprioritization, current-provider skip, OpenRouter fallback, and unknown modelsBackward-compatible: Explicit
provider:modelsyntax still takes precedence — auto-detection only runs when no provider prefix is given.Test plan
python -m pytest tests/hermes_cli/test_models.py -x -q— all 15 tests pass/model deepseek-chatfromopenai-codexprovider auto-switches todeepseek/model deepseek:deepseek-chatstill works as before (explicit syntax)/model gpt-5.2-codexwhile onopenai-codexdoes NOT trigger auto-switch🤖 Generated with Claude Code