fix(providers): set User-Agent on ProviderProfile.fetch_models#26235
Merged
Conversation
Some catalog endpoints (OpenCode Zen, etc.) sit behind a WAF that returns 403 for the default Python-urllib/<ver> User-Agent. The generic profile-based live fetch in providers/base.py was silently failing for any such provider — falling through to the static catalog and missing newly-launched models. Set a generic 'hermes-cli/<version>' UA on the catalog probe so every api_key provider profile benefits. Verified live against opencode-zen: before this change, profile.fetch_models() raised HTTP 403; after, it returns 42 models including gpt-5.5, gpt-5.5-pro, kimi-k2.6, glm-5.1 and the *-free variants the static catalog doesn't list. Also strip the now-stale comment in validate_requested_model() claiming opencode-zen's /models returns 404 against the HTML marketing site — the API endpoint at /zen/v1/models returns 200 with valid JSON. Surfaced by #2651 (@aashizpoudel) — fixes the same user-facing gap their PR targeted, applied at the right layer so all api_key provider profiles get live catalogs through the same code path. Co-authored-by: Aashish Poudel <mr.aashiz@gmail.com>
Contributor
🔎 Lint report:
|
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
Provider catalog live-fetch now works for endpoints behind a WAF that 403s the default
Python-urllib/<ver>User-Agent. Surfaced by #2651 — fixed at the right layer so every api_key provider profile gets live catalogs through the generic dispatch.Root cause
ProviderProfile.fetch_models()inproviders/base.pybuilds the catalog probe with noUser-Agentheader. urllib defaults toPython-urllib/3.11, which Cloudflare/WAF in front ofopencode.airejects with 403. The generic profile-based live-fetch inprovider_model_ids()was silently swallowing the 403 and falling back to the static catalog plus the models.dev merge.Changes
providers/base.py: add_profile_user_agent()helper and sendUser-Agent: hermes-cli/<version>on every catalog probe. Lazy version import keeps the layering clean.hermes_cli/models.py: strip the now-stale comment invalidate_requested_model()claiming opencode-zen's/modelsreturns 404 against the HTML marketing site — verified false (returns 200 JSON at/zen/v1/models).scripts/release.py: AUTHOR_MAP entries for the co-author.Validation
E2E with isolated
HERMES_HOMEand a real (non-placeholder) key:profile.fetch_models(api_key='...')directprovider_model_ids('opencode-zen')with keyprovider_model_ids('opencode-zen')no keygpt-5.5,gpt-5.5-pro,kimi-k2.6,glm-5.1,*-freevariants)Also:
scripts/run_tests.sh tests/providers/→ 92/92 passing.Co-authored-by: Aashish Poudel mr.aashiz@gmail.com
Closes #2651