Bug Description
When a user manually switches models via /model command in CLI, the _ensure_runtime_credentials() method unconditionally overwrites self.model with the model field from custom_providers config on every message, ignoring the user's choice.
Root Cause
This is a side effect of PR #7935 which fixed #7828. The fix added this code in cli.py:2736-2738:
runtime_model = runtime.get("model")
if runtime_model and isinstance(runtime_model, str):
self.model = runtime_model
This runs on every _ensure_runtime_credentials() call (before each API request), unconditionally setting the model from custom_providers[].model without checking if:
- User has manually switched models via
/model
- A
model.default config exists with a different model
Steps to Reproduce
- Configure
custom_providers with a model field:
custom_providers:
- name: my-provider
base_url: https://api.example.com/v1
api_key: xxx
model: default-model # This will override manual switches
models:
model-a:
context_length: 128000
model-b:
context_length: 192000
- Start CLI and switch model:
\model model-b --provider custom:my-provider
-
Send a message like "hello"
-
Expected: Model stays as model-b
Actual: Model is overwritten to default-model from custom_providers[].model
Workaround
Remove the model field from custom_providers entries:
custom_providers:
- name: my-provider
base_url: https://api.example.com/v1
api_key: xxx
# model: default-model <-- remove this line
models:
model-a:
context_length: 128000
Suggested Fix
The _ensure_runtime_credentials() method should:
- Check if
self.model is already set from a manual switch or model.default config
- Only use
runtime.get("model") when no model is configured
# Proposed fix: only use custom_providers.model when self.model is not set
runtime_model = runtime.get("model")
if runtime_model and isinstance(runtime_model, str) and not self.model:
self.model = runtime_model
Or compare against config's model.default to determine if user has overridden.
Environment
- Hermes Agent Version: v0.9.0 (2026.4.13)
- Platform: CLI
- Python: 3.11
Related
Bug Description
When a user manually switches models via
/modelcommand in CLI, the_ensure_runtime_credentials()method unconditionally overwritesself.modelwith themodelfield fromcustom_providersconfig on every message, ignoring the user's choice.Root Cause
This is a side effect of PR #7935 which fixed #7828. The fix added this code in
cli.py:2736-2738:This runs on every
_ensure_runtime_credentials()call (before each API request), unconditionally setting the model fromcustom_providers[].modelwithout checking if:/modelmodel.defaultconfig exists with a different modelSteps to Reproduce
custom_providerswith amodelfield:Send a message like "hello"
Expected: Model stays as
model-bActual: Model is overwritten to
default-modelfromcustom_providers[].modelWorkaround
Remove the
modelfield fromcustom_providersentries:Suggested Fix
The
_ensure_runtime_credentials()method should:self.modelis already set from a manual switch ormodel.defaultconfigruntime.get("model")when no model is configuredOr compare against config's
model.defaultto determine if user has overridden.Environment
Related
modelfield propagation