hermes - 💡(How to fix) Fix feat: use provider models config as whitelist in /model picker for custom providers [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#18726Fetched 2026-05-03 04:54:40
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×4

Root Cause

In hermes_cli/main.py, _model_flow_named_custom() (line ~3284) unconditionally calls fetch_api_models(api_key, base_url) regardless of whether the provider has a configured models whitelist. The models field from config is preserved in the provider_info dict but never used for filtering.

Code Example

providers:
  baidu:
    base_url: https://qianfan.baidubce.com/v2/coding
    key_env: BAIDU_CODING_API_KEY
    models:
    - kimi-k2.5
    - glm-5

---

configured_models = provider_info.get("models", {})
if isinstance(configured_models, dict) and configured_models:
    models = list(configured_models.keys())
elif isinstance(configured_models, list) and configured_models:
    models = [str(m) for m in configured_models if isinstance(m, str) and m.strip()]
else:
    # No configured models — fetch from API (existing behavior)
    models = fetch_api_models(api_key, base_url, ...)
RAW_BUFFERClick to expand / collapse

Problem

When a custom provider (via providers: in config.yaml) exposes an OpenAI-compatible /v1/models endpoint, the /model picker always fetches ALL models from the API, ignoring the models field in the provider config.

This is particularly problematic for platforms like Baidu Qianfan Coding Plan, where the API returns 100+ models (ERNIE series, open-source LLMs, image models, embedding models, etc.) even though the user only has access to 2-3 models in their plan.

Example config:

providers:
  baidu:
    base_url: https://qianfan.baidubce.com/v2/coding
    key_env: BAIDU_CODING_API_KEY
    models:
    - kimi-k2.5
    - glm-5

Expected behavior:

/model → select Baidu → shows 2 models (kimi-k2.5, glm-5)

Actual behavior:

/model → select Baidu → shows 100+ models from the full Qianfan catalog

Root Cause

In hermes_cli/main.py, _model_flow_named_custom() (line ~3284) unconditionally calls fetch_api_models(api_key, base_url) regardless of whether the provider has a configured models whitelist. The models field from config is preserved in the provider_info dict but never used for filtering.

Proposed Fix

Modify _model_flow_named_custom() to check for configured models first:

configured_models = provider_info.get("models", {})
if isinstance(configured_models, dict) and configured_models:
    models = list(configured_models.keys())
elif isinstance(configured_models, list) and configured_models:
    models = [str(m) for m in configured_models if isinstance(m, str) and m.strip()]
else:
    # No configured models — fetch from API (existing behavior)
    models = fetch_api_models(api_key, base_url, ...)

This requires also passing the models field through _named_custom_provider_map().

Additionally: when multiple providers expose the same model name (e.g., both Baidu and Alibaba have kimi-k2.5), the /model picker currently shows them without provider context, which can cause confusion. Consider adding provider disambiguation hints.

Environment

  • Hermes Agent version: latest (git-installed)
  • OS: macOS (Apple Silicon)
  • Provider: Baidu Qianfan Coding Plan, Alibaba Bailian Coding Plan

extent analysis

TL;DR

Modify the _model_flow_named_custom() function to check for configured models before fetching from the API to fix the issue of the /model picker showing all models instead of the whitelisted ones.

Guidance

  • Update the _model_flow_named_custom() function to prioritize configured models over API-fetched models.
  • Pass the models field through _named_custom_provider_map() to ensure it's available for filtering.
  • Consider adding provider disambiguation hints to avoid confusion when multiple providers expose the same model name.
  • Verify the fix by checking the /model picker after updating the code to ensure it only shows the whitelisted models.

Example

configured_models = provider_info.get("models", {})
if isinstance(configured_models, list) and configured_models:
    models = [str(m) for m in configured_models if isinstance(m, str) and m.strip()]
else:
    models = fetch_api_models(api_key, base_url, ...)

Notes

This fix assumes that the models field in the provider config is correctly formatted and contains the desired model names. Additional error handling may be necessary to handle cases where the models field is missing or malformed.

Recommendation

Apply the proposed fix to modify the _model_flow_named_custom() function, as it directly addresses the issue and provides a clear solution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix feat: use provider models config as whitelist in /model picker for custom providers [1 participants]