Skip to content

fix(auth): preserve 'custom' provider name instead of silently remapping to 'openrouter'#2564

Closed
dieutx wants to merge 1 commit into
NousResearch:mainfrom
dieutx:fix/preserve-custom-provider-name
Closed

fix(auth): preserve 'custom' provider name instead of silently remapping to 'openrouter'#2564
dieutx wants to merge 1 commit into
NousResearch:mainfrom
dieutx:fix/preserve-custom-provider-name

Conversation

@dieutx

@dieutx dieutx commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Summary

When a user sets provider: custom in config.yaml, resolve_provider() silently converts it to "openrouter" (line 666 in auth.py). This causes:

  • /model shows "via openrouter" instead of "via custom"
  • The provider name gets overwritten in the user's mental model and potentially in config
  • No notice is given to the user about the remapping

Root cause: resolve_provider() treated "custom" and "openrouter" identically:

if normalized in {"openrouter", "custom"}:
    return "openrouter"

Fix:

  • Return "custom" from resolve_provider() when explicitly requested
  • Preserve "custom" in the runtime provider dict returned by resolve_runtime_provider()
  • The OpenRouter runtime code path still handles the actual HTTP calls — it already had full custom base_url support (line 235 in runtime_provider.py)

Closes #2562

Changes

 hermes_cli/auth.py                        |  4 +-   (split the set check)
 hermes_cli/runtime_provider.py            |  6 +++  (preserve provider name)
 tests/test_runtime_provider_resolution.py | 82 +++ (5 new tests)

Test plan

  • Verified bug exists on current main: resolve_provider("custom") returns "openrouter"
  • Verified no existing PRs address [Bug]: 'custom' provider gets switched to 'openrouter' #2562
  • After fix: resolve_provider("custom") returns "custom"
  • After fix: resolve_runtime_provider(requested="custom") returns provider: "custom" with correct base_url
  • resolve_provider("openrouter") still returns "openrouter" (no regression)
  • 5 new tests: 2 for resolve_provider(), 3 for resolve_runtime_provider() custom flow
  • All 34 tests in test_runtime_provider_resolution.py pass
  • Run full test suite: pytest tests/ -x -q

@dieutx dieutx force-pushed the fix/preserve-custom-provider-name branch from 3040014 to 7504093 Compare March 23, 2026 05:11
@francip

francip commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

A more extensive fix for custom models support in #2580

@dieutx

dieutx commented Mar 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! Checked #2580 — nice work on the /model display side.

This PR is a different layer though — it's the auth.py resolve_provider() that silently swaps "custom" to "openrouter" under the hood. #2580 doesn't touch that file.

They should work together fine — one fixes how custom providers show up, this one stops them from being renamed internally.

…ing to 'openrouter'

resolve_provider() mapped 'custom' to 'openrouter' on line 666, causing
the /model command to display 'openrouter' and overwriting the user's
config.yaml provider setting.  This was confusing for users with local
models who explicitly set provider: custom.

- Return 'custom' from resolve_provider() when explicitly requested
- Preserve 'custom' in the runtime provider dict so display and config
  stay consistent with what the user configured
- The OpenRouter runtime code path still handles the actual HTTP calls
  (it already had custom base_url support)

Adds 5 regression tests covering both resolve_provider() and the full
resolve_runtime_provider() chain for custom providers.

Closes NousResearch#2562
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #2792 which fixes #2562 comprehensively (auth.py + runtime_provider.py + no-key-required fallback for local servers + tests). Your fix attempt is appreciated — thank you for the contribution!

@teknium1 teknium1 closed this Mar 24, 2026
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.

[Bug]: 'custom' provider gets switched to 'openrouter'

3 participants