Skip to content

feat: add opencode-zen model provider with live model fetch#2651

Closed
aashizpoudel wants to merge 1 commit into
NousResearch:mainfrom
aashizpoudel:fix/opencode-zen-model-fetch
Closed

feat: add opencode-zen model provider with live model fetch#2651
aashizpoudel wants to merge 1 commit into
NousResearch:mainfrom
aashizpoudel:fix/opencode-zen-model-fetch

Conversation

@aashizpoudel

Copy link
Copy Markdown
Contributor

Summary

Add OpenCode Zen provider with live model fetching from /v1/models endpoint.

  • Add _fetch_opencode_zen_models() function that fetches available models from the OpenCode Zen API
  • Includes required User-Agent header for the endpoint
  • Uses OPENCODE_ZEN_API_KEY and OPENCODE_ZEN_BASE_URL env vars with fallback to default inference URL

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/agent Core agent loop, run_agent.py, prompt builder labels May 3, 2026
teknium1 added a commit that referenced this pull request May 15, 2026
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>
@teknium1

Copy link
Copy Markdown
Contributor

Thanks @aashizpoudel — your PR surfaced a real bug, but at a deeper layer than the diff suggested.

The OpenCode Zen /models endpoint actually works without a User-Agent header (curl returns 200 with valid JSON either way). What's broken is that Cloudflare in front of opencode.ai returns 403 for the default Python-urllib/<ver> UA — so the existing generic profile-based live-fetch at providers/base.py::ProviderProfile.fetch_models() was silently failing for opencode-zen (and any other provider behind a similar WAF).

Fixed in #26235 by setting User-Agent: hermes-cli/<version> on the generic catalog probe, which restores live model fetching for opencode-zen and benefits every api_key provider profile through the same code path — no per-provider duplication needed.

You're credited as Co-author on the merge commit (5360b54). Thanks for catching this!

DIZ-admin pushed a commit to DIZ-admin/hermes-agent that referenced this pull request May 16, 2026
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 NousResearch#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>
@aashizpoudel aashizpoudel deleted the fix/opencode-zen-model-fetch branch May 22, 2026 20:46
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
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 NousResearch#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants