Repository navigation
🤖 fix: send GLM 5.3 reasoning_effort on custom OpenAI-compatible providers - #8149
Conversation
…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.
|
@codex review
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 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".
🟢 e2e stories (Haiku): 14 passed22 agent steps · 7 replayed from cache · 15 model calls · 47.2k tokens (23% cached) All 14 tests in 9 files
e2e 0.20.0 · 1m 22s · web · run artifacts 🟢 e2e Electron stories (Haiku): 3 passed3 agent steps · 3 model calls · 7.9k tokens (22% cached) All 3 tests in 3 files
e2e 0.20.0 · 20.3s · electron · run artifacts 🟢 e2e agent repros (Haiku): no tests selectedSpend: $0.00 of the $1.00 cap (proxy ledger) e2e 0.20.0 · 6.5s · 2 targets (web, phone) · run artifacts |
|
@codex review I replied on the shadowed-provider thread with wire measurements: a custom provider named
|
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
…t-reasoning # Conflicts: # src/common/utils/ai/providerOptions.ts
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
> 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 -->
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 sendsreasoning_effort(low,highormax) to those providers, and only for models it recognizes as GLM 5.3.Background
buildProviderOptionsreturned{}for every customopenai-compatibleprovider, so the SDK never wrotereasoning_effort.reasoning_effort: "low"and"high". Anything else (absent,medium,xhigh,max) renders "Reasoning Effort: Max".isGlm53Modelmatched onlyglm-5.3[-flash]with a digit orlatestsuffix, soGLM-5.3-Flash-oQ4e-mtpgot 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 bystripModelProviderPrefixes. Z.ai's named variants (FlashX,Air,Turbo) are plain words, so they stay unmatched.openaiCompatibleGlm53Optionshelper replaces the finalreturn {}ofbuildProviderOptions. It returns{ openaiCompatible: { reasoningEffort } }when the raw prefix is a customopenai-compatibleprovider and the capability model (the id, or itsmappedToModel) is GLM 5.3. Every OpenAI-compatible chat model reads theopenaiCompatiblekey, whatever the custom provider's name, and the SDK writes it asreasoning_effort. Unrecognized models still get no field, since strict servers may reject unknown fields.glm53ReasoningEffort):max->max,high/xhigh->high, everything else ->low.Mapping decision
The brief proposed
medium->highandxhigh->max. The GLM thinking policy (low,high,max) clamps the level beforebuildProviderOptionsruns (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
createOpenAICompatiblemodel against a capturingfetchand assert thereasoning_effortin the request body: every level off..max, amappedToModelalias, 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-sandboxfrom this branch, with its ownproviders.jsonc(omlx-> a logging spy -> oMLX):omlx:GLM-5.3-Flash-oQ4e-mtpreasoning_effort: "low"omlx:GLM-5.3-Flash-oQ4e-mtpreasoning_effort: "high"omlx:GLM-5.3-Flash-oQ4e-mtpreasoning_effort: "max"omlx:spy-unrecognized-modelreasoning_effortOn a small puzzle the completion tokens were 5 (low), 5 (high) and 45 (max).
Risks
Low. The new branch runs only for custom
openai-compatibleproviders 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:
mediumfor recognized GLM (as forzai: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.propose_status) sends no provider options for any provider, so GLM status summaries still run at Max.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. Shadowedzaiandopenaialready carryreasoning_effortthat way; the others send fields such asthinkingConfigorsearchParametersinstead. 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