Skip to content

fix: codex model discovery sends prime-agent version as client_version - #731

Closed
ayushnangia wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
ayushnangia:fix/702-codex-client-version
Closed

fix: codex model discovery sends prime-agent version as client_version#731
ayushnangia wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
ayushnangia:fix/702-codex-client-version

Conversation

@ayushnangia

@ayushnangia ayushnangia commented Aug 6, 2026

Copy link
Copy Markdown

Fixes #702.

Problem

openAICodexModelsUrl() (packages/coding-agent/src/core/model-registry.ts:386) 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.7.0 reads as an ancient client and returns {"models": []}. The empty catalog filters every openai-codex model out of getAvailable(), 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. VERSION import 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, drives findRlmModels through the harness, and asserts the /codex/models request's client_version is not the package VERSION and 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 when DEEPSEEK_API_KEY/OPENROUTER_API_KEY/HF_TOKEN are set in the environment (provider availability leaks into discovery); all green with those unset, before and after this change. npm run check clean.


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 openAICodexModelsUrl from sending prime-agent’s package VERSION as the client_version query param on /codex/models requests. The ChatGPT backend treats that as an outdated Codex CLI client and returns an empty catalog, which made every openai-codex model 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 unused VERSION import is removed from model-registry.ts.

Adds regression test 702-codex-client-version.test.ts, which stubs fetch, runs findRlmModels, and asserts client_version is 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_version

The Codex model discovery URL was sending the package VERSION as client_version, but the OpenAI Codex endpoint gates on a specific Codex CLI version. model-registry.ts now uses a hardcoded constant OPENAI_CODEX_CLIENT_VERSION (0.146.1) instead. A regression test verifies the pinned version is sent and differs from the package VERSION.

Macroscope summarized 5392c28.

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.
@sethkarten

Copy link
Copy Markdown
Contributor

Thank you for the report and proposed work. This root cause is now covered by maintainer-owned stacked PR #1164, authored independently from upstream/main.

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.

@sethkarten sethkarten closed this Aug 10, 2026
@ayushnangia

Copy link
Copy Markdown
Author

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 OPENAI_CODEX_CLIENT_VERSION root cause is exactly the kind of thing I'd want a stack like that to absorb; happy to verify #1164 against my original repro ("expected '0.7.0' not to be '0.7.0'") once it clears CI, if useful.

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.

openai-codex models invisible to rlm subagents: model discovery sends prime-agent VERSION as codex client_version, backend returns empty catalog

2 participants