fix: route slash-based custom provider models correctly - #189
Conversation
7fdf34a to
32f82e6
Compare
|
Thanks for digging into this and sending a fix! The root cause is real and the fix is correct. What the bug isWhen Fix assessmentThe fix inserts a custom-providers lookup before the slash-heuristic block, so named entries in # Custom providers declared in config.yaml should win over slash-based
# OpenRouter heuristics. Their model IDs commonly contain '/' too.
custom_providers = cfg.get('custom_providers', [])
if isinstance(custom_providers, list):
for entry in custom_providers:
...
if entry_model and entry_name and model_id == entry_model:
provider_hint = 'custom:' + entry_name.lower().replace(' ', '-')
return model_id, provider_hint, entry_base_url or None
One minor note: the No blockersClean fix, well-tested. Glad you confirmed it solved the problem against a real LM Studio + |
nesquena
left a comment
There was a problem hiding this comment.
Full Review: PR #189 — custom provider slash model routing
Thanks @smurmann for finding and fixing this! Real bug — slash-containing model IDs from custom providers (like google/gemma-4-26b-a4b) were being misrouted as OpenRouter models.
Security Audit
Clean. Python-only changes to model routing logic. No external resources, no injection vectors, no XSS.
Code Review
The fix is correct — custom_providers entries from config.yaml are checked for exact model match before the slash-based OpenRouter heuristic kicks in. This prevents models like google/gemma-4-26b-a4b from being sent to OpenRouter when they belong to a local LM Studio endpoint.
The custom:<name> provider hint format is a reasonable convention for routing through named custom endpoints. The test covers the key scenario well.
One minor note: If custom_providers grows large, the linear scan per model resolution could be slow. For now this is fine — most users have 0-3 custom providers.
Agent Review Verification
Agent approved, no fixes needed. Confirmed — the code matches the agent's description.
Tests
507 passed, 0 failed, 41 skipped. No regressions. New test test_custom_provider_model_with_slash_routes_to_named_custom_provider is well-structured.
Merge Order Note
This PR and #191 both touch api/config.py and test_model_resolver.py. They modify different functions (this one: resolve_model_provider(), #191: get_available_models()), but the test file may need a trivial rebase after whichever merges first.
Verdict
Approved. Ready to merge.
|
Rebased cleanly onto current master (post v0.41.0). All 15 model resolver tests pass including the new regression test for the slash-routing fix. The fix is correct: custom provider entries in |
|
Thank you, @smurmann! Custom provider model routing fix is live and working. That slash-heuristic was a real footgun for anyone running Ollama or LM Studio with multi-segment model IDs. You're in the Contributors section — thank you! |
Co-authored-by: smurmann <smurmann@users.noreply.github.com>
Co-authored-by: smurmann <smurmann@users.noreply.github.com>
I faced an issue where using a gamma4 through lmstudio on mac via hermes cli chat was fine but through the web UI had issues. I asked my AI to provide a fix for it and this is the PR for it. I'm no expert of this tech stack but I can confirm that the fix worked, so i figured to make a PR.
Here's the AI's report