Skip to content

feat: auto-detect provider when switching models via /model#1506

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-84930008
Mar 16, 2026
Merged

feat: auto-detect provider when switching models via /model#1506
teknium1 merged 1 commit into
mainfrom
hermes/hermes-84930008

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Fixes the confusing /model experience where typing /model deepseek-chat while on a different provider would silently keep the wrong provider, causing API errors.

Salvages the concept from PR #1177 by @virtaava, with credential awareness and OpenRouter slug mapping added.

What changed

Auto-detection in /model (cli.py + gateway/run.py):

  • When no explicit provider:model syntax is given, detect_provider_for_model() finds the right provider
  • Priority: direct provider with creds → OpenRouter slug match → direct provider without creds
  • Bare model names get remapped to proper OpenRouter slugs (gpt-5.4openai/gpt-5.4)

DeepSeek as first-class provider (auth.py + config.py + models.py):

  • Registered in PROVIDER_REGISTRY as an API-key provider
  • DEEPSEEK_API_KEY env var, base URL https://api.deepseek.com/v1
  • Static catalog: deepseek-chat, deepseek-reasoner
  • Works through the existing generic API-key credential resolution path — no changes to runtime_provider.py needed

New functions in models.py:

  • detect_provider_for_model(model, current_provider)(provider, model) or None
  • _find_openrouter_slug(bare_name) → full OpenRouter model ID

Examples

# Before: silently stays on openai-codex, API error
/model deepseek-chat

# After: auto-switches to deepseek provider (if DEEPSEEK_API_KEY set)
# or remaps to deepseek/deepseek-chat on OpenRouter
/model deepseek-chat

# Bare names get proper slugs
/model gpt-5.4        → openai/gpt-5.4
/model claude-opus-4.6 → anthropic/claude-opus-4.6

# Explicit syntax still works as before
/model anthropic:claude-opus-4-6

Tests

  • 11 new tests for detect_provider_for_model and _find_openrouter_slug
  • Updated existing tests for new behavior
  • Full suite: 4548 passed, 0 regressions

Closes #1177 (concept salvaged with improvements)

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>
@teknium1 teknium1 merged commit c1da1fd into main Mar 16, 2026
1 check passed
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…arch#1506)

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 NousResearch#1177 by @virtaava with credential
awareness and OpenRouter slug mapping added.

Co-authored-by: virtaava <virtaava@users.noreply.github.com>
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…arch#1506)

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 NousResearch#1177 by @virtaava with credential
awareness and OpenRouter slug mapping added.

Co-authored-by: virtaava <virtaava@users.noreply.github.com>
olympus-terminal pushed a commit to olympus-terminal/hermes-agent that referenced this pull request May 16, 2026
…arch#1506)

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 NousResearch#1177 by @virtaava with credential
awareness and OpenRouter slug mapping added.

Co-authored-by: virtaava <virtaava@users.noreply.github.com>
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
…arch#1506)

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 NousResearch#1177 by @virtaava with credential
awareness and OpenRouter slug mapping added.

Co-authored-by: virtaava <virtaava@users.noreply.github.com>
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