[PR #5965] [CLOSED] feat(providers): add Z.AI as a native text provider with GLM 5.3 and GLM 5.3 Flash #7005

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5965
Author: @ghost
Created: 9/8/2026
Status: ❌ Closed

Base: staging ← Head: feat/zai-text-provider


📝 Commits (5)

  • bbd7e6a feat(providers): add Z.AI as a native text provider (#5963)
  • 5a24719 fix(generate): an empty reply says what the provider reported (#5963)
  • 18efc2b fix(client): Z.AI key link label goes through the existing locale key (#5963)
  • d372359 fix(generate): the empty-reply sentence quotes the budget that was sent (#5963)
  • e5cccf7 Merge branch 'staging' into feat/zai-text-provider

📊 Changes

17 files changed (+317 additions, -21 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/connections/providers-reference.md (+7 -0)
📝 packages/client/src/components/connections/ConnectionEditor.tsx (+6 -1)
📝 packages/client/src/components/panels/ConnectionsPanel.tsx (+1 -0)
📝 packages/server/src/db/schema/connections.ts (+1 -0)
📝 packages/server/src/routes/connections.routes.ts (+28 -12)
📝 packages/server/src/routes/generate.routes.ts (+19 -5)
➕ packages/server/src/services/generation/empty-response-reason.ts (+75 -0)
📝 packages/server/src/services/generation/generation-parameters.ts (+1 -1)
📝 packages/server/src/services/llm/provider-registry.ts (+1 -0)
📝 packages/server/src/services/llm/providers/openai.provider.ts (+3 -0)
📝 packages/shared/src/constants/model-lists.ts (+16 -1)
📝 packages/shared/src/constants/providers.ts (+11 -0)
📝 packages/shared/src/schemas/connection.schema.ts (+1 -0)
📝 packages/shared/src/types/connection.ts (+1 -0)
📝 scripts/regressions/connection-test-parameters.regression.ts (+35 -1)
📝 scripts/regressions/provider-compat.regression.ts (+109 -0)

📄 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 #5963

Why this change

  • Z.AI is already a first-class image service (#4350) but has no text provider entry. Holding a Z.AI key today means picking Custom and typing the base URL and the model ID by hand, while the server's GLM compat layer already knows GLM 5.3 and the built-in ZAI_MODELS list stopped at 5.2.

What changed

  • zai added to APIProvider, the connection Zod enum, the DB enum, PROVIDERS (Z.AI, https://api.z.ai/api/paas/v4, /models, Bearer auth) and MODEL_LISTS (ZAI_MODELS).
  • glm-5.3 and glm-5.3-flash added to ZAI_MODELS (1M context, 128K output).
  • Server: zai routed to OpenAIProvider in provider-registry.ts; added to the OpenAI-compatible provider lists in connections.routes.ts and generation-parameters.ts; new OpenAIProviderKind member and error label.
  • Shared resolver: resolveProviderReasoningEffort now promotes a Maximum preset to max for the zai provider on GLM 5.2 / 5.3. Before, it lowered Maximum to high before glm53ReasoningEffort ever saw it, so Z.AI's max level was unreachable. Custom connections to api.z.ai behave exactly as before (the resolver has no base URL, so only the named provider is promoted).
  • Client: key link in API_KEY_LINKS (https://z.ai/manage-apikey/apikey-list) and an icon-color entry in ConnectionsPanel. The link label reuses the existing locale key connections.mediaSources.zai.apiKeyLink (same text the image source already shows), so no new hard-coded UI copy.
  • Docs: a Z.AI block in docs/connections/providers-reference.md; a line under [Unreleased] in CHANGELOG.md.
  • Regression: rows in scripts/regressions/provider-compat.regression.ts pin the resolver promotion (and its non-promotion for Custom), the new model rows, and the native request body with and without a configured effort.

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

Screenshot 2026-09-08 at 11 27 21 Screenshot 2026-09-08 at 11 26 15 Screenshot 2026-09-08 at 11 25 50 Screenshot 2026-09-08 at 11 23 13 Screenshot 2026-09-08 at 11 22 57 Screenshot 2026-09-08 at 11 21 29 Screenshot 2026-09-08 at 11 19 59

Verified on macOS arm64: created the Z.AI connection through the picker, sent a roleplay reply through GLM 5.3 with reasoning shown, checked light and dark mode, a narrow viewport, and the bad-key error path.

  • pnpm check passed locally on macOS arm64 (Node 26.4.0, pnpm 10.34.5): stale-client clean, impeccable, localization, format, lint, e2e types, build.
  • node ./scripts/run-regressions.mjs --filter scripts/regressions/provider-compat.regression.ts passed with the new rows in place.
  • Z.AI GET /models on the default base URL answered 200 with a live pay-as-you-go key: ten models, glm-5.3 and glm-5.3-flash among them.
  • Not yet done, which is why this is a draft: creating the connection through the picker in a real browser and sending a roleplay reply through it; light + dark mode and mobile viewport; container build. The boxes above stay unticked until a human has done those and written them up here.

Rebase and re-verification (2026-09-11)

  • Rebased onto staging 8906861ac. Two conflicts: the CHANGELOG bullet, and the empty-response if in generate.routes.ts, which upstream widened with !roleplayActivity.length && !currentRoleplayMedia.length — kept the upstream condition, this PR's body. pnpm check green; provider-compat and connection-test-parameters regressions pass.
  • Ran the rebased build locally against api.z.ai with a real key. Fetch Models returns the account list including glm-5.3 and glm-5.3-flash. Test Message returns text on glm-5.3 (1,024 tokens), glm-5.3-flash and glm-5.2 (200). Reasoning Effort on the wire: Low → low, Medium → high, Extra High → high, Maximum → max. A connection capped at 16 output tokens returns "The model used its whole output budget (16 of 16 output tokens, 15 of them reasoning) before writing any visible text…" from Test Message and from a streamed chat reply.
  • Found and fixed in d372359f1: the sentence quoted the pre-cap budget when the connection's Max Output Tokens override was lower than the preset ("16 of 4096" while the wire carried max_tokens=16). sentOutputBudget() applies the same cap BaseLLMProvider.applyMaxTokensCap applies; pinned in provider-compat.
  • Create Connection → Z.AI in the browser: base URL prefilled with https://api.z.ai/api/paas/v4, key link "Get your Z.AI API key", default model glm-5.3.

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)

Docs touched: docs/connections/providers-reference.md, CHANGELOG.md. The [docs-i18n] follow-up issue will be opened once the wording here has survived review. No version bump.

UI evidence (if applicable)

Screenshots of the provider picker and the connection editor will be added with the manual verification.

Summary by CodeRabbit

  • New Features

    • Added Z.AI as a supported provider with a prefilled endpoint, API-key link, model discovery, and GLM model selection.
    • Added GLM 5.3 and GLM 5.3 Flash support.
    • Maximum reasoning effort now maps to Z.AI’s highest reasoning level for supported GLM models.
  • Bug Fixes

    • Empty model responses now provide actionable explanations, including reasoning-budget and content-policy outcomes.
    • Connection tests allow additional tokens for always-reasoning GLM models.
  • Documentation

    • Added Z.AI provider setup and compatibility guidance.

🔄 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/5965 **Author:** [@ghost](https://github.com/ghost) **Created:** 9/8/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `feat/zai-text-provider` --- ### 📝 Commits (5) - [`bbd7e6a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bbd7e6a2994dcae519652762fe1eb42895a52e92) feat(providers): add Z.AI as a native text provider (#5963) - [`5a24719`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5a247192255a622495a1b9f2a50ec0089456aef1) fix(generate): an empty reply says what the provider reported (#5963) - [`18efc2b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/18efc2b5238cb3ef6dc90b44f2ac63a5a39755ed) fix(client): Z.AI key link label goes through the existing locale key (#5963) - [`d372359`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d372359f1672e850375cdf76732f7ba4a3488d1a) fix(generate): the empty-reply sentence quotes the budget that was sent (#5963) - [`e5cccf7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e5cccf75d93d17565c426bd7ee8373b7b6d1cce4) Merge branch 'staging' into feat/zai-text-provider ### 📊 Changes **17 files changed** (+317 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/connections/providers-reference.md` (+7 -0) 📝 `packages/client/src/components/connections/ConnectionEditor.tsx` (+6 -1) 📝 `packages/client/src/components/panels/ConnectionsPanel.tsx` (+1 -0) 📝 `packages/server/src/db/schema/connections.ts` (+1 -0) 📝 `packages/server/src/routes/connections.routes.ts` (+28 -12) 📝 `packages/server/src/routes/generate.routes.ts` (+19 -5) ➕ `packages/server/src/services/generation/empty-response-reason.ts` (+75 -0) 📝 `packages/server/src/services/generation/generation-parameters.ts` (+1 -1) 📝 `packages/server/src/services/llm/provider-registry.ts` (+1 -0) 📝 `packages/server/src/services/llm/providers/openai.provider.ts` (+3 -0) 📝 `packages/shared/src/constants/model-lists.ts` (+16 -1) 📝 `packages/shared/src/constants/providers.ts` (+11 -0) 📝 `packages/shared/src/schemas/connection.schema.ts` (+1 -0) 📝 `packages/shared/src/types/connection.ts` (+1 -0) 📝 `scripts/regressions/connection-test-parameters.regression.ts` (+35 -1) 📝 `scripts/regressions/provider-compat.regression.ts` (+109 -0) </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 #5963 ## Why this change - Z.AI is already a first-class **image** service (#4350) but has no **text** provider entry. Holding a Z.AI key today means picking Custom and typing the base URL and the model ID by hand, while the server's GLM compat layer already knows GLM 5.3 and the built-in `ZAI_MODELS` list stopped at 5.2. ## What changed - `zai` added to `APIProvider`, the connection Zod enum, the DB enum, `PROVIDERS` (**Z.AI**, `https://api.z.ai/api/paas/v4`, `/models`, Bearer auth) and `MODEL_LISTS` (`ZAI_MODELS`). - `glm-5.3` and `glm-5.3-flash` added to `ZAI_MODELS` (1M context, 128K output). - Server: `zai` routed to `OpenAIProvider` in `provider-registry.ts`; added to the OpenAI-compatible provider lists in `connections.routes.ts` and `generation-parameters.ts`; new `OpenAIProviderKind` member and error label. - Shared resolver: `resolveProviderReasoningEffort` now promotes a **Maximum** preset to `max` for the `zai` provider on GLM 5.2 / 5.3. Before, it lowered Maximum to `high` before `glm53ReasoningEffort` ever saw it, so Z.AI's `max` level was unreachable. Custom connections to `api.z.ai` behave exactly as before (the resolver has no base URL, so only the named provider is promoted). - Client: key link in `API_KEY_LINKS` (`https://z.ai/manage-apikey/apikey-list`) and an icon-color entry in `ConnectionsPanel`. The link label reuses the existing locale key `connections.mediaSources.zai.apiKeyLink` (same text the image source already shows), so no new hard-coded UI copy. - Docs: a Z.AI block in `docs/connections/providers-reference.md`; a line under `[Unreleased]` in `CHANGELOG.md`. - Regression: rows in `scripts/regressions/provider-compat.regression.ts` pin the resolver promotion (and its non-promotion for Custom), the new model rows, and the native request body with and without a configured effort. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [x] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes <img width="528" height="215" alt="Screenshot 2026-09-08 at 11 27 21" src="https://github.com/user-attachments/assets/937e4463-ffb8-4d40-b5c9-d475f7520716" /> <img width="517" height="822" alt="Screenshot 2026-09-08 at 11 26 15" src="https://github.com/user-attachments/assets/cc4cca7c-f5f3-4f54-811c-d4edb44c2c6a" /> <img width="461" height="785" alt="Screenshot 2026-09-08 at 11 25 50" src="https://github.com/user-attachments/assets/b78c9745-8161-4bb1-a611-b3e6a2b34d8e" /> <img width="524" height="276" alt="Screenshot 2026-09-08 at 11 23 13" src="https://github.com/user-attachments/assets/5211a967-34fa-490d-a19b-cfafeaccebdb" /> <img width="509" height="706" alt="Screenshot 2026-09-08 at 11 22 57" src="https://github.com/user-attachments/assets/acfcf32f-4bb8-4ecf-8c04-70a53731401e" /> <img width="744" height="321" alt="Screenshot 2026-09-08 at 11 21 29" src="https://github.com/user-attachments/assets/0267f810-fd3e-4968-91ab-6c45aed0d019" /> <img width="454" height="708" alt="Screenshot 2026-09-08 at 11 19 59" src="https://github.com/user-attachments/assets/bfca9280-3163-4a0b-954b-3894275c4890" /> Verified on macOS arm64: created the Z.AI connection through the picker, sent a roleplay reply through GLM 5.3 with reasoning shown, checked light and dark mode, a narrow viewport, and the bad-key error path. - `pnpm check` passed locally on macOS arm64 (Node 26.4.0, pnpm 10.34.5): stale-client clean, impeccable, localization, format, lint, e2e types, build. - `node ./scripts/run-regressions.mjs --filter scripts/regressions/provider-compat.regression.ts` passed with the new rows in place. - Z.AI `GET /models` on the default base URL answered `200` with a live pay-as-you-go key: ten models, `glm-5.3` and `glm-5.3-flash` among them. - **Not yet done, which is why this is a draft:** creating the connection through the picker in a real browser and sending a roleplay reply through it; light + dark mode and mobile viewport; container build. The boxes above stay unticked until a human has done those and written them up here. ### Rebase and re-verification (2026-09-11) - Rebased onto `staging` 8906861ac. Two conflicts: the CHANGELOG bullet, and the empty-response `if` in `generate.routes.ts`, which upstream widened with `!roleplayActivity.length && !currentRoleplayMedia.length` — kept the upstream condition, this PR's body. `pnpm check` green; `provider-compat` and `connection-test-parameters` regressions pass. - Ran the rebased build locally against `api.z.ai` with a real key. Fetch Models returns the account list including `glm-5.3` and `glm-5.3-flash`. Test Message returns text on `glm-5.3` (1,024 tokens), `glm-5.3-flash` and `glm-5.2` (200). Reasoning Effort on the wire: Low → `low`, Medium → `high`, Extra High → `high`, Maximum → `max`. A connection capped at 16 output tokens returns "The model used its whole output budget (16 of 16 output tokens, 15 of them reasoning) before writing any visible text…" from Test Message and from a streamed chat reply. - Found and fixed in d372359f1: the sentence quoted the pre-cap budget when the connection's Max Output Tokens override was lower than the preset ("16 of 4096" while the wire carried `max_tokens=16`). `sentOutputBudget()` applies the same cap `BaseLLMProvider.applyMaxTokensCap` applies; pinned in `provider-compat`. - Create Connection → Z.AI in the browser: base URL prefilled with `https://api.z.ai/api/paas/v4`, key link "Get your Z.AI API key", default model `glm-5.3`. ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [x] 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) Docs touched: `docs/connections/providers-reference.md`, `CHANGELOG.md`. The `[docs-i18n]` follow-up issue will be opened once the wording here has survived review. No version bump. ## UI evidence (if applicable) Screenshots of the provider picker and the connection editor will be added with the manual verification. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added Z.AI as a supported provider with a prefilled endpoint, API-key link, model discovery, and GLM model selection. - Added GLM 5.3 and GLM 5.3 Flash support. - Maximum reasoning effort now maps to Z.AI’s highest reasoning level for supported GLM models. - **Bug Fixes** - Empty model responses now provide actionable explanations, including reasoning-budget and content-policy outcomes. - Connection tests allow additional tokens for always-reasoning GLM models. - **Documentation** - Added Z.AI provider setup and compatibility guidance. <!-- 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:15:39 +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#7005
No description provided.