Skip to content

fix(providers): set User-Agent on ProviderProfile.fetch_models#26235

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-5a8e3dc5
May 15, 2026
Merged

fix(providers): set User-Agent on ProviderProfile.fetch_models#26235
teknium1 merged 1 commit into
mainfrom
hermes/hermes-5a8e3dc5

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

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() in providers/base.py builds the catalog probe with no User-Agent header. urllib defaults to Python-urllib/3.11, which Cloudflare/WAF in front of opencode.ai rejects with 403. The generic profile-based live-fetch in provider_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 send User-Agent: hermes-cli/<version> on every catalog probe. Lazy version import keeps the layering clean.
  • hermes_cli/models.py: strip the now-stale comment in validate_requested_model() claiming opencode-zen's /models returns 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_HOME and a real (non-placeholder) key:

Before After
profile.fetch_models(api_key='...') direct urllib HTTPError 403 → returns None 42 models
provider_model_ids('opencode-zen') with key 60 (static + models.dev merge — no live fetch) 42 (live API only)
provider_model_ids('opencode-zen') no key 60 (static + models.dev merge) 60 (unchanged)
Live-only models present (gpt-5.5, gpt-5.5-pro, kimi-k2.6, glm-5.1, *-free variants) partially via models.dev yes via live

Also: scripts/run_tests.sh tests/providers/ → 92/92 passing.

Co-authored-by: Aashish Poudel mr.aashiz@gmail.com

Closes #2651

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>
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-5a8e3dc5 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8258 on HEAD, 8258 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4312 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@teknium1 teknium1 merged commit 5360b54 into main May 15, 2026
15 of 17 checks passed
@teknium1 teknium1 deleted the hermes/hermes-5a8e3dc5 branch May 15, 2026 08:42
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants