Skip to content

feat: add glm-5.2 support#608

Open
MobCode100 wants to merge 3 commits into
Zoo-Code-Org:mainfrom
MobCode100:GLM-5.2
Open

feat: add glm-5.2 support#608
MobCode100 wants to merge 3 commits into
Zoo-Code-Org:mainfrom
MobCode100:GLM-5.2

Conversation

@MobCode100

@MobCode100 MobCode100 commented Jun 13, 2026

Copy link
Copy Markdown

Introduces a Max reasoning-effort tier; High is the default and Max is opt-in.

Related GitHub Issue

Closes: #597

Description

Adds support for Zhipu's GLM-5.2 model to the Z.ai provider.

Key implementation details:

  • Registers glm-5.2 in both the international and mainland Z.ai model maps packages/types/src/providers/zai.ts with a 1M context window, 128k max output, and prompt caching. Pricing is not released yet at this time.
  • Introduces "max" as a new reasoning-effort tier across the model schema packages/types/src/model.ts (confirmed against the API: reasoning_effort accepts none|minimal|low|medium|high|xhigh|max).
  • Wires reasoning_effort onto the Z.ai wire request in the handler src/api/providers/zai.ts. Design choice: High is the default, Max is opt-in. The parameter is omitted entirely when reasoning is disabled.
  • Casts the request params to the OpenAI streaming type at the create() call site, matching the established pattern in the deepseek handler.

Test Procedure

cd src && pnpm vitest run api/providers/__tests__/zai.spec.ts && cd ..

Result: 47/47 tests pass, including 5 new tests:

GLM-5.2 international config round-trip (1M context, High/Max tiers, pricing)
GLM-5.2 mainland config round-trip (pricing)
reasoning_effort: "high" sent by default (model default)
reasoning_effort: "max" sent when the user opts into Max
reasoning_effort omitted (and thinking disabled) when reasoning is off

Tested on built extension running pnpm vsix.

Pre-Submission Checklist

  • [ x] Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • [ x] Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • [ x] Self-Review: I have performed a thorough self-review of my code.
  • [ x] Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • [ x] Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • [ x] Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A — no UI layout changes.

Documentation Updates

  • [x ] No documentation updates are required.

Additional Notes

  • GLM-5.2's default max output resolves to 131,072 (its full ceiling) as the ceiling is lower than the max context's 20%.
  • Using GLM-5.1's pricing as GLM-5.2 pricing was not yet published.

Get in Touch

MobCode100

Summary by CodeRabbit

  • New Features

    • Added GLM‑5.2 model support (1M token context, up to 128k output).
    • Added a new “Max” reasoning-effort tier for compatible models; the default remains High, and reasoning-effort is not sent when reasoning is disabled.
  • Localization

    • Added the “Max” reasoning-effort label across supported UI languages.
  • Tests

    • Expanded coverage for GLM‑5.2 model configuration and reasoning-effort behavior (including defaults, Max, disable/omission, and fallback handling).

Introduces a Max reasoning-effort tier; High is the default and Max is opt-in.
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 51e9fd02-bdcb-42af-80ea-1a39aa480b6e

📥 Commits

Reviewing files that changed from the base of the PR and between 5ed5288 and 597280c.

📒 Files selected for processing (3)
  • packages/types/src/providers/zai.ts
  • src/api/providers/__tests__/zai.spec.ts
  • src/api/providers/zai.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/types/src/providers/zai.ts
  • src/api/providers/zai.ts
  • src/api/providers/tests/zai.spec.ts

📝 Walkthrough

Walkthrough

Adds GLM-5.2 support and a new "max" reasoning-effort tier: extends types/schemas, inserts glm-5.2 into Z.ai model catalogs, implements conditional streaming of reasoning_effort in ZAi requests, adds tests for payload behavior, and updates UI locale strings and changeset metadata.

Changes

GLM-5.2 Reasoning Effort Support

Layer / File(s) Summary
Type System Extension for Reasoning Effort Tiers
packages/types/src/model.ts
reasoningEffortsExtended and reasoningEffortSettingValues now include "max", and modelInfoSchema permits "max" in supportsReasoningEffort arrays.
GLM-5.2 Model Definitions
packages/types/src/providers/zai.ts
Adds glm-5.2 to internationalZAiModels and mainlandZAiModels with 1,000,000-token context, supportsMaxTokens, reasoning-effort support (disable/high/max), default reasoningEffort: "high", and updated pricing/cache fields.
ZAiHandler Reasoning Effort Streaming Logic
src/api/providers/zai.ts
ZAiChatCompletionParams adds a Z.ai-specific reasoning_effort union (including "max"). createStreamWithThinking derives reasoningEffort from user settings or model default when enabled, treats "disable" as undefined to omit the param, and includes reasoning_effort in the stream request.
Model Configuration and Reasoning Effort Behavior Tests
src/api/providers/__tests__/zai.spec.ts
Adds tests validating glm-5.2 model configs (1M context, supportsMaxTokens, pricing/cache) and tests verifying createMessage sends thinking plus reasoning_effort by default (high), when set to max, and omits reasoning_effort when disable.
UI Localization and Release Metadata
webview-ui/src/i18n/locales/*/settings.json, .changeset/add-glm-5-2-support.md
Adds "max" label to reasoning effort UI options across 17 locales and includes a changeset documenting default/explicit/disabled reasoning_effort handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • taltas
  • navedmerchant
  • hannesrudolph
  • JamesRobert20
  • edelauna

Poem

🐰 A new GLM hops in, with thinking turned to "Max",
Types stretched wide, models added, tests confirm the facts,
Streams carry tidy flags when reasoning's on,
Disabled they vanish—quiet as dawn,
Rabbit cheers: "Deep thoughts, now pick your tracks!"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding GLM-5.2 support to the codebase.
Description check ✅ Passed The PR description is comprehensive and follows the template with all major sections completed: issue linked, detailed implementation explanation, test procedures with results, and pre-submission checklist marked.
Linked Issues check ✅ Passed The code changes fully implement the objective from issue #597 to add GLM-5.2 support, including model registration, reasoning-effort configuration, and handler implementation.
Out of Scope Changes check ✅ Passed All changes are directly scoped to adding GLM-5.2 support: model definitions, reasoning-effort schema updates, handler implementation, tests, and i18n translations. No extraneous modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/api/providers/zai.ts 80.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@edelauna edelauna left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding this - had a couple comments related to the implementation.

Comment thread src/api/providers/zai.ts Outdated
Comment thread src/api/providers/zai.ts Outdated
Comment thread packages/types/src/providers/zai.ts
…is unsupported

Persisted reasoning effort not offered by the current model now falls back to the model default instead of silently disabling reasoning. Also wraps create() in handleOpenAIError for consistency with the base class, and flags GLM-5.2 pricing as provisional (mirrors GLM-5.1).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

glm 5.2 is coming, please support it

2 participants