[codex] fix Zhipu coding plan presets#3524
Merged
Merged
Conversation
makoMakoGo
force-pushed
the
codex/fix-zhipu-coding-plan-presets
branch
from
June 1, 2026 15:13
b3237ae to
b2b8f60
Compare
makoMakoGo
marked this pull request as ready for review
June 1, 2026 15:16
makoMakoGo
marked this pull request as draft
June 1, 2026 15:24
Collaborator
Author
|
原本想要 把 preset display name 也修正为 Coding Plan 的 ....... 我在思考这个 pr 到底值不值得。算了我觉得还是值得的,虽然小(智谱 x 某华学校交流群 之前也有例子被这个预设困惑过的....),毕竟用 GLM 预设的基本都是 Coding Plan 用户。 只改 url,不扩大到 preset display name 也修正了。 |
makoMakoGo
force-pushed
the
codex/fix-zhipu-coding-plan-presets
branch
from
June 1, 2026 15:30
6b312ef to
e50ba8b
Compare
makoMakoGo
marked this pull request as ready for review
June 1, 2026 15:33
Collaborator
Author
|
顺带提一个已知问题,当前 获取 模型逻辑 在不已 v1 结尾时 补 v1/models,对于智谱这种 v4 这种结尾的 只补 /models 就行,多了反而请求错误。所以 pr 里 没管,这块逻辑动起来比较麻烦。 |
Owner
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 ℹ️ 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". |
The model-list probe assumed any base URL not ending in /v1 needs /v1/models appended. For providers whose base URL already ends in a version segment like /v4 (Zhipu/Z.AI GLM Coding Plan at .../api/coding/paas/v4), this produced .../v4/v1/models which 404s, so the "Fetch models" button always failed.
Detect a trailing /v{N} version segment and probe {base}/models first, keeping /v1/models as a fallback candidate for non-/v1 versions. Fixes Codex/OpenCode/OpenClaw/Hermes GLM presets and any other vN-style endpoint, with no behavior change for /v1 or non-versioned URLs.
3 tasks
gfunc
pushed a commit
to gfunc/cc-switch
that referenced
this pull request
Jun 19, 2026
* fix(presets): update Zhipu coding plan endpoints
* fix(model-fetch): probe /models on versioned /vN base URLs
The model-list probe assumed any base URL not ending in /v1 needs /v1/models appended. For providers whose base URL already ends in a version segment like /v4 (Zhipu/Z.AI GLM Coding Plan at .../api/coding/paas/v4), this produced .../v4/v1/models which 404s, so the "Fetch models" button always failed.
Detect a trailing /v{N} version segment and probe {base}/models first, keeping /v1/models as a fallback candidate for non-/v1 versions. Fixes Codex/OpenCode/OpenClaw/Hermes GLM presets and any other vN-style endpoint, with no behavior change for /v1 or non-versioned URLs.
---------
Co-authored-by: Jason <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
摘要
修正智谱 / Z.AI GLM 预设在 OpenAI-compatible 应用里的默认端点,让这组预设实际走到 Coding Plan 对应的调用路径。
Closes #3471 (#3471)
背景
大多数用户选择这组预设时,预期是使用已订阅的 Coding Plan 额度,而不是普通 GLM API 计费路径。如果新增 coding plan 专用预设的话,考虑到当前预设数量已经很多了,感觉不好,并且 Claude Code 那块的语义已经差不多默认当前预设是 GLM Coding Plan 了,如 #3471。
并且智谱的端点规则比较特殊:
https://open.bigmodel.cn/api/anthropic/api/paas/v4或/v1这类普通端点/api/coding/paas/v4Anthropic-compatible 侧和 OpenAI-compatible 侧的端点规则并不对称。之前 Codex / OpenCode / OpenClaw / Hermes 的相关预设使用了普通 OpenAI-compatible 端点,用户选择预设后仍可能没有走到 Coding Plan 对应的调用路径(如 #3471)。
改动
https://open.bigmodel.cn/api/coding/paas/v4https://api.z.ai/api/coding/paas/v4本次不修改预设展示名、provider key、模型 ID、Codex TOML provider name、OpenCode
settingsConfig.name、Hermes provider name 等标识字段;只修正默认端点,因此不会影响已有用户配置,也不需要数据迁移。Validation
pnpm exec prettier --check src/config/codexProviderPresets.ts src/config/opencodeProviderPresets.ts src/config/openclawProviderPresets.ts src/config/hermesProviderPresets.ts tests/config/codexChatProviderPresets.test.tspnpm exec tsc --noEmit --ignoreDeprecations 5.0pnpm exec vitest run tests/config/codexChatProviderPresets.test.ts tests/config/opencodeProviderPresets.test.ts