You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
salvage helix4u's Z.AI setup fix onto current main
route zai through a dedicated _model_flow_zai() so setup/model selection uses resolve_api_key_provider_credentials("zai")
introduce shared base-URL override management for provider setup flows instead of making override recovery a Z.AI-only special case
align runtime and provider-status resolution so Z.AI uses the same resolved/persisted endpoint contract end-to-end
Architecture
This PR now uses a shared _configure_base_url_override(...) helper in hermes_cli/main.py.
That helper gives provider setup flows a consistent way to:
keep an existing explicit base URL override
clear a stale explicit override and return to auto/default resolution
replace the override with a new manual URL
The helper is used by:
generic API-key provider setup flow
Kimi setup flow
Z.AI setup flow
For Z.AI, resolve_api_key_provider_credentials(..., ignore_env_base_url=True) was added so setup can ask: "what endpoint would auto resolution choose if I clear the explicit override?" That lets hermes model recover from stale GLM_BASE_URL values instead of trapping users on them.
The follow-up fixes also align the rest of the stack:
resolve_runtime_provider() now honors the resolved/persisted Z.AI endpoint instead of silently falling back to the static default
get_api_key_provider_status() now reuses resolve_api_key_provider_credentials() so status output stays consistent with setup/runtime
Why
The original PR identified a real setup/runtime mismatch: runtime/auth already knew how to autodetect the correct Z.AI endpoint family, but the interactive setup flow still treated Z.AI like a generic API-key provider and prompted for a base URL.
During review, two follow-up issues surfaced:
removing the manual override path only for Z.AI would create a regression for users with stale GLM_BASE_URL values
even after setup autodetected and persisted the correct Z.AI endpoint, runtime/status still had stale parallel base-url resolution paths
The fix here is broader and cleaner: shared override-management UX for provider setup flows, with provider-specific autodetection beneath it, and aligned runtime/status resolution so the chosen endpoint is actually used everywhere.
Current-main follow-ups included
preserved newer dispatch entries on main (including nvidia / ollama-cloud) while carving out zai
added dispatch-level regression coverage on top of the original setup-flow tests
added tests for shared base-URL override management
added tests proving Z.AI setup can manually set an override and can clear a stale override back to the autodetected endpoint
added tests proving provider status uses the resolved Z.AI endpoint
added tests proving runtime uses the Z.AI endpoint persisted in config
Test plan
scripts/run_tests.sh tests/hermes_cli/test_api_key_providers.py -k 'zai or GLM_BASE_URL or detect_zai_endpoint or runtime_zai or provider_status' -q
This PR contains patterns commonly associated with supply chain attacks. This does not mean the PR is malicious — but these patterns require careful human review before merging.
⚠️ WARNING: Outbound network calls (POST/PUT)
Outbound POST/PUT requests in new code could be data exfiltration. Verify the destination URLs are legitimate.
Matches (first 10):
927:+ with urllib.request.urlopen(req, timeout=TIMEOUT) as r:
935:+ with urllib.request.urlopen(req, timeout=TIMEOUT) as r:
Automated scan triggered by supply-chain-audit. If this is a false positive, a maintainer can approve after manual review.
This PR contains patterns commonly associated with supply chain attacks. This does not mean the PR is malicious — but these patterns require careful human review before merging.
⚠️ WARNING: Outbound network calls (POST/PUT)
Outbound POST/PUT requests in new code could be data exfiltration. Verify the destination URLs are legitimate.
Matches (first 10):
1001:+ with urllib.request.urlopen(req, timeout=TIMEOUT) as r:
1009:+ with urllib.request.urlopen(req, timeout=TIMEOUT) as r:
Automated scan triggered by supply-chain-audit. If this is a false positive, a maintainer can approve after manual review.
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
comp/cliCLI entry point, hermes_cli/, setup wizardP2Medium — degraded but workaround existsprovider/zaiZAI providertype/bugSomething isn't working
3 participants
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
zaithrough a dedicated_model_flow_zai()so setup/model selection usesresolve_api_key_provider_credentials("zai")Architecture
This PR now uses a shared
_configure_base_url_override(...)helper inhermes_cli/main.py.That helper gives provider setup flows a consistent way to:
The helper is used by:
For Z.AI,
resolve_api_key_provider_credentials(..., ignore_env_base_url=True)was added so setup can ask: "what endpoint would auto resolution choose if I clear the explicit override?" That letshermes modelrecover from staleGLM_BASE_URLvalues instead of trapping users on them.The follow-up fixes also align the rest of the stack:
resolve_runtime_provider()now honors the resolved/persisted Z.AI endpoint instead of silently falling back to the static defaultget_api_key_provider_status()now reusesresolve_api_key_provider_credentials()so status output stays consistent with setup/runtimeWhy
The original PR identified a real setup/runtime mismatch: runtime/auth already knew how to autodetect the correct Z.AI endpoint family, but the interactive setup flow still treated Z.AI like a generic API-key provider and prompted for a base URL.
During review, two follow-up issues surfaced:
GLM_BASE_URLvaluesThe fix here is broader and cleaner: shared override-management UX for provider setup flows, with provider-specific autodetection beneath it, and aligned runtime/status resolution so the chosen endpoint is actually used everywhere.
Current-main follow-ups included
main(includingnvidia/ollama-cloud) while carving outzaiTest plan
scripts/run_tests.sh tests/hermes_cli/test_api_key_providers.py -k 'zai or GLM_BASE_URL or detect_zai_endpoint or runtime_zai or provider_status' -qscripts/run_tests.sh tests/hermes_cli/test_model_provider_persistence.py tests/hermes_cli/test_api_key_providers.py tests/hermes_cli/test_setup.py tests/hermes_cli/test_setup_model_provider.py tests/hermes_cli/test_ollama_cloud_provider.py -qGLM_BASE_URLcan be cleared and falls back to the autodetected endpointzaiusing the persisted config base URL instead of the static defaultBased on #11376 by @helix4u.