fix: codex model discovery sends prime-agent version as client_version - #731
fix: codex model discovery sends prime-agent version as client_version#731ayushnangia wants to merge 1 commit into
Conversation
fixes PrimeIntellect-ai#702 openAICodexModelsUrl passed prime-agent's own package VERSION as the client_version query parameter. The ChatGPT backend gates the Codex model catalog by Codex CLI version, so 0.x reads as an ancient client and returns an empty catalog. The empty set filters every openai-codex model out of discovery and subagent spawns, producing a misleading 'unavailable, unauthenticated, or expired' error with fresh auth. Pin a verified Codex CLI version (0.146.1, confirmed by the reporter to restore the full catalog with the same bearer token) instead of our own version.
|
Thank you for the report and proposed work. This root cause is now covered by maintainer-owned stacked PR #1164, authored independently from We did not inspect or reuse this PR's diff, branch, commits, implementation code, or tests; its public description/comments were used only as a bug report. To keep one review surface, this PR is superseded by #1164 and is being closed. The complete review stack is #1158–#1165. It is being left unmerged for human review after CI and review-bot findings are cleared. |
|
Thanks for the clear provenance note — understood on report-only usage, and consolidating into the maintainer-owned #1158–#1165 stack makes sense as one review surface. The pinned |
Fixes #702.
Problem
openAICodexModelsUrl()(packages/coding-agent/src/core/model-registry.ts:386) passed prime-agent's own packageVERSIONas theclient_versionquery parameter. The ChatGPT backend gates the Codex model catalog by Codex CLI version, so0.7.0reads as an ancient client and returns{"models": []}. The empty catalog filters everyopenai-codexmodel out ofgetAvailable(),findRlmModels, and subagent spawns, producing the misleading "unavailable, unauthenticated, or expired" error with fresh auth — exactly as diagnosed in the report.Change
Pin a verified Codex CLI version (
OPENAI_CODEX_CLIENT_VERSION = "0.146.1", confirmed by the reporter to restore the full 9-model catalog with the same bearer token) instead of our own version, with a comment explaining why the package version must not be used.VERSIONimport dropped from model-registry (now unused there).Complementary to #717, which fail-opens when discovery legitimately returns empty; this PR makes discovery return the real catalog in the first place. The report's optional suggestion (distinct error for discovery-empty vs auth failure) is left out to keep the change minimal.
Tests
test/suite/regressions/702-codex-client-version.test.ts: stubs fetch, drivesfindRlmModelsthrough the harness, and asserts the/codex/modelsrequest'sclient_versionis not the packageVERSIONand matches a Codex CLI version shape. Fails on main (expected '0.7.0' not to be '0.7.0').Neighbor suites (
4649-subagent-model-selection,model-registry,696-empty-codex-catalog): 85/85. Note: two 4649 tests fail on unmodified main whenDEEPSEEK_API_KEY/OPENROUTER_API_KEY/HF_TOKENare set in the environment (provider availability leaks into discovery); all green with those unset, before and after this change.npm run checkclean.Note
Low Risk
Narrow change to Codex catalog discovery query params plus a regression test; no auth or data-path changes.
Overview
Fixes #702 by stopping
openAICodexModelsUrlfrom sending prime-agent’s packageVERSIONas theclient_versionquery param on/codex/modelsrequests. The ChatGPT backend treats that as an outdated Codex CLI client and returns an empty catalog, which made everyopenai-codexmodel disappear from discovery,getAvailable(), and subagent flows despite valid auth.The URL builder now uses a pinned
OPENAI_CODEX_CLIENT_VERSION(0.146.1) with an inline comment explaining why the app version must not be used; the unusedVERSIONimport is removed frommodel-registry.ts.Adds regression test
702-codex-client-version.test.ts, which stubsfetch, runsfindRlmModels, and assertsclient_versionis not the package version and matches a Codex CLI-style semver.Reviewed by Cursor Bugbot for commit 5392c28. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix Codex model discovery to send a pinned Codex CLI version as
client_versionThe Codex model discovery URL was sending the package
VERSIONasclient_version, but the OpenAI Codex endpoint gates on a specific Codex CLI version. model-registry.ts now uses a hardcoded constantOPENAI_CODEX_CLIENT_VERSION(0.146.1) instead. A regression test verifies the pinned version is sent and differs from the packageVERSION.Macroscope summarized 5392c28.