Skip to content

🤖 fix: send GLM 5.3 reasoning_effort on custom OpenAI-compatible providers - #8149

Merged
ibetitsmike merged 2 commits into
mainfrom
mike/glm-openai-compat-reasoning
Nov 12, 2026
Merged

ibetitsmike merged 2 commits into
mainfrom
mike/glm-openai-compat-reasoning

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Xum opened this PR for Mike.

Summary

GLM 5.3 on a custom OpenAI-compatible provider (for example local oMLX serving GLM-5.3-Flash-oQ4e-mtp) ran every turn at Max thinking, whatever the picker said. Xum now recognizes self-hosted GLM 5.3 ids and sends reasoning_effort (low, high or max) to those providers, and only for models it recognizes as GLM 5.3.

Background

  • buildProviderOptions returned {} for every custom openai-compatible provider, so the SDK never wrote reasoning_effort.
  • GLM's chat template honors only reasoning_effort: "low" and "high". Anything else (absent, medium, xhigh, max) renders "Reasoning Effort: Max".
  • isGlm53Model matched only glm-5.3[-flash] with a digit or latest suffix, so GLM-5.3-Flash-oQ4e-mtp got the default off/low/medium/high picker.

Implementation

  • isGlm53Model (src/common/types/thinking.ts) also accepts the tags that self-hosted deployments append: a - or : followed by a token that carries a digit or names a packaging format (mtp, mlx, gguf, awq, gptq). Ids are already lowercased by stripModelProviderPrefixes. Z.ai's named variants (FlashX, Air, Turbo) are plain words, so they stay unmatched.
  • A new openaiCompatibleGlm53Options helper replaces the final return {} of buildProviderOptions. It returns { openaiCompatible: { reasoningEffort } } when the raw prefix is a custom openai-compatible provider and the capability model (the id, or its mappedToModel) is GLM 5.3. Every OpenAI-compatible chat model reads the openaiCompatible key, whatever the custom provider's name, and the SDK writes it as reasoning_effort. Unrecognized models still get no field, since strict servers may reject unknown fields.
  • The effort mapping is shared with the Z.ai builder (glm53ReasoningEffort): max -> max, high/xhigh -> high, everything else -> low.

Mapping decision

The brief proposed medium -> high and xhigh -> max. The GLM thinking policy (low, high, max) clamps the level before buildProviderOptions runs (medium -> low, xhigh -> high), so those inputs never reach this code on a turn. I reused the Z.ai mapping so the same level behaves the same on Z.ai and on a self-hosted GLM.

Validation

  • Unit tests run the real createOpenAICompatible model against a capturing fetch and assert the reasoning_effort in the request body: every level off..max, a mappedToModel alias, and no field for unrecognized ids (a Qwen id, glm-5.3-flashx). Policy tests cover the new id shapes and the named variants. Three of the new tests fail without the fix.

  • Wire check in a dev-server-sandbox from this branch, with its own providers.jsonc (omlx -> a logging spy -> oMLX):

    Model Picker level Request body
    omlx:GLM-5.3-Flash-oQ4e-mtp low reasoning_effort: "low"
    omlx:GLM-5.3-Flash-oQ4e-mtp high reasoning_effort: "high"
    omlx:GLM-5.3-Flash-oQ4e-mtp max reasoning_effort: "max"
    omlx:spy-unrecognized-model high no reasoning_effort

    On a small puzzle the completion tokens were 5 (low), 5 (high) and 45 (max).

Risks

Low. The new branch runs only for custom openai-compatible providers whose model resolves to GLM 5.3; every other provider path is unchanged. The broader id match also applies to the Z.ai builder and the thinking policy, so a Z.ai id with a deployment tag now gets the GLM levels.

