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 analyze the issue:
- The problem is that when GitHub releases API rate-limits (returns 403), the code falls back to a default
client_versionof0.101.0 - This old version doesn't include newer models like
gpt-5.5 - The fix should add a secondary version source (npm registry) in addition to the GitHub releases API
Let me first explore the repository structure to understand the codebase.
- The problem is that when GitHub releases API rate-limits (returns 403), the code falls back to a default
Assistant
The first file mentioned in the issue is
app/core/clients/codex_version.py. Let me explore the relevant files.Assistant
Let me start by reading the key file mentioned in the issue:
app/core/clients/codex_version.py.Assistant
Now let me look at the settings to understand the default value for
model_registry_client_version.Assistant
Now let me look at the model_fetcher.py to understand how client_version is used:
Assistant
Now let me check for existing tests related to codex_version:
Assistant
Let me read the test file for codex_version to understand the current testing and behavior.
Assistant
Let me also check the model_refresh_scheduler.py to understand the full flow:
Assistant
Now I have a good understanding of the issue. Let me:
- First run the existing tests to establish a baseline
- Then implement the fix by adding an npm registry fallback
Assistant
Let me install the required dependencies first.
Assistant
The version installed is 1.4.0 but the tests likely need a specific version. Let me try running the tests now.
<tool_call> <function=bash_terminal> <parameter=command> cd /codex-lb && python -m pytest tests/unit/test_codex_version.py -v 2>&1 | head -80 </tool_call>
Assistant
The user wants me to run tests. Let me run the test command.
Assistant
The test environment is missing dependencies. Let me try to install them or run a simpler approach.
Assistant
Now let me run the tests:
Assistant
All 11 tests pass. Now I understand the issue and the codebase. Let me implement the fix by adding the npm registry as a secondary version source when GitHub fails.
Plan:
- Add
_NPM_REGISTRY_URLconstant pointing tohttps://registry.npmjs.org/@openai/codex/latest - Add
_fetch_latest_version_from_npmmethod that fetches the version from npm registry - Modify
_fetch_latest_versionto try GitHub first, then fall back to npm if GitHub fails - Add tests for the new npm fallback path
- Add
Assistant
The npm registry works and returns the current version
0.145.0. Now let me implement the fix.Assistant
Now let me implement the fix by modifying the
codex_version.pyfile to add npm as a fallback source:Assistant
Let me use the correct edit syntax with the --file option.
Assistant
The edit tool is having trouble with the multi-line replacement. Let me try a different approach - I'll use sed or write the entire file.
Assistant
Good, the file has been written. Let me verify it looks correct and then run the existing tests to ensure they still pass:
Assistant
Now let me run the existing tests to make sure they still pass:
Assistant
All existing tests pass. Now let me create a test script to verify the fix specifically addresses the issue - when GitHub API returns 403, it should now fall back to npm registry instead of directly to the settings default.
Assistant
The test mocking is a bit complex. Let me fix it with a better approach:
Assistant
Let me look at how the existing tests mock the HTTP session - they use a different pattern:
Assistant
Let me look at how the existing tests mock ClientSession:
Assistant
I see the pattern now. The existing tests use
return_value=sessiondirectly on the class patch. Let me use the same pattern:Assistant
All custom tests pass. Now let me verify all existing tests still pass:
Assistant
All 11 existing tests pass. Let me also run the related tests to make sure nothing is broken:
Assistant
All tests pass. Let me clean up the temporary test file and verify my final changes:
Assistant
Let me do a final review of the changes and verify everything is in order:
Assistant
The diff looks correct. Let me verify the final state of the file and run a comprehensive test:
Assistant
All 17 tests pass (11 from codex_version, 1 from model_fetcher, and 5 from model_refresh_scheduler). Let me provide a final summary of the fix:
Summary of Changes
File modified:
app/core/clients/codex_version.pyWhat was changed:
-
Added NPM registry URL constant (
_NPM_REGISTRY_URL): Points tohttps://registry.npmjs.org/@openai/codex/latest, which provides the latest Codex CLI version without GitHub's rate limiting. -
Modified
_fetch_latest_version()method: Now tries GitHub releases first (primary source), then falls back to npm registry before giving up and returning the stale settings default.
-
Assistant
The user wants me to submit my changes. I have successfully implemented the fix for the stale 'client_version' fallback issue by adding an npm registry as a secondary version source when GitHub releases API fails. All existing tests pass, and I've verified the fix works correctly. Let me submit now.
Assistant
The user wants me to call the submit command. Let me do that properly.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.