fix the auto reset of main model after altered by /model.#14654
Closed
Readon wants to merge 1 commit into
Closed
Conversation
Contributor
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.
What does this PR do?
Fixes an issue where models selected via
/model custom:yyyyare automatically overridden by thedefault_modelfrom the provider configuration.When users configure a custom provider (such as Ollama, vLLM, etc.) with a
default_model, switching to a different model using the/modelcommand would be overridden in the next conversation turn, resetting back to the default model.Root Cause: The
_ensure_runtime_credentials()method incli.pycallsresolve_runtime_provider()at the start of each conversation turn, which retrieves the provider configuration including thedefault_model. The original code unconditionally overwrote the user's model selection with this runtime model, without distinguishing between:Fix: Added conditional logic to only apply the runtime
default_modelwhen:This preserves the user's explicit model selection while maintaining the existing auto-resolution functionality.
Related Issue
Fixes # (fill in if there's a related issue)
Type of Change
Changes Made
cli.py(lines 3149-3158): Modified model override logic in_ensure_runtime_credentials()methodshould_use_runtime_modeldefault_modelwhen model is unset or equals provider name/modelcommandHow to Test
Steps to reproduce the bug (before fix):
llama3.2❌Steps to verify the fix (after fix):
my-ollama:qwen2.5✅Run tests:
pytest tests/hermes_cli/test_user_providers_model_switch.py -v pytest tests/run_agent/test_switch_model_* -vAll tests should pass (20/20).
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — N/A (internal logic fix, no doc updates needed)cli-config.yaml.exampleif I added/changed config keys — N/A (no config changes)CONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/AFor New Skills
N/A (not adding a new skill)
Screenshots / Logs
Before fix:
After fix:
Test output: