feat(zai): support thinking effort for GLM-5.2 - #46446
Closed
potatogim wants to merge 1 commit into
Closed
Conversation
tonydwb
approved these changes
Jun 15, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
zai provider now supports thinking effort for GLM-5.2 model. Small, focused change (2 files).
Looks Good
- Well-scoped, clean implementation
Reviewed by Hermes Agent
sebitabravo
added a commit
to sebitabravo/AgroVoz
that referenced
this pull request
Jun 18, 2026
…hropic
z.ai NO soporta reasoning_effort (Anthropic nativo). Usa formato propio:
{"thinking": {"type": "enabled", "effort": "max"}}
El CI anterior enviaba reasoning_effort y z.ai lo ignoraba silenciosamente
(cero thinking blocks en los 3 passes). Con este fix deberian aparecer
bloques 🧠 Razonamiento activo en los logs.
Ref: NousResearch/hermes-agent#46446
GLM-5.2 accepts an effort field (high/max) inside the thinking object per Z.AI official docs. Without this, Hermes reasoning_effort is silently ignored for Z.AI — the value never reaches the API. Override build_api_kwargs_extras() in a new ZAIProfile subclass, mirroring the DeepSeek profile pattern. Effort mapping: xhigh/max → thinking.effort=max high → thinking.effort=high lower → omit (server default = high) Effort is GLM-5.2 only — guarded by _model_supports_effort() with boundary matching (glm-5.2 or glm-5.2-*, not glm-5.20). When reasoning_config is None, returns empty dicts to preserve the default wire format for existing GLM users (5.1, 5, 4.x). 35 tests: wire shape, model gating, backward compat, transport integration.
potatogim
force-pushed
the
feat/zai-glm52-effort
branch
from
July 3, 2026 10:56
ef197dc to
10de1e9
Compare
Contributor
|
Thanks for the focused Z.AI investigation. This is now implemented on current
|
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?
GLM-5.2 accepts an
effortfield (high/max) inside thethinkingobject, per the Z.AI official docs. Without this PR, Hermesreasoning_effortis silently ignored for Z.AI — the configured value never reaches the API.This adds a
ZAIProfilesubclass that overridesbuild_api_kwargs_extras()to emitthinking.type+ optionaleffort, mirroring the DeepSeek profile pattern.Related Issue
Supersedes the effort portion of #45483 (closed as duplicate after #45695 merged the model registration). GLM-5.2 model registration and context length are already on
mainvia #45695 — this PR adds only the missing effort support.Type of Change
Changes Made
plugins/model-providers/zai/__init__.py:ZAIProfile(ProviderProfile)class withbuild_api_kwargs_extras()override_model_supports_effort()guard — GLM-5.2 only, with boundary matching (glm-5.2orglm-5.2-*, notglm-5.20)xhigh/max→thinking.effort=maxhigh→thinking.effort=highnone/minimal/low/medium) → omit (server default =high)reasoning_config=None, returns empty dicts — preserves default wire format for existing GLM users (5.1, 5, 4.x)tests/plugins/model_providers/test_zai_profile.py:How to Test
hermes config set model.default glm-5.2 && hermes config set agent.reasoning_effort xhigh"thinking": {"type": "enabled", "effort": "max"}inextra_bodypytest tests/plugins/model_providers/test_zai_profile.py -v— 35 passedChecklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping
Validation
Effort 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}}Effort was verified against the live Z.AI API:
effort=maxproduces ~55% more reasoning tokens than baseline.Screenshots / Logs
N/A