Skip to content

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

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-3c0e357d
Mar 24, 2026
Merged

fix(auth): preserve 'custom' provider instead of silently remapping to 'openrouter'#2792
teknium1 merged 1 commit intomainfrom
hermes/hermes-3c0e357d

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

Fixes #2562. resolve_provider('custom') was silently returning 'openrouter', causing users who set provider: custom in config.yaml to unknowingly route through OpenRouter instead of their local/custom endpoint.

This is Phase 1 of the /model command overhaul plan.

What changed

  • hermes_cli/auth.py: Split the {"openrouter", "custom"} set check into two separate conditionals so 'custom' returns 'custom' as-is
  • hermes_cli/runtime_provider.py:
    • _resolve_named_custom_runtime() now returns provider='custom' instead of 'openrouter'
    • _resolve_openrouter_runtime() returns provider='custom' when that was explicitly requested
    • Adds 'no-key-required' placeholder API key for local servers that don't need authentication (OpenAI SDK requires non-empty string)
  • Tests: Updated 1 existing test + added 5 new tests covering the fix

Why this is safe

All OpenRouter-specific logic in run_agent.py checks by URL ("openrouter" in base_url), not by provider name. Custom endpoints hitting non-OpenRouter URLs won't match any OpenRouter-specific behavior.

Salvaged from

Closes #2562. Four external PRs attempted this fix (#2564, #2571, #2633, #2725) — all submitted the same auth.py change but none added the runtime_provider.py fixes or the no-key-required fallback for local servers. Credit to @davidmacmillan for the original report, @aifunmobi for the root cause analysis, and @teyrebaz33, @dusterbloom, @amethystani for their fix attempts.

Test plan

  • python -m pytest tests/test_runtime_provider_resolution.py -q — 36/36 pass
  • Full suite: 6086 passed, 0 failures

…o 'openrouter'

resolve_provider('custom') was silently returning 'openrouter', causing
users who set provider: custom in config.yaml to unknowingly route
through OpenRouter instead of their local/custom endpoint. The display
showed 'via openrouter' even when the user explicitly chose custom.

Changes:
- auth.py: Split the conditional so 'custom' returns 'custom' as-is
- runtime_provider.py: _resolve_named_custom_runtime now returns
  provider='custom' instead of 'openrouter'
- runtime_provider.py: _resolve_openrouter_runtime returns
  provider='custom' when that was explicitly requested
- Add 'no-key-required' placeholder for keyless local servers
- Update existing test + add 5 new tests covering the fix

Fixes #2562
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'

1 participant