[PR #5734] [CLOSED] fix(llm): preserve mandatory GLM 5.3 reasoning on custom and native Z.Ai endpoints #6910

Closed
opened 2026-10-23 04:14:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5734
Author: @tempestnano
Created: 9/1/2026
Status: ❌ Closed

Base: staging ← Head: fix/5582-glm-5-3-mandatory-reasoning-custom-native


📝 Commits (1)

  • fcb2349 fix(llm): keep GLM 5.3 mandatory reasoning on custom and native endpoints

📊 Changes

4 files changed (+94 additions, -15 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/services/llm/providers/glm-request-compat.ts (+11 -4)
📝 packages/server/src/services/llm/providers/openai.provider.ts (+4 -4)
📝 scripts/regressions/provider-compat.regression.ts (+78 -7)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #5582 — follow-up to #5683. #5582 was closed by #5683, but the reporter's configuration (a custom OpenAI-compatible connection, not OpenRouter/NanoGPT) still failed; this PR closes the remaining gap, so the issue may need reopening until this merges.

Why this change

The reporter's connection is a custom endpoint pointing at https://api.z.ai/api/coding/paas/v4 with model glm-5.3-flash (plain glm-5.3 behaves the same). #5683 fixed OpenRouter and NanoGPT, but two remaining request paths still sent a reasoning-disable that Z.Ai rejects with 400: This model always engages in thinking and cannot be disabled; please use low, high, or max:

  1. Because api.z.ai is a native-GLM hostname, the GLM request shim stamped enable_thinking: false into every request — including a bare connection Test Message that passes no reasoning options at all ("no preference" collapsed to "disable").
  2. For custom endpoints whose hostname is not a GLM-native host, the generic custom branch sent reasoning_effort: "none" for the same models.

The detector also matched only the exact string glm-5.3-flash, so plain glm-5.3 would hit the identical rejection.

What changed

  • Renamed isGlm53FlashMandatoryReasoningModel → isGlm53MandatoryReasoningModel and widened it to the whole GLM 5.3 family (glm-5.3, glm-5.3-flash, provider-prefixed and suffixed variants; still excludes glm-5.2 and would not match glm-5.35).
  • applyGlmThinkingParameters: on native GLM endpoints, GLM 5.3 models with no active reasoning request now omit enable_thinking entirely instead of sending enable_thinking: false, deferring to the provider's always-on default. NanoGPT keeps its required explicit enable_thinking: true. Older GLMs (e.g. glm-5) keep the working explicit disable, and glm-5.2 keeps its thinking.type handling — both locked by new regression assertions.
  • Generic custom OpenAI-compatible branch: skip reasoning_effort: "none" for GLM 5.3 family models.
  • OpenRouter disable-support gate now excludes plain glm-5.3 as well (via the renamed detector).
  • Extended provider-compat regression coverage: native bare/none/enable cases, NanoGPT plain 5.3, custom-branch end-to-end, OpenRouter plain 5.3, and detector edge cases.
  • Added a [Unreleased] CHANGELOG entry.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Automated request-body proof:

  • pnpm regression:node --filter provider-compat — passes, including the new native/custom/OpenRouter GLM 5.3 cases.
  • pnpm regression:node --filter agent-runtime — passes.
  • Reproduced the original failure shape (custom provider, https://api.z.ai/api/coding/paas/v4, glm-5.3-flash) against a local capture server: before the fix the request body contained enable_thinking: false; after the fix no reasoning-disable fields are present.

Live verification (performed by the reporter on the real Z.Ai endpoint with provider credentials):

  • Manually verified a connection Test Message against the Z.Ai custom connection with glm-5.3-flash — succeeds after the fix.
  • Manually verified the same against glm-5.3 — succeeds after the fix.

Still open before merge (unticked above on purpose):

  • Container build was not exercised for this change.
  • OpenRouter and NanoGPT 5.3 paths rest on the request-body regressions only; a maintainer with those provider credentials may want to spot-check live behavior.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

The CHANGELOG [Unreleased] entry is included in this PR; no other docs, translations, or version files are affected (server-side request shaping only).

UI evidence (if applicable)

Not applicable. This change only updates server-side provider request shaping.

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility with Z.Ai and other OpenAI-compatible providers serving GLM 5.3 models.
    • Prevented rejected reasoning-disable parameters for models that always enable reasoning.
    • Added support for both standard and Flash GLM 5.3 variants while preserving legacy GLM behavior.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/5734 **Author:** [@tempestnano](https://github.com/tempestnano) **Created:** 9/1/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `fix/5582-glm-5-3-mandatory-reasoning-custom-native` --- ### 📝 Commits (1) - [`fcb2349`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fcb23494bc9e9fdd87b396de1a562e967a5ba0d1) fix(llm): keep GLM 5.3 mandatory reasoning on custom and native endpoints ### 📊 Changes **4 files changed** (+94 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/services/llm/providers/glm-request-compat.ts` (+11 -4) 📝 `packages/server/src/services/llm/providers/openai.provider.ts` (+4 -4) 📝 `scripts/regressions/provider-compat.regression.ts` (+78 -7) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #5582 — follow-up to #5683. #5582 was closed by #5683, but the reporter's configuration (a **custom** OpenAI-compatible connection, not OpenRouter/NanoGPT) still failed; this PR closes the remaining gap, so the issue may need reopening until this merges. ## Why this change The reporter's connection is a custom endpoint pointing at `https://api.z.ai/api/coding/paas/v4` with model `glm-5.3-flash` (plain `glm-5.3` behaves the same). #5683 fixed OpenRouter and NanoGPT, but two remaining request paths still sent a reasoning-disable that Z.Ai rejects with `400: This model always engages in thinking and cannot be disabled; please use low, high, or max`: 1. Because `api.z.ai` is a native-GLM hostname, the GLM request shim stamped `enable_thinking: false` into **every** request — including a bare connection Test Message that passes no reasoning options at all ("no preference" collapsed to "disable"). 2. For custom endpoints whose hostname is not a GLM-native host, the generic custom branch sent `reasoning_effort: "none"` for the same models. The detector also matched only the exact string `glm-5.3-flash`, so plain `glm-5.3` would hit the identical rejection. ## What changed - Renamed `isGlm53FlashMandatoryReasoningModel` → `isGlm53MandatoryReasoningModel` and widened it to the whole GLM 5.3 family (`glm-5.3`, `glm-5.3-flash`, provider-prefixed and suffixed variants; still excludes `glm-5.2` and would not match `glm-5.35`). - `applyGlmThinkingParameters`: on native GLM endpoints, GLM 5.3 models with no active reasoning request now omit `enable_thinking` entirely instead of sending `enable_thinking: false`, deferring to the provider's always-on default. NanoGPT keeps its required explicit `enable_thinking: true`. Older GLMs (e.g. `glm-5`) keep the working explicit disable, and `glm-5.2` keeps its `thinking.type` handling — both locked by new regression assertions. - Generic custom OpenAI-compatible branch: skip `reasoning_effort: "none"` for GLM 5.3 family models. - OpenRouter disable-support gate now excludes plain `glm-5.3` as well (via the renamed detector). - Extended `provider-compat` regression coverage: native bare/none/enable cases, NanoGPT plain 5.3, custom-branch end-to-end, OpenRouter plain 5.3, and detector edge cases. - Added a `[Unreleased]` CHANGELOG entry. ## Validation - [x] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes Automated request-body proof: - `pnpm regression:node --filter provider-compat` — passes, including the new native/custom/OpenRouter GLM 5.3 cases. - `pnpm regression:node --filter agent-runtime` — passes. - Reproduced the original failure shape (custom provider, `https://api.z.ai/api/coding/paas/v4`, `glm-5.3-flash`) against a local capture server: before the fix the request body contained `enable_thinking: false`; after the fix no reasoning-disable fields are present. Live verification (performed by the reporter on the real Z.Ai endpoint with provider credentials): - Manually verified a connection Test Message against the Z.Ai custom connection with `glm-5.3-flash` — succeeds after the fix. - Manually verified the same against `glm-5.3` — succeeds after the fix. Still open before merge (unticked above on purpose): - Container build was not exercised for this change. - OpenRouter and NanoGPT 5.3 paths rest on the request-body regressions only; a maintainer with those provider credentials may want to spot-check live behavior. ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) The CHANGELOG `[Unreleased]` entry is included in this PR; no other docs, translations, or version files are affected (server-side request shaping only). ## UI evidence (if applicable) Not applicable. This change only updates server-side provider request shaping. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved compatibility with Z.Ai and other OpenAI-compatible providers serving GLM 5.3 models. * Prevented rejected reasoning-disable parameters for models that always enable reasoning. * Added support for both standard and Flash GLM 5.3 variants while preserving legacy GLM behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:14:48 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6910
No description provided.