Skip to content

fix(custom-providers): propagate model field from config so API receives the correct model name#7935

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-efa38736
Apr 11, 2026
Merged

fix(custom-providers): propagate model field from config so API receives the correct model name#7935
teknium1 merged 2 commits into
mainfrom
hermes/hermes-efa38736

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Salvage of PR #7916 by @0xFrank-eth. Fixes #7828.

When a custom_providers entry in config.yaml defines a model field that differs from the entry's name, 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 the model field from config entries
  • _resolve_named_custom_runtime() propagates model into its return dict
  • cli.py _ensure_runtime_credentials() overrides self.model when runtime carries a model

Follow-up fixes:

  • Critical: The original fix 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). Fixed by injecting model into pool_result before returning.
  • Added model to _VALID_CUSTOM_PROVIDER_FIELDS in config validation
  • Added 5 regression tests covering: model extraction from config, empty/whitespace model exclusion, direct resolution path, credential pool path, and absent model field

Test plan

  • E2E tested the full resolution chain with real imports (_get_named_custom_provider_resolve_named_custom_runtimeresolve_runtime_provider)
  • Verified model propagates through both direct and pool paths
  • All 65 runtime_provider_resolution tests pass
  • Full hermes_cli test suite: 1657 passed

0xFrank-eth and others added 2 commits April 11, 2026 14:02
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: custom_providers model field not preserved, causing "Model Not Exist" errors

2 participants