fix(custom-providers): propagate model field from config so API receives the correct model name#7935
Merged
Merged
Conversation
…o API receives the correct model name Fixes #7828 When a custom_providers entry carries a `model` field, that value was silently dropped by `_get_named_custom_provider` and `_resolve_named_custom_runtime`. Callers received a runtime dict with `base_url`, `api_key`, and `api_mode` — but no `model`. As a result, `hermes chat --model <provider-name>` sent the *provider name* (e.g. "my-dashscope-provider") as the model string to the API instead of the configured model (e.g. "qwen3.6-plus"), producing: Error code: 400 - {'error': {'message': 'Model Not Exist'}} Setting the provider as the *default* model in config.yaml worked because that path writes `model.default` and the agent reads it back directly, bypassing the broken runtime resolution path. Changes: 1. hermes_cli/runtime_provider.py — _get_named_custom_provider() Reads `entry.get("model")` and includes it in the result dict so the value is available to callers. 2. hermes_cli/runtime_provider.py — _resolve_named_custom_runtime() Propagates `custom_provider["model"]` into the returned runtime dict. 3. cli.py — _ensure_runtime_credentials() After resolving runtime, if `runtime["model"]` is set, assign it to `self.model` so the AIAgent is initialised with the correct model name rather than the provider name the user typed on the CLI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The cherry-picked fix from PR #7916 placed model propagation after the credential pool early-return in _resolve_named_custom_runtime(), making it dead code when a pool is active (which happens whenever custom_providers has an api_key that auto-seeds the pool). - Inject model into pool_result before returning - Add 5 regression tests covering direct path, pool path, empty model, and absent model scenarios - Add 'model' to _VALID_CUSTOM_PROVIDER_FIELDS for config validation
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
Salvage of PR #7916 by @0xFrank-eth. Fixes #7828.
When a
custom_providersentry inconfig.yamldefines amodelfield that differs from the entry'sname, the model string was silently dropped during runtime resolution. The API received the provider name (e.g., "my-dashscope") instead of the actual model name (e.g., "qwen3.6-plus"), causing 400 errors.Changes
Cherry-picked from PR #7916 (contributor: @0xFrank-eth):
_get_named_custom_provider()now reads themodelfield from config entries_resolve_named_custom_runtime()propagates model into its return dictcli.py_ensure_runtime_credentials()overridesself.modelwhen runtime carries a modelFollow-up fixes:
_resolve_named_custom_runtime(), making it dead code when a pool is active (which happens whenevercustom_providershas anapi_keythat auto-seeds the pool). Fixed by injecting model intopool_resultbefore returning.modelto_VALID_CUSTOM_PROVIDER_FIELDSin config validationTest plan
_get_named_custom_provider→_resolve_named_custom_runtime→resolve_runtime_provider)