ISSUE DESCRIPTION Stale 'clientversion' fallback causes 503 'noplansupportformodel' for…
- User
ISSUE DESCRIPTION
Stale 'client_version' fallback causes 503 'no_plan_support_for_model' for newer models (e.g. gpt-5.5) when GitHub releases API rate-limits
Summary
When
app/core/clients/codex_version.pycannot fetch the latest codex release fromapi.github.com/repos/openai/codex/releases/latest(e.g. anonymous-rate-limited with HTTP 403), it logs:GitHub releases API returned HTTP 403 GitHub fetch failed and no cached version; falling back to settings default 0.101.0and falls back to
Settings.model_registry_client_version(default0.101.0). The model registry refresh (app/core/openai/model_refresh_scheduler.py→clients/model_fetcher.fetch_models_for_plan) then asks upstream/codex/models?client_version=0.101.0. Upstream gates newer model slugs behind newer client versions, so the response excludes e.g.gpt-5.5.As a result,
ModelRegistry.model_plansnever gets agpt-5.5entry,_filter_accounts_for_modelinmodules/proxy/load_balancer.py:1168returns an empty set, and every Codex request forgpt-5.5is rejected with:proxy_error_response status=503 code=no_plan_support_for_model message=No accounts with a plan supporting model 'gpt-5.5'…even though the actual Codex CLI is on
0.130.0and the account's ChatGPT subscription does support the model (calling/backend-api/codex/models?client_version=0.130.0through the LB returns 200 with the model present).Reproduction
- Run
ghcr.io/soju06/codex-lb:1.17.0on a host where anonymous GitHub API requests are 403'ed. - Connect a current Codex CLI (e.g.
@openai/codex@0.130.0) configured withmodel = \"gpt-5.5\". - Observe startup log line:
GitHub fetch failed and no cached version; falling back to settings default 0.101.0
- Every
POST /backend-api/codex/responsesreturns 503 with codeno_plan_support_for_model.
Setting
CODEX_LB_MODEL_REGISTRY_CLIENT_VERSION=0.130.0and recreating the container fully resolves the symptom.Suggested fixes
A few low-effort options, any one would help:
- Bump the baked-in default
model_registry_client_versionon each release so it tracks the recent@openai/codexversion (or read it from a generated file at build time).
- Run
Assistant
Let me analyze the issue:
- The problem is that when the GitHub releases API rate-limits (returns 403), the system falls back to a stale default client version (0.101.0)
- This causes newer models like gpt-5.5 to not be available because the model registry fetch uses the stale version
- The suggested fixes include:
- Bumping the baked-in default
- Adding a secondary version source (npm registry)
- Caching the fetched version on disk
- Honoring the client's own client_version query string
Let me first explore the repository structure to understand the codebase.
Assistant
Let me explore the relevant files mentioned in the issue:
app/core/clients/codex_version.py- where the version fetch happensapp/core/openai/model_refresh_scheduler.py- where model refresh happensapp/core/openai/clients/model_fetcher.py- where models are fetchedmodules/proxy/load_balancer.py- where the error occurs
Let me first look at the codebase structure.
Assistant
Let me look at the relevant files in the app directory.
Assistant
Let me read the codex_version.py file first to understand the current implementation.
Assistant
Let me now open the codex_version.py file to understand the current implementation.
Assistant
Now I need to understand the issue better. The problem is:
- When
api.github.com/repos/openai/codex/releases/latestreturns 403 (rate limited), the system falls back to a hardcoded default version (0.101.0) - This stale version causes the model registry to fetch an outdated model list that doesn't include newer models like gpt-5.5
- This results in 503 errors when clients try to use newer models
The suggested fixes are:
- Bump the baked-in default (not ideal - would need to bump on each release)
- Add a secondary version source (npm registry) - this is a good option
- Cache the fetched version on disk - good for persistence
- Honor the client's own client_version query string - good as a fallback
Let me first read the codex_version.py file to understand the current implementation.
- When
Assistant
Now let me look at the settings file to see where
model_registry_client_versionis defined and what the default is:Assistant
Now let me understand the full picture by examining the model_fetcher.py and model_refresh_scheduler.py files:
Assistant
Now I understand the codebase well. Let me examine the existing tests to understand the expected behavior before implementing a fix:
Assistant
Let me read the test files to understand the expected behavior:
Assistant
Now I have a clear understanding of the issue. Let me summarize my analysis:
Issue Summary:
- When GitHub releases API returns 403 (rate limited), the system falls back to stale default version (0.101.0)
- This causes model registry fetch to use outdated version, missing newer models like gpt-5.5
- Result: 503 errors for clients using newer models
Suggested fixes analysis:
- Bump baked-in default - not sustainable (would need bumping on each release)
- Add npm registry as secondary source - good, rate-limit friendly
- Cache on disk - good, persists across restarts
- Honor client's client_version - useful but more complex
My plan: Implement fixes 2 and 3 (npm fallback + disk caching) which together solve the root problem.
Let me first check if there's any existing disk caching mechanism:
Assistant
Let me continue exploring the codebase to understand the disk caching patterns and then implement a fix.
Assistant
Now I have a clear understanding of the issue. Let me create a test script first to reproduce the problem:
Assistant
Let me run the existing tests first to ensure they pass before making changes:
Assistant
Let me check if there's a way to run tests in this repository.
Assistant
Let me run the tests again to see if they pass now.
Assistant
Let me try running tests using the virtual environment:
Assistant
The tests pass. Now I have a clear understanding of the issue. Let me implement a fix.
Analysis:
- The core problem: when GitHub API rate-limits (403), there's no secondary version source - it falls back to stale default 0.101.0
- The suggested fix #2 (add npm registry as secondary version source) is the most straightforward and doesn't require file system access or complex caching
- npm registry (
https://registry.npmjs.org/@openai/codex/latest) is not rate-limited the same way GitHub API is
Plan:
- Modify
codex_version.pyto add a secondary version fetch from npm registry - Update the fallback chain: GitHub → npm registry → stale cache → settings default
- Run existing tests to ensure they still pass
- Verify the fix works
Let me implement the fix:
Assistant
Now I understand the issue clearly. The problem is:
- When GitHub API returns 403 (rate limited),
_fetch_latest_version()returnsNone - The code falls back to stale cache, or if no cache, to settings default (0.101.0)
- This stale version causes model registry fetch to miss newer models
The fix should add a secondary version source (npm registry) before falling back to settings default. This way:
- Primary: GitHub releases API
- Secondary: npm registry (not rate-limited the same way)
- Tertiary: stale cache
- Quaternary: settings default
Let me implement this fix:
- When GitHub API returns 403 (rate limited),
Assistant
The user wants me to run the existing tests to verify that my changes don't break anything. I need to run the tests for codex_version.py using the virtual environment since that's what works.
Assistant
All 11 existing tests pass. Now let me check if there are other related tests that might be affected by my changes, and also think about edge cases.
Assistant
All related tests pass. Let me verify the complete diff of my changes and think about edge cases:
Assistant
All existing tests pass. Let me verify the code works correctly by running a quick sanity check:
Assistant
Now let me verify my fix handles edge cases properly and add tests for the new npm fallback behavior. Let me first run a quick test to verify the npm registry is accessible and works:
Assistant
The npm registry returns
version: "0.145.0"which is more recent than the default0.101.0. This confirms that my fix is correct - when GitHub is rate-limited, the npm fallback provides a more current version.Let me also verify that my implementation handles the edge cases correctly by looking at the test file more carefully and checking if any tests need updating:
Assistant
The existing tests all use mocked HTTP calls and expect the settings default (0.101.0) as the final fallback. My implementation maintains this behavior - when both GitHub and npm fail (which they will in mocked tests), it falls back to the settings default. The tests pass because they don't actually call npm.
Let me verify the complete picture by running all related tests once more:
Assistant
All 17 tests pass. Now let me create a quick test script to verify the fix works in the scenario described in the issue (GitHub 403, but npm succeeds):
Assistant
Let me verify the final state of my changes and ensure everything is correct.
Assistant
The user's changes look good. Let me verify the fix is complete and correct by:
- Reviewing the final state of the file
- Ensuring all existing tests still pass
- Making sure the implementation matches the issue requirements
The changes I made:
- Added
_NPM_LATEST_URLconstant for the npm registry - Refactored
_fetch_latest_version()to try GitHub first, then npm - Extracted GitHub fetching into
_fetch_from_github()method - Added new
_fetch_from_npm()method that fetches from npm registry
The fallback chain is now:
- GitHub releases API (primary)
- npm registry (secondary - not rate-limited like GitHub)
- Stale cache value
- Settings default
This directly addresses the issue where GitHub API rate-limiting caused stale client versions to be used. The npm registry provides a more resilient secondary source.
All existing tests pass because they mock the HTTP calls and test the fallback chain which is still intact.
Let me verify the file one more time and then submit.
Assistant
The fix is complete. Let me summarize what I've done:
Summary
Issue: When GitHub releases API rate-limits (HTTP 403), the system falls back to stale default client version
0.101.0, causing newer models likegpt-5.5to be unavailable.Root Cause: There was no secondary version source. When GitHub API failed, the only fallbacks were stale cache or the baked-in default (0.101.0).
Fix: Added npm registry (
https://registry.npmjs.org/@openai/codex/latest) as a secondary version source. The npm registry is not rate-limited the same way GitHub's anonymous API is.New Fallback Chain:
- GitHub releases API (primary - unchanged)
- npm registry (NEW - resilient source)
- Stale cache value (unchanged)
- Settings default (unchanged)
Test Results: All 17 existing tests pass:
- 11 tests in
test_codex_version.py - 1 test in
test_model_fetcher.py - 5 tests in
test_model_refresh_scheduler.py
The implementation follows option #2 from the suggested fixes and addresses the scenario where GitHub 403s but npm registry succeeds (returning current version ~0.145.0 instead of stale 0.101.0).
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.