feat(models): add Z.AI GLM-5.2 to native zai provider + 1M context + thinking effort - #45483
feat(models): add Z.AI GLM-5.2 to native zai provider + 1M context + thinking effort#45483potatogim wants to merge 2 commits into
Conversation
c437258 to
0c2d7bc
Compare
Review: Bundled model additionThe PR title says "add Z.AI GLM-5.2 model" but the diff also adds Concern: If Suggestion: Either remove the The GLM-5.2 additions across |
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Overview
Adds Z.AI GLM-5.2 model (1M context window) to the providers list, following the standard provider/model registration pattern.
Assessment
- Model registration follows established patterns with appropriate context window (1M).
- One prior informal review from Copilot is noted; this constitutes the formal review.
- No security, performance, or documentation concerns.
Reviewed by Hermes Agent
|
Thanks @liuhao1024 for catching that! You were right — the Fixed in the latest commit — both openrouter and nous catalog entries for |
6cc9716 to
7cc279d
Compare
GLM-5.2 now appears in the Z.AI model picker and resolves to its correct 1M context length on every surface. The Z.AI live /models API returns 7 GLM models but not glm-5.2, so it falls through to the static curated list and must be added by hand. Model facts (from Z.AI docs): - ID: glm-5.2 - Context window: 1,000,000 tokens - Max output: 131,072 tokens - Reasoning: enabled - Docs: https://docs.z.ai/devpack/latest-model Changes: - agent/model_metadata.py: DEFAULT_CONTEXT_LENGTHS["glm-5.2"] = 1_000_000 (longest-key-first matching, before generic "glm": 202752) - hermes_cli/models.py: add to _PROVIDER_MODELS["zai"] curated list - tests/agent/test_model_metadata.py: context length resolution test
GLM-5.2 accepts an 'effort' field inside the thinking object to control reasoning depth. Verified against the live Z.AI API: effort=max produces significantly more reasoning tokens than baseline. Effort mapping per Z.AI official docs (https://docs.z.ai/devpack/latest-model): - xhigh/max → max - high → high - lower efforts → omit (server default is high) Implementation: - plugins/model-providers/zai: ZAIProfile overrides build_api_kwargs_extras() to emit thinking.type + optional effort. Mirrors the DeepSeek profile pattern (ProviderProfile subclass). - When reasoning_config is None, returns empty dicts — preserves default wire format for existing GLM users (5.1, 5, 4.x). - Effort is GLM-5.2 only — _model_supports_effort() uses boundary matching (glm-5.2 or glm-5.2-*, not glm-5.20). - glm-5.2 added to fallback_models for picker display until the live /models API includes it. Tests (35 total): - Wire shape: enabled/disabled, effort mapping, case insensitivity - Model gating: GLM-5.2+ gets effort, older models don't - Backward compat: None reasoning_config returns empty for all models - Transport integration: ChatCompletionsTransport().build_kwargs() E2E
7cc279d to
0efa118
Compare
|
Thanks for jumping on GLM-5.2. We merged the broader GLM-5.2 support via #45695, preserving @am423's authorship in git history: That landed the 1M context metadata plus the Z.AI model picker/setup/auth probing/fallback surfaces, so this PR is now covered. Closing as duplicate, with appreciation for helping validate the same issue. |
Summary
GLM-5.2now appears in the Z.AI native model picker and resolves to its correct 1M context length on every surface, withthinking+effortparameter support for reasoning depth control.Why this needed a manual edit: The Z.AI provider lists are hardcoded in
_PROVIDER_MODELSandmodel_metadata.py— the live/modelsAPI returns 7 GLM models but notglm-5.2, so it falls through to the static curated list and must be added by hand.Why effort matters: GLM-5.2 accepts an
effortfield (high/max) inside thethinkingobject. Verified against the live Z.AI API:effort=maxproduces significantly more reasoning tokens than baseline. Without this PR, Hermesreasoning_effort: xhighis silently ignored for Z.AI.Changes
Model registration:
agent/model_metadata.py: addDEFAULT_CONTEXT_LENGTHSkey"glm-5.2": 1_000_000. Longest-key-first substring matching makes it win over the generic"glm": 202752catch-all.hermes_cli/models.py: add to_PROVIDER_MODELS["zai"]curated list (native Z.AI picker only).Thinking effort implementation:
plugins/model-providers/zai/__init__.py:ZAIProfileclass overridesbuild_api_kwargs_extras()to emitthinking.type+ optionaleffort. Mirrors the DeepSeek profile pattern (ProviderProfilesubclass + override).xhigh/max→max,high→high, lower efforts omitted (server default =high)_model_supports_effort()with boundary matching (glm-5.2orglm-5.2-*, notglm-5.20)reasoning_config=None, returns empty dicts — preserves default wire format for existing GLM users (5.1, 5, 4.x)thinkingparameter itself works across all GLM models on both endpoints (verified);effortis a GLM-5.2 feature.glm-5.2added tofallback_modelsfor picker display until the live/modelsAPI includes it.Tests:
tests/plugins/model_providers/test_zai_profile.py— 35 tests: wire shape, model gating, backward compat, transport integrationtests/agent/test_model_metadata.py— GLM-5.2 context length resolution testModel facts (from Z.AI docs)
glm-5.2, 1M context window, max output 131,072 tokens, reasoning enabledhttps://api.z.ai/api/paas/v4(standard) andhttps://api.z.ai/api/coding/paas/v4(Coding Plan)thinkingandeffortparameters are accepted on both endpoints (verified)low/medium/high→high,xhigh/max→maxContext length
The context length is set to
1_000_000, matching the Z.AI official docs which explicitly state 1,000,000 tokens. A power-of-two approximation (1,048,576) has been used in some references, but the documented spec value is preferred.Validation
glm-5.2/zai/glm-5.2glm-5.1/glm-5glm-4.6/glm-4.5Effort wire shape (
build_api_kwargs_extras):None(no reasoning){}(preserved default){enabled: True, effort: xhigh}{thinking: {type: enabled, effort: max}}{enabled: True, effort: high}{thinking: {type: enabled, effort: high}}{enabled: True, effort: medium}{thinking: {type: enabled}}{enabled: False}{thinking: {type: disabled}}Full test suite: 5899 passed, 2 skipped. The 19 pre-existing failures (LSP, coding-context, vision-routing) are unrelated to this change and reproduce on
main. GLM-5.2 specific tests: 35 passed (effort profile) + 101 passed (model metadata, includes 1 new GLM-5.2 test).Related
Also addresses #45519.
This PR adds
thinking/effortsupport on top, which none of the above cover.