fix(model): preserve custom endpoint credentials during /model switch#15088
Closed
kshitijk4poor wants to merge 1 commit into
Closed
fix(model): preserve custom endpoint credentials during /model switch#15088kshitijk4poor wants to merge 1 commit into
kshitijk4poor wants to merge 1 commit into
Conversation
48e798e to
5aad06c
Compare
9e32855 to
ca8df75
Compare
19 tasks
ca8df75 to
3d0171a
Compare
…els not in /v1/models When switching models on a custom endpoint (ollama-launch): - Same-provider switches no longer re-resolve credentials (fixes base_url being lost for 'custom' provider on subsequent switches) - Named providers (ollama-launch) are resolved via user_providers so switch_model can find their base_url from config - Models not in the /v1/models probe but present in the user's saved provider config are accepted with a warning instead of rejected - CLI /model and TUI /model both pass user_providers/custom_providers to switch_model so the config model list is available for validation Closes #15088
3d0171a to
0d3d2a2
Compare
teknium1
pushed a commit
that referenced
this pull request
Apr 26, 2026
…els not in /v1/models When switching models on a custom endpoint (ollama-launch): - Same-provider switches no longer re-resolve credentials (fixes base_url being lost for 'custom' provider on subsequent switches) - Named providers (ollama-launch) are resolved via user_providers so switch_model can find their base_url from config - Models not in the /v1/models probe but present in the user's saved provider config are accepted with a warning instead of rejected - CLI /model and TUI /model both pass user_providers/custom_providers to switch_model so the config model list is available for validation Closes #15088
Contributor
|
Merged via #15826 with your authorship preserved via cherry-pick. Thanks @kshitijk4poor — solid diagnosis and fix. Complements #15823 (Gille's |
ulasbilgen
pushed a commit
to ulasbilgen/hermes-adhd-agent
that referenced
this pull request
May 1, 2026
…els not in /v1/models When switching models on a custom endpoint (ollama-launch): - Same-provider switches no longer re-resolve credentials (fixes base_url being lost for 'custom' provider on subsequent switches) - Named providers (ollama-launch) are resolved via user_providers so switch_model can find their base_url from config - Models not in the /v1/models probe but present in the user's saved provider config are accepted with a warning instead of rejected - CLI /model and TUI /model both pass user_providers/custom_providers to switch_model so the config model list is available for validation Closes NousResearch#15088
donald131
pushed a commit
to donald131/hermes-agent
that referenced
this pull request
May 2, 2026
…els not in /v1/models When switching models on a custom endpoint (ollama-launch): - Same-provider switches no longer re-resolve credentials (fixes base_url being lost for 'custom' provider on subsequent switches) - Named providers (ollama-launch) are resolved via user_providers so switch_model can find their base_url from config - Models not in the /v1/models probe but present in the user's saved provider config are accepted with a warning instead of rejected - CLI /model and TUI /model both pass user_providers/custom_providers to switch_model so the config model list is available for validation Closes NousResearch#15088
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
…els not in /v1/models When switching models on a custom endpoint (ollama-launch): - Same-provider switches no longer re-resolve credentials (fixes base_url being lost for 'custom' provider on subsequent switches) - Named providers (ollama-launch) are resolved via user_providers so switch_model can find their base_url from config - Models not in the /v1/models probe but present in the user's saved provider config are accepted with a warning instead of rejected - CLI /model and TUI /model both pass user_providers/custom_providers to switch_model so the config model list is available for validation Closes NousResearch#15088
dannyJ848
pushed a commit
to dannyJ848/hermes-agent
that referenced
this pull request
May 17, 2026
…els not in /v1/models When switching models on a custom endpoint (ollama-launch): - Same-provider switches no longer re-resolve credentials (fixes base_url being lost for 'custom' provider on subsequent switches) - Named providers (ollama-launch) are resolved via user_providers so switch_model can find their base_url from config - Models not in the /v1/models probe but present in the user's saved provider config are accepted with a warning instead of rejected - CLI /model and TUI /model both pass user_providers/custom_providers to switch_model so the config model list is available for validation Closes NousResearch#15088
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
…els not in /v1/models When switching models on a custom endpoint (ollama-launch): - Same-provider switches no longer re-resolve credentials (fixes base_url being lost for 'custom' provider on subsequent switches) - Named providers (ollama-launch) are resolved via user_providers so switch_model can find their base_url from config - Models not in the /v1/models probe but present in the user's saved provider config are accepted with a warning instead of rejected - CLI /model and TUI /model both pass user_providers/custom_providers to switch_model so the config model list is available for validation Closes NousResearch#15088
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
…els not in /v1/models When switching models on a custom endpoint (ollama-launch): - Same-provider switches no longer re-resolve credentials (fixes base_url being lost for 'custom' provider on subsequent switches) - Named providers (ollama-launch) are resolved via user_providers so switch_model can find their base_url from config - Models not in the /v1/models probe but present in the user's saved provider config are accepted with a warning instead of rejected - CLI /model and TUI /model both pass user_providers/custom_providers to switch_model so the config model list is available for validation Closes NousResearch#15088
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
/model <name>on custom/local endpoints (ollama-launch, lmstudio, vllm, LAN servers, Docker hostnames, etc.) silently probes OpenRouter instead of the local server, causing model switches to fail.Before: User on Ollama types
/model glm-5:cloud→ error says model not found onhttps://openrouter.ai/api/v1/modelsAfter:
/model glm-5:cloud→ validates against the local endpoint → model switch succeedsRoot Cause
Named custom providers (config
providers: { ollama-launch: { ... } }) resolve through_resolve_named_custom_runtime()which returnsprovider: "custom". Whenswitch_model()later re-resolves credentials for the same provider,resolve_runtime_provider(requested="custom")can't find the original endpoint and falls through to OpenRouter. Validation then probes OpenRouter's model list instead of the local server.Fix
When switching models on the same provider (no
--providerflag), the existingapi_keyandbase_urlfrom the live agent are already correct. Re-resolution is still attempted for credential rotation and provider-specific URL adjustments (e.g. OpenCode strips/v1for Anthropic models). But if re-resolution returns a different base_url for a"custom"/"local"provider, that signals a fallthrough — the caller's known-good credentials are preserved instead.Not hardcoded to Ollama/localhost. The guard uses behavioral detection (base_url mismatch on re-resolution for custom providers), not URL pattern matching. Works for:
127.0.0.1:11434)192.168.x.x:8080)http://ollama:11434)https://my-gpu-server:8080)[::1]:11434)Known providers (OpenRouter, OpenCode, Copilot, etc.) still re-resolve normally.
Verified
ollama launch hermes→/model gemma3:4b→"✓ Model switched: gemma3:4b, Provider: ollama-launch"