Skip to content

feat: codex无重启,无另外调整,纯模型栏切换官模与第三方api#1641

Open
121103qwq wants to merge 2 commits into
BigPizzaV3:mainfrom
121103qwq:codex/model-provider-routing
Open

feat: codex无重启,无另外调整,纯模型栏切换官模与第三方api#1641
121103qwq wants to merge 2 commits into
BigPizzaV3:mainfrom
121103qwq:codex/model-provider-routing

Conversation

@121103qwq

Copy link
Copy Markdown

新增“按模型自动路由供应商”功能,使 ChatGPT 官方模型与第三方 API 模型可以同时出现在 Codex 模型栏中,并仅通过切换模型自动选择对应供应商。
模型存在于某个第三方供应商的 modelList:走该供应商

  • 模型未匹配任何第三方供应商:走 ChatGPT 官方登录
  • 模型同时存在于多个供应商:返回明确的重复绑定错误
  • 第三方请求使用对应供应商的 API Key
  • 官方请求保留 Codex 提供的官方认证
  • 无需 CC Switch,也无需手动切换当前供应商
    新增“按模型自动路由供应商”独立开关,默认关闭
  • Codex 固定连接本地 127.0.0.1:57321/v1
  • 合并官方模型与第三方模型目录
  • 保留各模型单独配置的上下文窗口,例如 mimo-v2.5-pro[1M]
  • 复用现有 Responses / Chat Completions 协议转换

@BigPizzaV3

Copy link
Copy Markdown
Owner

审查结论:当前不建议合并,主要有以下问题需要先确认:

  1. 官方模型可能不会出现在模型列表中
    model_catalog.rsmodel_routing_catalog_value() 只收集第三方 profile 的 model_list,普通官方 profile 会被排除。但 read_codex_model_catalog() 在开启 model routing 后会直接使用这个结果,而 launcher 的模型目录接口也调用了它。这样可能出现实际 router catalog 尝试合并官方模型,但 /models 返回的模型列表只包含第三方模型,和 PR 描述的“官方模型与第三方模型同时显示”不一致。

建议让 routing catalog 同步合并 models_cache.json 或生成的 router catalog 中的官方模型,并补一个接口级测试,确认 /models 同时返回官方和第三方模型。

  1. 缺少核心路由的端到端测试
    目前测试覆盖了 profile 匹配、router 配置生成和 catalog 写入,但没有验证:
  • 匹配第三方模型时使用正确的 API Key;
  • 未匹配模型时正确转发官方 Authorization;
  • /responses/responses/compact 官方路径;
  • 重复模型的错误响应;
  • 实际 /models 返回的完整模型集合。
  1. CI 状态
    当前 PR 没有 GitHub CI,状态为 UNSTABLE。建议补齐 Windows、macOS x64、macOS arm64 构建检查。

我本地验证了 relay_config 100 个测试、launcher 71 个测试、protocol_proxy 46 个测试、TypeScript 检查和 release build,基础构建均通过;但上述路由行为仍缺少真实覆盖。

@BigPizzaV3

Copy link
Copy Markdown
Owner

Codex++ maintainer review note

这个方向有价值,但当前 PR 改动覆盖模型目录、relay config、protocol proxy、settings 和前端开关,而且没有 CI/check 结果;暂时不建议直接合并。

请补充以下内容后再复审:

  1. 针对官方模型、单一第三方模型、多个供应商重复模型名的端到端/集成测试;
  2. 明确该功能开启/关闭时不会破坏现有 per-profile provider 行为;
  3. 说明与现有 CC Switch / provider sync / model_catalog_json 逻辑的边界;
  4. 触发一轮 PR build artifacts 或贴出本地验证命令与结果。

The feature is useful, but it touches model catalog, relay config, protocol proxy, settings, and UI without CI results. Please add coverage and clarify compatibility boundaries before merge.

Addresses the review on BigPizzaV3#1641.

- model_catalog: the routing catalog only listed third-party models, so
  /models hid the official ones even though Codex's generated
  model_catalog_json had both. Merge the official slugs back in from
  model-catalogs/codex-plus-router.json (falling back to
  models_cache.json before the first launch writes it) and expose them as
  their own source entry.
- relay_switch: switching or editing a provider while routing is on wrote
  that profile over the router provider, and backfilled the router's live
  config.toml onto the profile it replaced. Apply the router profile
  instead and skip the backfill.
- protocol_proxy: make the official base URL overridable via
  CODEX_PLUS_OFFICIAL_BASE_URL and expose the settings+headers entry point
  so the routing decision can be driven end to end from tests.

New coverage: tests/model_routing.rs drives /v1/responses against
loopback upstreams for matched third-party models (correct API key),
suffixed model ids, unmatched models (official Authorization forwarded,
x-api-key withheld), /responses and /responses/compact, duplicate model
bindings, missing/placeholder ChatGPT login, and routing turned off.
tests/model_catalog.rs asserts the /models payload with routing on and
off; tests/relay_switch.rs asserts the switch flow in both states.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

2 participants