Skip to content

fix(providers): support Codex model discovery protocol - #2001

Open
indexGin wants to merge 3 commits into
TencentCloud:developfrom
indexGin:fix/codex-model-discovery
Open

indexGin wants to merge 3 commits into
TencentCloud:developfrom
indexGin:fix/codex-model-discovery

Conversation

@indexGin

@indexGin indexGin commented Oct 13, 2026 •

Copy link
Copy Markdown

Summary

Fixes #1992.

Codex model discovery uses a different contract from OpenAI's /models: it requires client_version and returns models[].slug with display_name. The shared fetcher currently omits the query parameter and only accepts data[].id, so fetching the Codex model list fails.

  • Reuse CODEX_ATTRIBUTION_VERSION, including its existing environment override, for the Codex query parameter.
  • Normalize Codex slugs and display names into Octop's existing model records, preserving sorting, deduplication, and empty lists.
  • Recognize the built-in Codex provider or the matching endpoint host/path; retain the ordinary OpenAI request and response contract.
  • Report malformed Codex model lists in English and Chinese, including non-empty lists without any valid slug.

Target branch

  • Base is develop (feature / fix — default)
  • Base is main (release/* or hotfix/* only)

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactor / chore
  • Release / hotfix

Test plan

  • make all passes locally
  • Added/updated tests

The new tests use a real loopback HTTP server serving JSON fixtures, with the production HTTP client unchanged. They check the query parameter, authorization/account headers, normalization, deduplication, sorting, empty/malformed lists, localized errors, and ordinary OpenAI behavior. The initial nine regression cases produced five failures against the unmodified code; the targeted suite now passes all 105 tests, including 17 new cases. Running the request regression again with OCTOP_CODEX_ATTRIBUTION_VERSION=2026.10.13-test also passes, checking the existing configuration override.

After merging develop at 99e479a6, make all passed on Windows / Python 3.12: 4,618 passed, 211 skipped (10 existing-suite warnings). GNU Make used SHELL=bash and PYTEST_JOBS=2. The first full run had one existing subprocess test exceed its 20-second timeout; its isolated recheck and the full rerun passed without changing the test or timeout. No authenticated live Codex request was performed.

The normal pre-commit gate passed, including 340 testmon-selected tests (using pytest's two-worker option) and dashboard npm run build (tsc -b and Vite/PWA build). No checks were bypassed.

Checklist

  • Updated CHANGELOG.md (if user-facing)
  • README / docs updated (if needed): no API or configuration changes require a documentation update.

Prepared with AI assistance.

Review follow-up: two non-empty invalid response fixtures, checked in both languages, reproduced four failures before the fix and now return the existing localized error. The valid empty-list and mixed-validity cases remain covered.

Copilot AI balanced review requested due to automatic review settings October 13, 2026 14:58

Copilot AI 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.

🟡 Changes recommended

非空但没有有效 slug 的 Codex 响应仍会被错误地报告为成功。

1 open finding
What changed in this PR

该 PR 修复 Codex 模型发现协议兼容问题。

Changes:

  • 携带 client_version 并识别 Codex 端点。
  • 解析、去重并排序 Codex 模型数据。
  • 新增本地化错误信息和协议回归测试。
File Description
src/​octop/​infra/​agents/​providers/​probe.py 实现 Codex 请求与响应适配
tests/​unit/​test_codex_fetch_models_http.py 覆盖 Codex 和 OpenAI 协议
src/​octop/​i18n/​en.json 添加英文错误信息
src/​octop/​i18n/​zh.json 添加中文错误信息
CHANGELOG.md 记录用户可见修复

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/octop/infra/agents/providers/probe.py

This branch has not been deployed

No deployments
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