Skip to content

fix(codex): refresh discovery client version automatically - #15663

Merged
diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.52from
zitus91:fix/automatic-model-discovery
Oct 7, 2026
Merged

diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.52from
zitus91:fix/automatic-model-discovery

Conversation

@zitus91

@zitus91 zitus91 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Codex's model manifest gates newer models on the client version. OmniRoute uses a pinned discovery identity, so refreshing a connection can keep returning an obsolete catalog even after new models are available.

Refresh the stable @openai/codex version from the official npm registry before authenticated model discovery. Discovery URL and identity headers use the same validated version, and synchronous inference consumers reuse the cache. Explicit operator and caller identity overrides retain their precedence.

The lookup is cached for six hours, coalesces concurrent requests, and retains the last-known-good version or existing pin when metadata is unavailable. Failed refreshes are throttled for five minutes. No CLI package is installed and inference adds no network lookup.

Related Issues

⚠️ base-red inherited: #15306

Validation

  • Change type: provider
  • Focused tests and category gates from the Contribution Golden Path
  • npm run lint
  • npm run typecheck:core
  • npm run check:provider-consistency
  • npm run check:provider-assets
  • Reconciled with the active release/v3.8.52 base (112313aa); focused checks rerun afterward
  • Production-code changes include automated regression tests

Focused command (37 passing):

node --import tsx/esm --import ./tests/_setup/isolateDataDir.ts --test --test-force-exit \
  tests/unit/codex-client-version-refresh.test.ts \
  tests/unit/provider-models-route-codex.test.ts \
  tests/unit/codex-client-headers.test.ts \
  tests/unit/claude-codex-identity-version-sync.test.ts \
  tests/unit/claude-oauth-models-discovery.test.ts

Independent review also passed 58 refresh/discovery/header tests. Security checks passed the refresh, outbound timeout and DNS suites (22 tests). Real read-only Codex discovery selected registry version 0.160.1 and returned gpt-6.1-sol, gpt-6-astra, gpt-6-sol, and gpt-6-luna; application imports were isolated with a temporary DATA_DIR for the final run.

provider-translate-path-golden.test.ts passes 2/3 assertions on this macOS host. Its sole mismatch is six unchanged GitHub/GHE user-agent fields: the committed snapshot expects linux, while the runtime emits darwin. No Codex golden fields differ. The unrelated snapshot was not regenerated. Full suites, coverage and production build are deferred to CI as required by the golden path.

Tests Added Or Updated

  • tests/unit/codex-client-version-refresh.test.ts (9 tests, demonstrated failing before implementation)

Coverage Notes

The new tests cover successful metadata refresh, synchronized URL/headers, explicit overrides, cache expiry, single-flight, offline fallback/retry, malformed metadata and downgrade rejection, remote-only model IDs, missing credentials, body size limits and stalled-body cancellation. Existing discovery, identity and Claude tests cover adjacent behavior.

Reviewer Notes

The metadata request uses a fixed public HTTPS endpoint, DNS pinning, no redirects or account credentials, a 5-second deadline including body consumption, and a 64 KiB response cap. Package identity and bounded stable semver are validated with the existing Zod dependency.

Auto-Sync remains opt-in. Claude live discovery is already implemented in this release base and is unchanged. No static catalog, dependency, schema, or UI changes are included.

@zitus91
zitus91 requested a review from diegosouzapw as a code owner October 6, 2026 14:48
@TheViniAlmeida

Copy link
Copy Markdown
Contributor

Additional controlled reproduction supporting this change: keeping the same account and Responses request payload, changing only the advertised Codex client version produced:

Client version Discovery Inference
0.156.1 9 models; gpt-6.1-sol absent HTTP 400
0.159.1 10 models; gpt-6.1-sol present HTTP 200, completed

The rejection with 0.156.1 was: The 'gpt-6.1-sol' model is not supported when using Codex with a ChatGPT account.

The live manifest reports minimal_client_version: 0.153.0, so that field alone does not explain the difference. 0.159.1 is a confirmed working identity in this comparison, not a universal minimum.

This supports keeping discovery and inference on the same refreshed client identity, while preserving explicit overrides. Related catalog/model work: #15166.

overbit added a commit to overbit/OmniRoute that referenced this pull request Oct 7, 2026
Backport the reproduced discovery fix from upstream cheaper-inference#15663.

Refresh the stable @openai/codex version from the official npm registry through
the same guarded fetch path used for model discovery, then build the authenticated
catalog URL and identity headers from that validated value. Synchronous inference
consumers reuse the cache, while explicit operator overrides keep precedence.

Retain the offline 0.159.2 pin and add focused refresh, cache, failure and
remote-only discovery regression coverage.
…8.52

Keep the release Codex client pin. Discovery may cache a newer registry
version, and a lower version cannot replace that pin.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@diegosouzapw
diegosouzapw merged commit c6a2431 into cheaper-inference:release/v3.8.52 Oct 7, 2026
3 checks passed
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.

3 participants