Skip to content

fix(zai): autodetect endpoint during setup flow#11376

Open
helix4u wants to merge 1 commit into
NousResearch:mainfrom
helix4u:fix/zai-setup-autodetect
Open

fix(zai): autodetect endpoint during setup flow#11376
helix4u wants to merge 1 commit into
NousResearch:mainfrom
helix4u:fix/zai-setup-autodetect

Conversation

@helix4u

@helix4u helix4u commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

This fixes a mismatch between the Z.AI auth path and the interactive model/setup path.

Hermes already auto-detects the correct GLM endpoint at auth setup time in hermes_cli/auth.py, but the interactive provider flow in hermes_cli/main.py was still routing zai through the generic API-key provider flow. That generic flow prompts for Base URL [...] and defaults to the general GLM endpoint, which makes Coding Plan users guess the right endpoint even though Hermes already has autodetect logic.

This PR gives Z.AI its own setup flow and reuses resolve_api_key_provider_credentials("zai") so setup stays aligned with the existing auth/runtime endpoint detection and cache behavior.

This applies both to hermes model and to the model/provider section inside hermes setup, because the setup wizard delegates that step through the same select_provider_and_model() path in hermes_cli/main.py.

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

  • Added a dedicated _model_flow_zai() in hermes_cli/main.py
  • Routed zai provider selection through that dedicated flow instead of the generic API-key provider flow
  • Reused resolve_api_key_provider_credentials("zai") so setup uses the same endpoint autodetect/cached resolution as the auth path
  • Removed the interactive Z.AI base-URL prompt from the named zai provider flow
  • Covered the shared provider-selection path used by both hermes model and the model/provider step in hermes setup
  • Replaced the old Z.AI base-URL prompt tests with setup autodetect tests in tests/hermes_cli/test_model_provider_persistence.py

How to Test

  1. Run hermes setup and go through the model/provider step, or run hermes model
  2. Select zai
  3. Configure a Z.AI key for either general GLM or Coding Plan and verify Hermes no longer asks you to guess the endpoint
  4. Confirm the saved model.base_url matches the resolved Z.AI endpoint

Focused test run completed:

source venv/bin/activate && python -m pytest tests/hermes_cli/test_model_provider_persistence.py tests/hermes_cli/test_api_key_providers.py -q

Result: 136 passed in 9.05s

Full suite run completed:

source venv/bin/activate && python -m pytest tests/ -q -n 4

Result: 38 failed, 12253 passed, 35 skipped in 333.60s (0:05:33)

The failures are broad and appear unrelated to this change. They are clustered in existing-red areas including gateway/Discord, DM topics, API server, setup prompt menus, Bedrock auto-detection, Ollama Cloud auto-detection, backup/profile restoration, browser/camofox/browserbase, tirith, and a few other general suite failures. Nothing in the failing list is in the touched Z.AI setup files.

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: Ubuntu Linux

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

Screenshots / Logs

Focused pytest:

136 passed in 9.05s

Full suite pytest:

38 failed, 12253 passed, 35 skipped in 333.60s (0:05:33)

@helix4u helix4u marked this pull request as ready for review April 17, 2026 03:58
@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 provider/zai ZAI provider labels Apr 25, 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 provider/zai ZAI provider type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants