Skip to content

feat(providers): GLM-5.2 native reasoning_effort controls (port kilocode#11555) - #51108

Closed
teknium1 wants to merge 1 commit into
mainfrom
kilocode-port/glm-5.2-reasoning-effort
Closed

feat(providers): GLM-5.2 native reasoning_effort controls (port kilocode#11555)#51108
teknium1 wants to merge 1 commit into
mainfrom
kilocode-port/glm-5.2-reasoning-effort

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

GLM-5.2's reasoning effort preference now reaches the model on both Z.AI routes — previously it was silently dropped.

GLM-5.2 exposes a native reasoning_effort knob with two enabled levels (high / max) on its OpenAI-compatible endpoints. The zai profile (direct Z.AI /api/paas/v4) used the base ProviderProfile and emitted no reasoning controls at all, and the OpenCode Go profile only handled Kimi K2 / DeepSeek — so a user setting reasoning effort on GLM-5.2 had no effect on either route.

Ported from Kilo-Org/kilocode#11555, adapted to hermes-agent's provider-profile architecture.

Changes

  • plugins/model-providers/zai/__init__.py: base profile → ZaiProfile with GLM-5.2 effort mapping (xhigh/maxmax; lower enabled levels → high; disabled/unset → server default).
  • plugins/model-providers/opencode-zen/__init__.py: same GLM-5.2 mapping added to OpenCodeGoProfile, alongside the existing Kimi/DeepSeek branches.
  • Alias spellings recognized: glm-5.2, glm-5-2, glm-5p2, and vendor-prefixed forms (z-ai/glm-5.2, accounts/fireworks/models/glm-5p2).
  • Tests: new test_zai_profile.py (18) + GLM-5.2 cases added to test_opencode_go_profile.py.

Adaptation notes

Kilo Code maps three SDK shapes (@openrouter/ai-sdk-provider → high/xhigh, @ai-sdk/openai-compatible → high/max, @ai-sdk/anthropic → effort high/max). Hermes already passes the full reasoning_config through to OpenRouter as extra_body.reasoning (xhigh handled there), so this PR only needs the two OpenAI-compatible direct routes hermes owns: Z.AI direct and OpenCode Go. GLM-5.2 on these routes has exactly two enabled effort levels per Z.AI/BigModel docs, so the richer Hermes scale clamps onto high/max.

Validation

Before After
zai GLM-5.2 effort=max (no reasoning sent) reasoning_effort: max
zai GLM-5.2 effort=medium (no reasoning sent) reasoning_effort: high
opencode-go GLM-5.2 effort=xhigh (no reasoning sent) reasoning_effort: max
GLM-5.1 / GLM-5 / Kimi / DeepSeek unchanged unchanged

47 targeted tests pass. E2E verified through the real ChatCompletionsTransport.build_kwargs() with real provider discovery against a temp HERMES_HOME — effort reaches the wire, no extra_body pollution, non-target models and Kimi/DeepSeek paths unaffected.

Port from Kilo-Org/kilocode#11555: GLM-5.2 exposes a native
reasoning_effort knob with two enabled levels (high / max) on its
OpenAI-compatible endpoints. Previously the zai profile (direct Z.AI
/api/paas/v4) used the base ProviderProfile and emitted nothing, and the
OpenCode Go profile only handled Kimi K2 / DeepSeek — so a user's effort
preference for GLM-5.2 was silently dropped on both routes.

- zai: ZaiProfile maps effort onto high/max (xhigh/max -> max, lower -> high)
- opencode-go: same mapping for GLM-5.2, alongside existing Kimi/DeepSeek
- alias spellings recognized (glm-5.2 / glm-5-2 / glm-5p2, vendor-prefixed)
- disabled / no effort leaves the server default untouched
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: kilocode-port/glm-5.2-reasoning-effort vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 11464 on HEAD, 11461 on base (🆕 +3)

🆕 New issues (3):

Rule Count
unresolved-attribute 2
unresolved-import 1
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_credits_session_start_micros` on type `AIAgent`
tests/plugins/model_providers/test_zai_profile.py:9: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`
run_agent.py:2984: [unresolved-attribute] unresolved-attribute: Object of type `Self@get_credits_spent_micros` has no attribute `_credits_session_start_micros`

✅ Fixed issues (1):

Rule Count
invalid-assignment 1
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [invalid-assignment] invalid-assignment: Object of type `None` is not assignable to attribute `_credits_session_start_micros` of type `int`

Unchanged: 6037 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/feature New feature or request comp/plugins Plugin system and bundled plugins provider/zai ZAI provider P3 Low — cosmetic, nice to have labels Jun 23, 2026
@teknium1

teknium1 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via PR #58884, re-applied onto current main. The original branch predated the thinking-off fix (5a6720b) and would have reverted it; the salvage merges both behaviors — GLM-5.2 now sends thinking: enabled plus reasoning_effort together.

@teknium1 teknium1 closed this Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have provider/zai ZAI provider type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants