feat(providers): add Z.AI GLM Coding Plan provider and glm-5.2 model - #2
Closed
yuanmingyi wants to merge 1 commit into
Closed
feat(providers): add Z.AI GLM Coding Plan provider and glm-5.2 model#2yuanmingyi wants to merge 1 commit into
yuanmingyi wants to merge 1 commit into
Conversation
Add a dedicated zai-coding provider as a sibling to the direct-API zai provider. They share API-key env vars (GLM_API_KEY/ZAI_API_KEY/Z_AI_API_KEY) and may reuse each other's stored credential, but are kept on separate billing paths so a cached or legacy base URL cannot bleed across the direct (/api/paas/v4) and coding-plan (/api/coding/paas/v4) endpoints. Add the glm-5.2 model to both the zai (direct API) and zai-coding (Coding Plan) provider catalogs and to the Z.AI endpoint probe candidates. Generalize Z.AI endpoint detection into provider-family helpers (endpoint_family_providers, base_url_matches_endpoint_family, resolve_provider_endpoint_family_base_url) with an official-URL canonical key that normalizes default ports, trailing dots/slashes, and casing. Add endpoint-family guards at all base-URL resolution sites (runtime, credential pool, setup picker), a Z.AI endpoint picker in the setup flow, and wire zai-coding across registries, overlays, profiles, aliases, model catalogs, aux/vision models, doctor/status labels, and model-metadata URL inference while keeping its curated model list separate from the direct catalog. Includes focused tests for endpoint-family isolation, credential sharing, the family guard, picker fallback, cache invalidation, and model normalization.
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-attribute |
2 |
invalid-argument-type |
1 |
First entries
tests/hermes_cli/test_runtime_provider_resolution.py:1405: [invalid-argument-type] invalid-argument-type: Argument to function `_resolve_runtime_from_pool_entry` is incorrect: Expected `PooledCredential`, found `_Entry`
tests/providers/test_provider_profiles.py:107: [unresolved-attribute] unresolved-attribute: Attribute `display_name` is not defined on `None` in union `ProviderProfile | None`
tests/providers/test_provider_profiles.py:110: [unresolved-attribute] unresolved-attribute: Attribute `fallback_models` is not defined on `None` in union `ProviderProfile | None`
✅ Fixed issues: none
Unchanged: 5773 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
Owner
Author
|
Redirected to upstream: NousResearch#47140 (targets NousResearch/hermes-agent:main). |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Adds a dedicated
zai-coding(Z.AI / GLM Coding Plan) provider as a sibling to the existing direct-APIzaiprovider. The two share the same API-key env vars (GLM_API_KEY/ZAI_API_KEY/Z_AI_API_KEY) and may reuse each other's stored credential, but are kept on separate billing paths — direct/api/paas/v4vs coding-plan/api/coding/paas/v4— so a cached or legacyGLM_BASE_URLcannot bleed across endpoints (a direct key hitting the coding path returns "Insufficient balance", and vice versa). Also adds theglm-5.2model to both providers' catalogs and to the Z.AI endpoint probe candidates.The Z.AI endpoint-detection logic is generalized into reusable provider-family helpers (
endpoint_family_providers,base_url_matches_endpoint_family,resolve_provider_endpoint_family_base_url) backed by an official-URL canonical key that normalizes default ports (:443), trailing dots/slashes, and casing, so cross-family official URLs are reliably rejected.Related Issue
Supersedes #1 (closed prior attempt). No tracking issue —
Fixes #.Type of Change
Changes Made
zai-codingProviderConfig(hermes_cli/auth.py),ProviderProfile(plugins/model-providers/zai/__init__.py),HermesOverlay(hermes_cli/providers.py), with aliases (zai-coding-plan,z-ai-coding,glm-coding,glm-coding-plan,zhipu-coding,zhipu-coding-plan) and coding-plan base URL.glm-5.2to thezaiandzai-codingcatalogs (hermes_cli/models.py,hermes_cli/setup.py) and to the Z.AI endpoint probe candidates.ZAI_ENDPOINTSintoZAI_DIRECT_ENDPOINTS/ZAI_CODING_ENDPOINTS; new_official_base_url_key+base_url_matches_endpoint_familyguard; guards applied at all base-URL resolution sites (hermes_cli/runtime_provider.py,agent/credential_pool.py,hermes_cli/model_setup_flows.py).shared_credential_provider_ids()letszai/zai-codingfall back to each other's stored pool key while the endpoint still follows the selected provider's family._select_endpoint_family_base_url, persisted toGLM_BASE_URL.glm-5-turboand vision modelglm-5v-turboforzai-coding(agent/auxiliary_client.py);/coding/URL inference →zai-coding(agent/model_metadata.py); models.dev mapping (agent/models_dev.py);/modelpicker +PROVIDER_GROUPS, canonical providers, labels, doctor/status labels,model_normalizeprefix-strip.:443/trailing-dot), picker fallback, andzai-coding/...normalization.How to Test
scripts/run_tests.sh tests/hermes_cli/test_api_key_providers.py tests/hermes_cli/test_runtime_provider_resolution.py tests/hermes_cli/test_model_provider_persistence.py tests/hermes_cli/test_model_validation.py tests/hermes_cli/test_model_normalize.py tests/agent/test_auxiliary_named_custom_providers.py tests/providers/test_provider_profiles.py— affected zai/coding tests pass (189 passed, 0 failed).hermes /model→ Z.AI / GLM group → Coding Plan; confirm the endpoint picker offers Global / China / custom proxy and persists the choice toGLM_BASE_URL.zai-coding, and confirm requests hithttps://api.z.ai/api/coding/paas/v4(not the direct path).zaiandzai-codingand confirm no cross-family base-URL bleed (stale cached/GLM_BASE_URLvalues are rejected with a warning and re-probed).Checklist
Code
feat(providers):…)package-lock.jsonexcluded)pytest tests/ -qand all tests pass — ran the affected test files (189 passed); full suite not yet run on this branchDocumentation & Housekeeping
plugins/model-providers/zai/; no new config keys)cli-config.yaml.example— N/A (reuses existingGLM_API_KEY/GLM_BASE_URL)CONTRIBUTING.mdorAGENTS.md— N/AScreenshots / Logs
N/A