feat(providers): add Z.AI GLM Coding Plan provider and glm-5.2 model - #47140
feat(providers): add Z.AI GLM Coding Plan provider and glm-5.2 model#47140yuanmingyi wants to merge 3 commits 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.
|
Related: #13500 and #13911 (open competing approaches that split |
these two are old & duplicate and can be closed. Thanks |
…stings Simplify the zai-coding provider surface introduced in the prior commit: drop the extra coding aliases and the generalized endpoint-family credential seeding in favor of the canonical "zai-coding" slug and dedicated, explicit provider listings. Remove the zai-coding aliases (zai-coding-plan, z-ai-coding, glm-coding, glm-coding-plan, zhipu-coding, zhipu-coding-plan) from the provider/alias maps and the plugin profile, and drop the zai-coding aux/vision model overrides in auxiliary_client. Revert credential-pool seeding to the zai-only _resolve_zai_base_url path (drop the endpoint_family_providers branch). Add dedicated doctor and status entries for "Z.AI / GLM Coding Plan API" with the coding /models URL. Recognize zai-coding in anthropic dot-preservation (run_agent), the delegate provider error message, and trajectory-compression provider detection (z.ai / bigmodel.cn hosts with /api/coding/paas/). Drop the "provider" alias for the /model command and update tests accordingly.
|
Closing as redundant — current Verified on
The one genuine UX gap is that the setup flow uses a plain text input for base URL rather than a picker offering Global/China/Coding Plan options — that's a small setup-flow tweak, not a 1171-line provider split with endpoint-family isolation machinery. Thanks for the thorough work and tests — the endpoint-family guard design is thoughtful, but main's probe + env override + per-key-hash cache already covers the use case. |
|
I can confirm, it works now with Coding Plan url entered during model setup |
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