Notes:

  • The per-model default floor is medium for recognized GLM (as for zai:glm-5.3-flash), so the picker shows high and max until the user lowers the floor in Settings > Models. This is the existing GLM behavior.
  • Follow-up, not in this PR: the sidebar status generator (propose_status) sends no provider options for any provider, so GLM status summaries still run at Max.
  • Follow-up, not in this PR: a custom provider whose id shadows a built-in (zai, openai, google, ...) still gets that built-in's provider options, and the OpenAI-compatible SDK spreads them raw onto the request body for every model. Shadowed zai and openai already carry reasoning_effort that way; the others send fields such as thinkingConfig or searchParameters instead. That predates this PR and needs its own change to the format selection.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: xhigh • Cost: $7.47

…iders

isGlm53Model now accepts self-hosted ids with deployment tags in any case
(GLM-5.3-Flash-oQ4e-mtp, ...:q4_K_M, -MLX-4bit, -FP8) and keeps named
variants (FlashX, Air) unmatched. buildProviderOptions sends
openaiCompatible.reasoningEffort (low/high/max, same mapping as Z.ai) to a
custom openai-compatible provider only when the model, or its mappedToModel,
is GLM 5.3. Unrecognized models still get no field.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum posted this comment for Mike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T02:35:41.858658Z 81f894e Manual request
🔒 Security Review ✅ Completed 2026-11-12T02:36:08.993524Z 81f894e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: d2c4164f6d

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d2c4164f6d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/common/utils/ai/providerOptions.ts Resolved
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e stories (Haiku): 14 passed

22 agent steps · 7 replayed from cache · 15 model calls · 47.2k tokens (23% cached)
Spend: $0.09 of the $1.00 cap (proxy ledger)

All 14 tests in 9 files
Test Agent Time
🟢 chatRestart.e2e.ts · 1 passed 1 step · 1 call 5.9s
🟢 a chat survives a restart of the server 1 step · 1 call 5.9s
🟢 compaction.e2e.ts · 1 passed 1 step · 1 call 4.6s
🟢 /compact replaces the old chat with a summary 1 step · 1 call 4.6s
🟢 pluginTrustRestart.e2e.ts · 1 passed 4 steps · 2 calls 10.3s
🟢 a trusted plugin hook stays trusted after the server restarts 4 steps · 2 calls 10.3s
🟢 settingsRoundTrip.e2e.ts · 1 passed 2 steps · 1 call 8.9s
🟢 a chat survives trips through Settings 2 steps · 1 call 8.9s
🟢 sidebarPerWorkspace.e2e.ts · 1 passed 4 steps · 1 call 4.7s
🟢 a new workspace starts with its right sidebar collapsed while another keeps it open 4 steps · 1 call 4.7s
🟢 smoke.e2e.ts · 1 passed 2 steps · 1 call 2.7s
🟢 the agent opens the playground workspace 2 steps · 1 call 2.7s
🟢 streamErrors.e2e.ts · 1 passed 1 step · 1 call 7.1s
🟢 stream errors show in the chat, and the chat recovers 1 step · 1 call 7.1s
🟢 todoNudge.e2e.ts · 1 passed 1 step · 1 call 4.5s
🟢 the agent finishes open TODO items after the turn-end nudge 1 step · 1 call 4.5s
🟢 touchAlignment.e2e.ts · 6 passed 6 steps · 6 calls 29.8s
🟢 the Settings close button is level with the title on a touch screen 390px wide 1 step · 1 call 3.7s
🟢 the Settings close button is level with the title on a touch screen 768px wide 1 step · 1 call 8.0s
🟢 Backup settings checkboxes are small and level with their labels on a touch phone 1 step · 1 call 4.5s
🟢 the heartbeat checkbox is small and level with its label on a touch phone 1 step · 1 call 6.9s
🟢 a reply's model and time stay on one line on a touch phone 1 step · 1 call 3.5s
🟢 the workspace actions menu stays on the title row on a touch phone 1 step · 1 call 3.3s

e2e 0.20.0 · 1m 22s · web · run artifacts

🟢 e2e Electron stories (Haiku): 3 passed

3 agent steps · 3 model calls · 7.9k tokens (22% cached)
Spend: $0.02 of the $1.00 cap (proxy ledger)

