Skip to content

fix(auxiliary): honor Z.AI detected_endpoint for vision provider resolution and add glm-4.6v for vision model on GLM coding plan - #74071

Open
Musanna-al-akil wants to merge 3 commits into
NousResearch:mainfrom
Musanna-al-akil:main
Open

fix(auxiliary): honor Z.AI detected_endpoint for vision provider resolution and add glm-4.6v for vision model on GLM coding plan#74071
Musanna-al-akil wants to merge 3 commits into
NousResearch:mainfrom
Musanna-al-akil:main

Conversation

@Musanna-al-akil

@Musanna-al-akil Musanna-al-akil commented Jul 29, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes Z.AI vision calls failing with error 1113 ("insufficient balance") for Coding Lite / Coding Plan subscribers. These keys are only valid on the /api/coding/paas/v4 endpoint, but the vision resolver (resolve_vision_provider_client) only tried the hardcoded generic /api/paas/v4 URLs — unlike the chat model, which already reads the auto-detected endpoint from auth.json via the credential pool.

This PR extends the same detected_endpoint lookup to the vision resolver path, with a key_hash guard to prevent stale cached endpoints from poisoning resolution. It also adds glm-4.6v to the Z.AI provider model list — on the Coding Plan, glm-5v-turbo is not available, making glm-4.6v the primary vision model for Z.AI users.

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • agent/auxiliary_client.pyresolve_vision_provider_client now reads the detected_endpoint cache from auth.json (providers.zai.detected_endpoint) and inserts it as the first candidate URL before falling back to the hardcoded generic endpoints. Includes a SHA-256 key_hash guard so a stale endpoint cached for a different key is silently skipped. Any error reading auth.json is caught and logged at debug level.
  • hermes_cli/models.py — Adds glm-4.6v to the Z.AI provider model list so it appears as a selectable auxiliary vision model.
  • tests/agent/test_zai_vision_detected_endpoint.py (new) — Four regression tests covering: coding endpoint selection, standard endpoint selection, credential-pool-only key resolution, and stale key-hash fallback.

How to Test

  1. Use a Z.AI Coding Plan key and run hermes setup to auto-detect the endpoint
  2. Configure a Z.AI vision model (e.g. glm-4.6v) as the auxiliary vision provider
  3. Send an image to the agent — before the fix, vision calls return error 1113 ("insufficient balance"); after the fix, the detected /api/coding/paas/v4 endpoint is used and vision works
  4. Run the regression tests: pytest tests/agent/test_zai_vision_detected_endpoint.py -v

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 14.8.7

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

…lution

Z.AI Coding Lite / Coding Plan keys are only valid on the
/api/coding/paas/v4 endpoint, but the vision resolver
(resolve_vision_provider_client) only tried the hardcoded generic
/api/paas/v4 URLs, producing error 1113 ("insufficient balance") on
otherwise valid accounts.

The main chat model already avoided this by reading the endpoint
auto-detected at setup time (auth.json providers.zai.detected_endpoint)
via the credential pool. This extends the same detected_endpoint lookup
to the vision resolver path, with a key_hash guard to prevent a stale
cached endpoint from poisoning resolution.

Also adds glm-4.6v to the Z.AI provider model list.
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard tool/vision Vision analysis and image generation provider/zai ZAI provider area/auth Authentication, OAuth, credential pools P2 Medium — degraded but workaround exists sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Jul 29, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for tracing the explicit Z.AI vision path. The premise is real: current main forces that path through generic PaaS URLs at agent/auxiliary_client.py:6290-6305.

Problems

  • The new direct _AUTH_JSON_PATH read bypasses the shared profile/global auth-state fallback. hermes_cli/auth.py:1235-1243 intentionally obtains provider state from global auth when a profile lacks it, and read_credential_pool() applies the same fallback at hermes_cli/auth.py:1417-1425. A profile can therefore resolve a global Z.AI key but miss its globally cached detected endpoint under this patch.
  • glm-4.6v is added to the picker list, but automatic Z.AI vision routing remains pinned to glm-5v-turbo at agent/auxiliary_client.py:566-569. The new entry does not become the automatic vision model.

Suggested changes

  • Reuse the existing Z.AI credential/base-URL resolver rather than reading auth.json directly, and add a global-auth fallback regression test.
  • If the intended behavior is an automatic Coding Plan vision default, update that routing and test it.

Automated hermes-sweeper review.

@teknium1 teknium1 added the sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users label Jul 30, 2026
Musanna-al-akil and others added 2 commits August 4, 2026 02:27
…al resolver

The initial vision fix read auth.json directly for the detected endpoint,
bypassing the shared profile→global auth-state fallback that
_load_provider_state and read_credential_pool both apply. A profile that
resolves a global Z.AI key but has no locally cached detected_endpoint
would therefore miss the globally cached endpoint and fall back to the
generic URLs, reintroducing error 1113 on Coding Lite/Plan keys.

Replace the direct auth.json read with a call to
resolve_api_key_provider_credentials, which flows through
_resolve_zai_base_url → _load_provider_state and inherits the same
profile→global fallback. The resolver also owns GLM_BASE_URL precedence
and endpoint detection, keeping all credential-sensitive resolution on
one path.

Add api_key_override (keyword-only) to resolve_api_key_provider_credentials
so the vision resolver can thread its effective key (resolved or pool-sourced)
through the same base-URL resolution, keeping cache validation and client
construction tied to the same key. Restructure resolve_provider_client's
explicit key/base_url handling so a complete caller-supplied pair skips
provider discovery, while a partial override still goes through the resolver.

Adds a global-auth fallback regression test and glm-4.6v to the Z.AI model list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists provider/zai ZAI provider sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades tool/vision Vision analysis and image generation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants