Skip to content

fix(openai): 移除已下线 Codex 模型的内置重定向#1759

Open
specialpointcentral wants to merge 1 commit intoWei-Shaw:mainfrom
specialpointcentral:fix/issue-1758-codex-models
Open

fix(openai): 移除已下线 Codex 模型的内置重定向#1759
specialpointcentral wants to merge 1 commit intoWei-Shaw:mainfrom
specialpointcentral:fix/issue-1758-codex-models

Conversation

@specialpointcentral
Copy link
Copy Markdown

说明

修复 ChatGPT 登录用户在 Codex/OAuth 路径下,仍会被内置模型映射重定向到已下线模型的问题。

Closes #1758

改动内容

  • 后端移除对以下已下线模型的内置重定向:
    • gpt-5
    • gpt-5.1
    • gpt-5.1-codex
    • gpt-5.1-codex-max
    • gpt-5.1-codex-mini
    • gpt-5.2-codex
  • 将 Codex/OAuth 模型归一化的默认兜底切换到仍可用模型
  • 保留并修正当前仍可用模型的映射行为:
    • gpt-5.4
    • gpt-5.4-mini
    • gpt-5.3-codex
    • gpt-5.3-codex-spark
    • gpt-5.2
  • 更新默认测试模型,避免继续使用已下线模型
  • 前端移除已下线模型的白名单、预设映射与配置模板项,避免继续展示给用户

验证

后端

  • go test ./internal/service ./internal/pkg/openai -run 'TestNormalizeCodexModel|TestDefaultModels_RemovedCodexModelsExcluded|TestNormalizeOpenAIModelForUpstream|TestResolveOpenAIForwardModel_PreventsClaudeModelFromFallingBackToGpt51'

前端

  • pnpm test:run src/composables/__tests__/useModelWhitelist.spec.ts
  • pnpm typecheck

影响范围

  • OpenAI OAuth / Codex 模型归一化
  • OpenAI 默认模型列表与测试模型
  • 前端 OpenAI 模型白名单与配置生成

Copilot AI review requested due to automatic review settings April 20, 2026 06:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

该 PR 修复 ChatGPT 登录(Codex/OAuth)路径下仍被内置映射重定向到已下线模型的问题,并同步前后端默认/白名单模型配置,确保只暴露仍可用的模型集合。

Changes:

  • 后端移除已下线 Codex 模型的内置重定向,并将 Codex/OAuth 归一化默认兜底切换到可用模型(如 gpt-5.4 / gpt-5.3-codex)。
  • 前端移除已下线模型的白名单/预设映射/配置模板项,避免继续展示给用户。
  • 更新并新增相关单测,覆盖“移除模型不再暴露/回退到可用目标”等行为。

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
frontend/src/composables/useModelWhitelist.ts 更新 OpenAI 模型白名单与预设映射,移除下线模型
frontend/src/composables/tests/useModelWhitelist.spec.ts 更新/新增前端白名单相关断言,验证下线模型不再暴露
frontend/src/components/keys/UseKeyModal.vue 移除已下线模型的配置模板项,避免生成过期配置
backend/internal/service/openai_model_mapping_test.go 调整 OpenAI/Codex 归一化与回退行为的测试期望
backend/internal/service/openai_codex_transform_test.go 新增/更新 Codex 模型归一化回退到可用目标的测试
backend/internal/service/openai_codex_transform.go 移除下线模型映射、更新 normalizeCodexModel 默认兜底与 spark 保留策略
backend/internal/pkg/openai/constants.go 更新默认 OpenAI 模型列表与默认测试模型
backend/internal/pkg/openai/constants_test.go 新增测试确保默认模型列表排除已下线模型并更新默认测试模型

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 21 to 25
// GPT-5.4 系列
'gpt-5.4', 'gpt-5.4-mini', 'gpt-5.4-nano', 'gpt-5.4-2026-03-05',
'gpt-5.4', 'gpt-5.4-mini', 'gpt-5.4-2026-03-05',
// GPT-5.3 系列
'gpt-5.3-codex', 'gpt-5.3-codex-spark',
'chatgpt-4o-latest',
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

openaiModelsgpt-5.3-codex-spark 被重复加入(这里的 GPT-5.3 系列已包含一次,前面 GPT-5 系列段落也包含一次),会导致下拉/白名单列表出现重复项。建议只保留一个条目并将其放在对应的 GPT-5.3 分组下(同时调整上方分组注释避免误导)。

Copilot uses AI. Check for mistakes.
Comment on lines 74 to +78
Credentials: map[string]any{},
}

withoutDefault := normalizeCodexModel(resolveOpenAIForwardModel(account, "claude-opus-4-6", ""))
if withoutDefault != "gpt-5.1" {
t.Fatalf("normalizeCodexModel(...) = %q, want %q", withoutDefault, "gpt-5.1")
if withoutDefault != "gpt-5.4" {
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

该用例现在断言默认回退为 gpt-5.4,但测试函数名仍是 ...FallingBackToGpt51,容易误导后续维护/排查。建议同步重命名测试函数(以及必要时更新描述字符串),与新的回退目标一致。

Copilot uses AI. Check for mistakes.
@specialpointcentral specialpointcentral force-pushed the fix/issue-1758-codex-models branch from 1ec106a to 31c102a Compare April 20, 2026 06:55
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.

Codex 部分模型已不可用,应移除内置重定向

2 participants