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:codeGitHub 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:codeproxy_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
- Run
Assistant
Let me start by understanding the issue and the repository structure. The issue is about a stale
client_versionfallback when the GitHub releases API is rate-limited, causing 503 errors for newer models likegpt-5.5.Let me first explore the repository structure to understand how the code is organized.
Assistant
Let me look at the key files mentioned in the issue:
app/core/clients/codex_version.py- the version fetching logicapp/core/openai/model_refresh_scheduler.py- the model refresh schedulermodules/proxy/load_balancer.py- where the 503 is returned
Assistant
Let me explore the key files mentioned in the issue.
Assistant
OK, so I can see the issue. The
CodexVersionCacheclass has:- A TTL-based cache
- A fallback to GitHub releases API
- A fallback to a stale cached value if available
- A final fallback to
Settings.model_registry_client_version(the settings default, which is0.101.0)
The problem is that when GitHub API is rate-limited (HTTP 403), it falls back to the settings default
0.101.0, which is too old to support newer models likegpt-5.5.Let me also check the settings file to see the default value:
Assistant
Let me look at the settings file to find the default value for
model_registry_client_version.Assistant
Good, I found it. The default is
0.101.0on line 206. The issue suggests adding a secondary version source (npm registry) which is not rate-limited the same way as GitHub's API. Let me look at the complete settings.py file and the model_refresh_scheduler.py to understand the full picture.Assistant
Now let me also look at the model_refresh_scheduler.py to understand how the version is used:
Assistant
Now let me look at the model_fetcher to see how client_version is used:
Assistant
Now I understand the full picture. The issue is in
codex_version.pywhere when GitHub API returns 403 (rate-limited), it falls back to the stale cache or settings default (0.101.0). The suggested fix in the issue is option 2: Add a secondary version source using npm registry which is not rate-limited.Let me also check the load_balancer.py to understand the 503 error:
Assistant
Let me find the correct location of load_balancer.py
Assistant
Now let me look at the test files to understand the testing patterns and the existing tests for codex_version.py:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "no_plan_support_for_model" /codex-lb/app/modules/proxy/load_balancer.py | head -20 </tool_call>
Assistant
Let me search for the no_plan_support_for_model error in load_balancer.py.
Assistant
Let me also check if there are any existing tests for the codex_version.py module.
Assistant
Let me look at the existing tests for codex_version.py:
Assistant
Now I have a clear understanding of the issue. The problem is in
codex_version.py: when the GitHub API returns 403 (rate-limited) and there's no cache, it falls back to the stale default version0.101.0, which is too old to support newer models likegpt-5.5.The suggested fix (option 2) is to add a secondary version source using the npm registry, which is not rate-limited the same way as GitHub's anonymous API.
Let me first run the existing tests to establish a baseline:
Assistant
Let me install the dependencies first:
Assistant
Let me try a different version of pytest-asyncio that's more compatible with the project.
Assistant
Let me check what the project uses for dependencies.
Assistant
Let me check the project's dependency system and use it properly:
Assistant
It seems like the package uses uv for dependency management. Let me try to install the dependencies properly.
Assistant
Now let me run the tests:
Assistant
All 11 tests pass. Now let me implement the fix. The issue suggests adding a secondary version source (npm registry) when GitHub API fails. Let me implement this:
Assistant
Now I'll implement the fix. The approach is to add a secondary version source (npm registry) when the GitHub API fails. Let me modify
codex_version.py:Assistant
The edit command format seems different. Let me look at the format again and use the proper syntax.
Assistant
Let me verify the file was updated correctly:
Assistant
The file is updated. Now let me run the existing tests to make sure they still pass:
Assistant
All 11 existing tests pass. Now I need to add tests for the new npm registry fallback functionality. Let me create a test script to verify the new behavior works:
Assistant
All 4 new tests pass. Let me also run all the related tests to ensure nothing is broken:
Assistant
All 17 tests pass. Let me also run the integration tests related to models to make sure nothing is broken:
Assistant
All tests pass. Let me also run a broader set of tests to make sure nothing is broken:
Assistant
All 1889 unit tests passed. Let me now verify the fix by checking the key flow:
- GitHub API succeeds → returns version, caches it
- GitHub API fails (403 rate-limited) + stale cache exists → returns stale cached version (same as before)
- GitHub API fails + no cache → tries npm registry (NEW), if npm succeeds returns npm version, otherwise falls back to settings default (same as before)
Let me verify the logic in the code once more:
Assistant
Let me also verify the npm registry URL actually returns the expected JSON structure:
Assistant
The npm registry returns a valid version (
0.145.0), which is more recent than the settings default (0.101.0). This confirms the fix will work correctly.Let me clean up and do a final verification:
Assistant
Let me do a final check of the changes:
Assistant
My fix is complete. Let me summarize what was done:
Summary of Changes
File modified:
app/core/clients/codex_version.pyProblem
When the GitHub releases API (
api.github.com/repos/openai/codex/releases/latest) returns HTTP 403 (anonymous rate limit), and there's no cached version, the system fell back toSettings.model_registry_client_version(default0.101.0). This old client version doesn't include newer models likegpt-5.5, causing 503no_plan_support_for_modelerrors.Solution (Option 2 from suggested fixes)
Added the npm registry (
https://registry.npmjs.org/@openai/codex/latest) as a secondary version source. The npm registry is not rate-limited the same way as GitHub's anonymous API.Fallback chain (new order):
- Cached version (if within TTL)
- GitHub releases API (primary source)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.