Skip to content

fix: add GLM-5.2 to models supporting max reasoning effort - #4467

Merged
akshaydeo merged 4 commits into
maximhq:devfrom
is911:fix/glm-5.2-max-reasoning-effort
Jun 24, 2026
Merged

fix: add GLM-5.2 to models supporting max reasoning effort#4467
akshaydeo merged 4 commits into
maximhq:devfrom
is911:fix/glm-5.2-max-reasoning-effort

Conversation

@is911

@is911 is911 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Description

GLM-5.2 (Z.ai) natively supports reasoning_effort: "max" alongside "high" (Z.ai docs). However, normalizeOpenAIReasoningEffort() silently downgraded "max" to "high" for GLM-5.2 because it was not listed in supportsMaxReasoningEffort(). This is the same normalization gap that previously affected DeepSeek V4 (#4320, fixed in #4330).

Evidence: a direct probe through a Bifrost gateway (v1.5.13) routing to Z.ai GLM-5.2 confirmed that reasoning_effort: "max" sent to Bifrost was forwarded to Z.ai as reasoning_effort: "high" (verified via extra_fields.raw_request).

Type of Change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected Packages

  • core/providers/openai/

Changes Made

  • core/providers/openai/utils.go: Added glm-5.2 to supportsMaxReasoningEffort() so normalizeOpenAIReasoningEffort() returns "max" unchanged for GLM-5.2 models (both bare glm-5.2 and provider-prefixed zai/glm-5.2).
  • core/providers/openai/chat_test.go: Extended TestToOpenAIChatRequest_NormalizesReasoningEffort and TestOpenAIChatRequest_FilterOpenAISpecificParameters_NormalizesReasoningEffort with GLM-5.2 test cases (bare and provider-prefixed).
  • core/providers/openai/responses_test.go: Extended TestToOpenAIResponsesRequest_NormalizesReasoningEffort with GLM-5.2 test cases (bare and provider-prefixed).
  • core/changelog.md: Added changelog entry.

Testing

go test ./core/providers/openai/... -run "NormalizesReasoningEffort|FilterOpenAISpecificParameters" -v -count=1

All tests pass, including the new GLM-5.2 cases:

  • preserves max for glm-5.2
  • preserves max for provider-prefixed glm-5.2

Regression cases for existing models remain unchanged:

  • preserves max for deepseek-v4-pro/flash
  • maps max to xhigh for gpt-5.4
  • maps max to high for gpt-5.1

Code formatted with gofmt. No new lint issues introduced.

Checklist

  • Code follows the project style guidelines (make fmt)
  • Self-reviewed the code
  • Added tests for new behavior
  • All tests pass (go test ./core/providers/openai/...)
  • Changelog updated

Related Issues

Closes #4460

GLM-5.2 (Z.ai) natively supports reasoning_effort "max" (alongside
"high"), but normalizeOpenAIReasoningEffort() silently downgraded
"max" to "high" because GLM-5.2 was not in supportsMaxReasoningEffort().
This is the same normalization gap that previously affected DeepSeek V4
(issue maximhq#4320, PR maximhq#4330).

Affected packages: core/providers/openai/

Closes maximhq#4460
@CLAassistant

CLAassistant commented Jun 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 284b923b-bfa1-4ddf-a05b-5b09411ffc53

📥 Commits

Reviewing files that changed from the base of the PR and between 526254e and 4c56d14.

📒 Files selected for processing (3)
  • core/changelog.md
  • core/providers/openai/chat_test.go
  • core/providers/openai/responses_test.go

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • GLM-5.2 (Z.ai) models now correctly preserve the “max” reasoning effort setting.
    • Improved OpenAI-compatible gateway behavior, including provider handling and better tool-call metadata/results ordering across supported gateways.
  • New Features

    • Added cache diagnostics to help explain cache hits/misses, including first cache-prefix divergence reporting.
  • Tests

    • Expanded/extended reasoning-effort normalization coverage for GLM-5.2, including plain and provider-prefixed model names, with proper provider registration during test runs.

Walkthrough

supportsMaxReasoningEffort now recognizes glm-5.2 model prefixes, a changelog entry was added, and reasoning-effort tests register the zai provider and verify "max" stays unchanged for glm-5.2 models.

Changes

GLM-5.2 max reasoning effort support

Layer / File(s) Summary
supportsMaxReasoningEffort: add glm-5.2 prefix check and document
core/providers/openai/utils.go, core/changelog.md
supportsMaxReasoningEffort now returns true for glm-5.2 prefixes in addition to deepseek-v4, and the changelog records the update.
Test coverage: zai provider registration and glm-5.2 cases
core/providers/openai/chat_test.go, core/providers/openai/responses_test.go
The chat and responses reasoning-effort tests register zai and add cases for both glm-5.2 and zai/glm-5.2 to confirm "max" is preserved.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • danpiths
  • akshaydeo

Poem

🐇 GLM hopped in, asking for more,
max stayed max at the gateway door.
With a prefix tweak bright,
And tests set just right,
The rabbit applauds: "Reasoning restored!"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding GLM-5.2 to the list of models supporting max reasoning effort.
Description check ✅ Passed The PR description is comprehensive and follows the template structure with clear sections for Summary, Type of Change, Affected Packages, Changes Made, Testing, and Checklist.
Linked Issues check ✅ Passed The PR fully addresses issue #4460 by adding GLM-5.2 to supportsMaxReasoningEffort() function and extending tests to verify the fix for both bare and provider-prefixed model names.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the fix for issue #4460: updates to utils.go, test files, and changelog. No unrelated modifications are present.
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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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.

@coderabbitai
coderabbitai Bot requested review from akshaydeo and danpiths June 16, 2026 15:28
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 16, 2026
Signed-off-by: is911 <archilles92@gmail.com>
@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The code change is a one-line allowlist addition with full test coverage; safe to merge once the changelog is trimmed to only the GLM-5.2 entry.

The functional change is minimal and correct — one new prefix check in a pure transformation function with no side effects, matching the established pattern for DeepSeek V4. Tests cover both the bare and provider-prefixed model name and include proper provider registration setup. The only issue is in the changelog, which contains extra entries from other contributors that appear unintentional.

core/changelog.md — contains 8 extra entries attributed to other contributors that should be removed before merging.

Important Files Changed

Filename Overview
core/providers/openai/utils.go Adds glm-5.2 prefix check to supportsMaxReasoningEffort; minimal, correct, and consistent with the existing deepseek-v4 pattern.
core/providers/openai/chat_test.go Adds GLM-5.2 test cases (bare and provider-prefixed) to both reasoning-effort normalization test functions; provider registration/cleanup via defer is correct.
core/providers/openai/responses_test.go Adds equivalent GLM-5.2 test cases to the responses API reasoning-effort normalization test; structurally correct.
core/changelog.md First added line is correct for this PR; the remaining 8 added lines are attributed to other contributors and appear to be unintentionally pulled in from a local branch sync.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["normalizeOpenAIReasoningEffort(model, effort)"] --> B{effort == 'max'?}
    B -- No --> C[handle other cases]
    B -- Yes --> D{supportsMaxReasoningEffort?}
    D -- "Yes: deepseek-v4* OR glm-5.2*" --> E["return 'max' ✅"]
    D -- No --> F{supportsOpenAIXHighReasoningEffort?}
    F -- "Yes: gpt-5.2*, gpt-5.4*, etc." --> G["return 'xhigh'"]
    F -- No --> H["return 'high'"]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["normalizeOpenAIReasoningEffort(model, effort)"] --> B{effort == 'max'?}
    B -- No --> C[handle other cases]
    B -- Yes --> D{supportsMaxReasoningEffort?}
    D -- "Yes: deepseek-v4* OR glm-5.2*" --> E["return 'max' ✅"]
    D -- No --> F{supportsOpenAIXHighReasoningEffort?}
    F -- "Yes: gpt-5.2*, gpt-5.4*, etc." --> G["return 'xhigh'"]
    F -- No --> H["return 'high'"]
Loading

Reviews (3): Last reviewed commit: "Merge branch 'dev' into fix/glm-5.2-max-..." | Re-trigger Greptile

Signed-off-by: is911 <archilles92@gmail.com>

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core/changelog.md`:
- Around line 8-9: Remove lines 8-9 from the changelog.md file as these entries
document fixes for ChatAssistantMessageToolCall.extra_content preservation and
Anthropic prompt-cache diagnostics, which are out of scope for this PR focused
on GLM-5.2 support for max reasoning effort. If these changes are part of other
features, they should be committed to their respective feature branches with
their own changelog entries. Additionally, line 8 uses excessive exclamation
marks (3 total) which deviates from standard changelog style — ensure any
retained changelog entries follow consistent punctuation conventions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 401e1cc1-3850-4589-9f21-ef92be3924ab

📥 Commits

Reviewing files that changed from the base of the PR and between d9c3a51 and 526254e.

📒 Files selected for processing (1)
  • core/changelog.md

Comment thread core/changelog.md
@akshaydeo
akshaydeo force-pushed the dev branch 3 times, most recently from fa15f50 to ca190fc Compare June 21, 2026 11:44
akshaydeo
akshaydeo previously approved these changes Jun 24, 2026
Signed-off-by: Akshay Deo <akshay@akshaydeo.com>
@akshaydeo
akshaydeo merged commit 48576ae into maximhq:dev Jun 24, 2026
3 of 5 checks passed
@coderabbitai
coderabbitai Bot requested a review from akshaydeo June 24, 2026 09:17
akhsaul pushed a commit to akhsaul/bifrost that referenced this pull request Aug 27, 2026
…aximhq#4467)

GLM-5.2 (Z.ai) natively supports reasoning_effort "max" (alongside
"high"), but normalizeOpenAIReasoningEffort() silently downgraded
"max" to "high" because GLM-5.2 was not in supportsMaxReasoningEffort().
This is the same normalization gap that previously affected DeepSeek V4
(issue maximhq#4320, PR maximhq#4330).

Affected packages: core/providers/openai/

Closes maximhq#4460

Signed-off-by: is911 <archilles92@gmail.com>
Signed-off-by: Akshay Deo <akshay@akshaydeo.com>
Co-authored-by: Akshay Deo <akshay@akshaydeo.com>
occcat pushed a commit to occcat/bifrost that referenced this pull request Sep 2, 2026
…aximhq#4467)

GLM-5.2 (Z.ai) natively supports reasoning_effort "max" (alongside
"high"), but normalizeOpenAIReasoningEffort() silently downgraded
"max" to "high" because GLM-5.2 was not in supportsMaxReasoningEffort().
This is the same normalization gap that previously affected DeepSeek V4
(issue maximhq#4320, PR maximhq#4330).

Affected packages: core/providers/openai/

Closes maximhq#4460

Signed-off-by: is911 <archilles92@gmail.com>
Signed-off-by: Akshay Deo <akshay@akshaydeo.com>
Co-authored-by: Akshay Deo <akshay@akshaydeo.com>
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 reasoning_effort "max" silently downgraded to "high" (same normalization gap as #4320 for DeepSeek V4)

3 participants