fix(models): merge live API results with curated static catalog in generic provider path - #46857
Conversation
|
Looking forward to have this fix merged. |
|
Thanks for tackling #46850 — the live+curated merge in One gap I can still reproduce on this PR branch: direct model switching still fails because Minimal repro with the live Z.AI listing simulated as from unittest.mock import patch
from hermes_cli.models import validate_requested_model
from hermes_cli.model_switch import switch_model
live = ['glm-5.1', 'glm-5']
with patch('hermes_cli.models.fetch_api_models', return_value=live):
validate_requested_model(
'glm-5.2',
'zai',
api_key='dummy',
base_url='https://api.z.ai/api/coding/paas/v4',
)
# => {'accepted': False, 'persist': False, ...}
with patch('hermes_cli.models.fetch_api_models', return_value=live):
switch_model(
'glm-5.2',
current_provider='zai',
current_model='glm-5.1',
current_base_url='https://api.z.ai/api/coding/paas/v4',
current_api_key='dummy',
explicit_provider='zai',
)
# => success=False, "Model `glm-5.2` was not found..."So this PR appears to fix visibility in the picker/listing path, but A small follow-up in |
…neric provider path When a provider's live /v1/models endpoint returns a stale or incomplete list (e.g. Z.AI missing glm-5.2), the generic profile-based code path returned only the live results, silently dropping curated models. Generalize the kimi-coding merge pattern to all providers: live entries come first (provider's preferred order), then curated-only entries are appended with case-insensitive dedup. This ensures models that the live endpoint omits still appear in /model picker. Fixes NousResearch#46850
…hen live API omits model When live /v1/models responds but omits a model that exists in the curated static catalog, validate_requested_model now accepts it with a note instead of rejecting. This covers the /model slash-command path (the picker path was already fixed in the parent commit). Addresses review feedback from potatogim on NousResearch#46857.
2e020cb to
ee7b8a4
Compare
|
Thanks for the detailed repro, @potatogim. You're right — Fixed in the latest commit: when the live Three regression tests added covering:
|
…ure-catalog helper in validation The generic live+curated merge (commit 630b438) seeded the merged list from live results, demoting curated-only models below live ones. That regressed NousResearch#46309, which deliberately surfaces the newest curated model (kimi-k2.7-code) FIRST in the native picker even when the live /models listing lags. Restore curated-first ordering: curated entries lead (in catalog order), live-only entries are appended for discovery. This keeps the NousResearch#46850 fix (zai glm-5.2 now appears) without the kimi regression. Also switch the validate_requested_model curated fallback (commit ee7b8a4) from provider_model_ids() — which triggers a second, uncached live /models fetch with its own 8s timeout and may resolve different credentials than the api_key/base_url just probed — to the pure-catalog helper _model_in_provider_catalog(). Membership is checked against the shipped catalog only, with no extra network call. Tests: restore the curated-first assertion in test_kimi_coding_live_catalog_does_not_hide_curated_k2_7_code; update the new merge tests to curated-first semantics; de-circularize the validation fallback tests to patch _PROVIDER_MODELS (the real source) instead of mocking the function under test.
|
Thanks for this — the live+curated merge is the right fix for #46850, and generalizing it past the kimi-only special case is a good call. I pushed one follow-up commit ( Restored curated-first ordering. The merge seeded the list from Validation fallback uses the pure-catalog helper. The Tests: restored the original curated-first assertion in Verified locally: 102 tests pass; zai surfaces |
…hen live API omits model When live /v1/models responds but omits a model that exists in the curated static catalog, validate_requested_model now accepts it with a note instead of rejecting. This covers the /model slash-command path (the picker path was already fixed in the parent commit). Addresses review feedback from potatogim on NousResearch#46857.
…hen live API omits model When live /v1/models responds but omits a model that exists in the curated static catalog, validate_requested_model now accepts it with a note instead of rejecting. This covers the /model slash-command path (the picker path was already fixed in the parent commit). Addresses review feedback from potatogim on NousResearch#46857.
…hen live API omits model When live /v1/models responds but omits a model that exists in the curated static catalog, validate_requested_model now accepts it with a note instead of rejecting. This covers the /model slash-command path (the picker path was already fixed in the parent commit). Addresses review feedback from potatogim on NousResearch#46857.
…r-merge-live-static fix(models): merge live API results with curated static catalog in generic provider path
…hen live API omits model When live /v1/models responds but omits a model that exists in the curated static catalog, validate_requested_model now accepts it with a note instead of rejecting. This covers the /model slash-command path (the picker path was already fixed in the parent commit). Addresses review feedback from potatogim on NousResearch#46857.
…r-merge-live-static fix(models): merge live API results with curated static catalog in generic provider path
…hen live API omits model When live /v1/models responds but omits a model that exists in the curated static catalog, validate_requested_model now accepts it with a note instead of rejecting. This covers the /model slash-command path (the picker path was already fixed in the parent commit). Addresses review feedback from potatogim on NousResearch#46857.
…r-merge-live-static fix(models): merge live API results with curated static catalog in generic provider path
…hen live API omits model When live /v1/models responds but omits a model that exists in the curated static catalog, validate_requested_model now accepts it with a note instead of rejecting. This covers the /model slash-command path (the picker path was already fixed in the parent commit). Addresses review feedback from potatogim on NousResearch#46857.
…r-merge-live-static fix(models): merge live API results with curated static catalog in generic provider path
…hen live API omits model When live /v1/models responds but omits a model that exists in the curated static catalog, validate_requested_model now accepts it with a note instead of rejecting. This covers the /model slash-command path (the picker path was already fixed in the parent commit). Addresses review feedback from potatogim on NousResearch#46857.
…r-merge-live-static fix(models): merge live API results with curated static catalog in generic provider path
What does this PR do?
Merges live API model results with the static curated catalog in the generic profile-based provider path, so models that a provider's live
/v1/modelsendpoint omits (stale cache, partial rollout) still appear in the/modelpicker.Related Issue
Fixes #46850
Type of Change
Changes Made
hermes_cli/models.py: Generalized the kimi-coding live+curated merge pattern to all providers in the generic profile-based path. Live entries come first (provider's preferred order), then curated-only entries are appended with case-insensitive dedup.tests/hermes_cli/test_models_dev_preferred_merge.py: Updated existing kimi-coding test to reflect live-first ordering.tests/hermes_cli/test_provider_live_curated_merge.py: New test file covering the merge behavior — live+curated merge, no duplicates, case-insensitive dedup, empty curated fallback.How to Test
pytest tests/hermes_cli/test_provider_live_curated_merge.py -v— all 5 tests should passpytest tests/hermes_cli/test_models_dev_preferred_merge.py -v— all tests should passpytest tests/hermes_cli/test_model_validation.py -v— all tests should passChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
hermes_cli/models.py::provider_model_ids(generic profile-based path, lines 2370-2382)_merge_with_models_dev(models.dev merge), kimi-coding merge (existing pattern generalized)