All 3 tests in 3 files
Test Agent Time
🟢 electron/deepLink.e2e.ts · 1 passed 1 step · 1 call 6.7s
🟢 a deep link of a second launch starts a chat in the running app 1 step · 1 call 6.7s
🟢 electron/menuBar.e2e.ts · 1 passed 1 step · 1 call 5.7s
🟢 the workspace menu bar is the desktop title bar 1 step · 1 call 5.7s
🟢 electron/smoke.e2e.ts · 1 passed 1 step · 1 call 5.4s
🟢 Xum Electron opens the playground workspace 1 step · 1 call 5.4s

e2e 0.20.0 · 20.3s · electron · run artifacts

🟢 e2e agent repros (Haiku): no tests selected

Spend: $0.00 of the $1.00 cap (proxy ledger)

e2e 0.20.0 · 6.5s · 2 targets (web, phone) · run artifacts

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

I replied on the shadowed-provider thread with wire measurements: a custom provider named zai already sends reasoning_effort, and the general shadowing issue predates this PR, so it is noted as a follow-up in the description. Please take another look.

Xum posted this comment for Mike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: d2c4164f6d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: d2c4164f6d

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

…t-reasoning

# Conflicts:
#	src/common/utils/ai/providerOptions.ts
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Merged origin/main (#8147) to resolve a conflict in the ProviderOptions union and imports; no other change. Please take another look.

Xum posted this comment for Mike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 81f894ea5d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 81f894ea5d

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ibetitsmike
ibetitsmike added this pull request to the merge queue Nov 12, 2026
Merged via the queue into main with commit c0043d9 Nov 12, 2026
34 of 35 checks passed
@ibetitsmike
ibetitsmike deleted the mike/glm-openai-compat-reasoning branch November 12, 2026 02:56
yermakoffivan pushed a commit to yermakoffivan/mux that referenced this pull request Nov 12, 2026
> Xum opened this PR for Mike.

## Summary

Sidebar status summaries (`propose_status`) now run with thinking off,
or with the lowest level the model's policy allows. Before this change
they sent no provider options at all, so each provider ran its own
default effort. On GLM 5.3 served by oMLX that default is Max.

## Background

Follow-up from coder#8149. `generateWorkspaceStatus` created its model with
`createModelWithPinnedMetadata` and called `streamText` without
`providerOptions`. The title generator and the other headless callers
already create through `createModelWithPinnedOptions` and send
`buildProviderOptions(...)` for an explicit level. For most providers an
absent effort means the model default (for example medium reasoning on
OpenAI). GLM's chat template treats an absent `reasoning_effort` as Max:
the coder#8149 wire check measured 287 to 597 reasoning tokens per status
summary.

## Implementation

- Create the status model with `createModelWithPinnedOptions`, so the
request options come from the same config and route snapshot as the
model.
- Request `"off"`, clamped by `enforceThinkingPolicy` to the model's
allowed levels, and send it through `buildProviderOptions`. GLM 5.3 has
no off level, so it gets `reasoning_effort: "low"`.
- The request level is re-derived from the pinned snapshot. If it
differs from the creation level (a config change between the two reads),
the candidate is skipped, as in `workspaceTitleGenerator`: xAI picks its
non-reasoning variant only for an explicit "off".
- The per-model slider floor is not applied: this is a background call,
as with the naming fallbacks.

## Validation

- New test runs the real `AIService` and SDK against a loopback server
and checks each request body: `omlx:GLM-5.3-Flash-oQ4e-mtp` sends
`reasoning_effort: "low"` and `openai:gpt-6.1-sol` sends
`reasoning.effort: "low"`. Without the fix the GLM request had no
`reasoning_effort` (test fails). A second test forces the snapshot
mismatch and asserts no request is sent.

## Risks

Low. Only the sidebar status request changes. Providers that already
defaulted to no thinking keep it; providers that defaulted higher now
think less, which is the intended behavior for this cheap background
call.

---

_Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking:
`high` • Cost: `$5.61`_

<!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=high
costs=5.61 -->
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.

1 participant