Repository navigation
feat(codex): give Codex a model catalog for gateways it does not know - #1222
Open
justinware24 wants to merge 1 commit into
Open
justinware24 wants to merge 1 commit into
justinware24 wants to merge 1 commit into
Conversation
Codex falls back to its built-in metadata for a model it has never heard of. That metadata understates the context window of a model served by another gateway and makes the CLI warn on every turn, so a run against such a gateway truncates turns early and complains about a model the user deliberately configured. The platform now writes a model catalog next to the CLI's own configuration and passes it as model_catalog_json. The catalog describes the models of the user's personal catalog and of the gateway it points at, plus the model of the current turn. A model the gateway does not publish a window for gets a conservative one, because Codex's fallback is smaller still. A turn without a personal catalog and without a custom Base URL keeps the CLI's own catalog, which is right for OpenAI's own endpoint. A catalog that cannot be written does not fail the turn: the CLI still runs and only loses the real window.
justinware24
force-pushed
the
feat/codex-model-catalog
branch
from
November 23, 2026 09:51
8d61e8c to
0de35a9
Compare
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.
问题
Codex 会回退到其内置的元数据来处理它从未见过的模型。该元数据低估了由另一个网关提供服务的模型的上下文窗口,因此命令行界面会提前截断对话轮次,并在每一轮都发出警告:
Warning: model
xxxis not in the Codex model catalog; using the default context window这会影响所有将 Codex 指向 OpenAI Responses 兼容网关的部署——包括自托管网关、区域计划端点或任何转售 OpenAI 模型的供应商。用户在个人配置中配置模型,平台已通过 model_providers.agentflow_user 将基础 URL 传递给 CLI,且模型仍会在错误的窗口中运行。
建议行为
该平台会在命令行界面自身的配置旁边生成一个模型目录,并将其作为 model_catalog_json 传递,因此 Codex 能够知晓运行过程中可能使用的每个模型的实际窗口。
该目录包含以下内容:
the models of the user’s personal catalog (个人配置 → 模型与执行),
网关发布的模型,以及
当前轮次的模型,即使网关未发布该模型。
网关未发布其窗口的模型会得到一个保守的窗口,因为 Codex 自身的后备窗口还要更小。
范围
平台——Codex 提供方、引擎凭证组装以及 AI 对话轮次。
目录存储在回合的私有主目录中,位于 CODEX_HOME 旁边,因此它会随回合的创建而存在、随回合的销毁而消失。
两种行为保持不变:
使用官方端点且没有个人目录和自定义基础 URL 的用户,保留 CLI 自带的目录;
一个无法写入的目录不会导致测试失败。命令行界面(CLI)仍会运行,只是会失去真实的窗口。
检查项
go build ./...
go vet ./internal/runtime/ ./internal/engine/ ./internal/httpapi/
go test ./internal/runtime/ ./internal/httpapi/ -count=1 — 测试通过
go test ./internal/engine/ -count=1 — 此签出中的网关和节点循环用例失败,因为它没有运行节点的执行机器。相同的用例在未修改的 main 分支上也会失败,因此它们并非由本次修改导致。
bash scripts/build-chatbot.sh — 聊天机器人前端构建完成,且其自身测试全部通过
浏览器兼容性测试套件——无需运行:此修改不涉及身份验证、首选项或执行相关内容
python3 scripts/check-public.py、bash scripts/scan-secrets.sh — 拉取请求合并前运行