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 exploring the repository structure to understand the codebase and locate the relevant files mentioned in the issue description.
The issue is about:
app/core/clients/codex_version.py- fetches codex release version from GitHub APIapp/core/openai/model_refresh_scheduler.py- refreshes model registrymodules/proxy/load_balancer.py:1168- filters accounts for models- Settings default
model_registry_client_version(default0.101.0)
The problem is:
- When GitHub API returns 403 (rate-limited), it falls back to a stale default version (0.101.0)
- The model registry fetches models with this stale client version
- Newer models like
gpt-5.5are gated behind newer client versions - This causes 503 errors when requests try to use these newer models
Let me explore the repository structure first.
Assistant
Let me explore the
appdirectory to find the relevant files.<tool_call> <function=bash_terminal> <parameter=command> find app -name "*.py" | head -50 </tool_call>
Assistant
Let me search for Python files in the app directory properly.
Assistant
Now let me look at the specific files mentioned in the issue description. Let me start with
app/core/clients/codex_version.py:<tool_call> <function=bash_terminal> <parameter=command> cat app/core/clients/codex_version.py </tool_call>
Assistant
Let me use the correct tool syntax for bash_terminal - it needs to be a JSON object with a command field.
Assistant
Now let me look at the settings file to see the default value for
model_registry_client_version:<tool_call> <function=bash_terminal> <parameter=command> cat app/core/config/settings.py </tool_call>
Assistant
I need to use the correct format for bash_terminal - it needs to be a proper JSON object. Let me run the command again.
Assistant
I see the default value for
model_registry_client_versionis"0.101.0"on line 231. Now let me look at themodel_refresh_scheduler.pyto understand how the version is used:<tool_call> <function=bash_terminal> <parameter=command> cat app/core/openai/model_refresh_scheduler.py </tool_call>
Assistant
I need to properly format the bash_terminal command. Let me try again.
Assistant
Now let me look at the
model_fetcher.pyto see how it fetches models:<tool_call> <function=bash_terminal> <parameter=command> cat app/core/clients/model_fetcher.py </tool_call>
Assistant
I need to run the bash command to view the model_fetcher.py file.
Assistant
Now I understand the problem. Let me look at the load_balancer.py to see the
_filter_accounts_for_modelfunction that's mentioned in the issue:<tool_call> <function=bash_terminal> <parameter=command> cat modules/proxy/load_balancer.py | head -1200 | tail -100 </tool_call>
Assistant
I need to properly run the bash command to view the load_balancer.py file. Let me do that.
Assistant
Let me check the correct path to load_balancer.py.
Assistant
Good, the file is at
app/modules/proxy/load_balancer.py. Let me view it.Assistant
Now I have a good understanding of the issue. The problem is:
codex_version.pytries to fetch the latest codex version from GitHub API- If it fails (e.g., 403 rate limit), it falls back to
model_registry_client_versionsetting which defaults to"0.101.0" model_fetcher.pyuses this version when fetching models from upstream- Upstream gates newer models (like
gpt-5.5) behind newer client versions - The model registry never gets the
gpt-5.5model _filter_accounts_for_modelreturns empty set because the model isn't in the registry- Requests for
gpt-5.5fail with 503no_plan_support_for_model
Now, let me look at the test files to understand what tests exist and how to run them:
<tool_call> <function=bash_terminal> <parameter=command> ls -la tests/ </tool_call>
Assistant
Let me run the command to list test files.
Assistant
Let me check the tests/unit directory for unit tests and find if there are tests for codex_version.py.
Assistant
Let me look at the test file for codex_version.py to understand how it works and what tests exist.
<tool_call> <function=bash_terminal> <parameter=command> cat tests/unit/test_codex_version.py </tool_call>
Assistant
I need to run a command to view the test file. Let me use the bash_terminal properly.
Assistant
Now I have a good understanding of the issue. The problem is:
- When GitHub API returns 403 (rate-limited), the fallback is to
model_registry_client_versiondefault"0.101.0" - The issue suggests 4 potential fixes:
- Bump the baked-in default to a newer version
- Add a secondary version source (npm registry)
- Cache the fetched version on disk
- Honor the client's own
client_versionquery string
Looking at the issue description, the best low-effort options would be:
- Add a secondary version source - npm registry is not rate-limited like GitHub's anonymous API
- Bump the default version - But this requires changing code on every release
The most effective solution would be to add the npm registry as a fallback when GitHub API fails. This is because:
- npm registry version endpoint is typically not rate-limited for anonymous requests
- It's already a known source for the
@openai/codexpackage - It requires minimal code changes
Let me check the current state of the npm registry API for the codex package:
- When GitHub API returns 403 (rate-limited), the fallback is to
Assistant
Let me run the curl command to check the npm registry API.
Assistant
The npm registry returns JSON with a
versionfield. Now let me also check the standard npm registry endpoint to see if it returns the version directly:<tool_call> <function=bash_terminal> <parameter=command> curl -sL https://registry.npmjs.org/@openai/codex | grep -o '"version":"[^"]*"' | head -5 </tool_call>
Assistant
Let me try the curl command properly.
Assistant
This returns old versions. Let me check if there's a better endpoint:
Assistant
The
@openai/codex/latestendpoint returns JSON with"version":"0.144.6". This is exactly what we need!Now let me implement the fix. The approach will be:
- Add a new async method to
CodexVersionCachethat fetches the version from npm registry - Modify
get_version()to try GitHub first, then fall back to npm registry, and finally fall back to settings default - Update the tests accordingly
Let me also update the default version in settings to something more recent. Looking at the npm registry, the current version is 0.144.6, so we could bump the default to something like 0.130.0 (the version mentioned in the issue as working).
Actually, let me reconsider. The issue description suggests that the default should be updated on each release. The better approach would be:
- Keep the default version at a reasonable current value (e.g., 0.130.0 or 0.140.0)
- Add npm registry as a secondary source when GitHub API fails
Let me implement the fix by modifying
codex_version.py:<tool_call> <function=bash_terminal> <parameter=command> cat app/core/clients/codex_version.py </tool_call>
- Add a new async method to
Assistant
I need to run the bash command to view the codex_version.py file.
Assistant
Now I understand the issue and have verified the npm registry works. Let me implement the fix by modifying
codex_version.pyto add npm registry as a secondary source when GitHub API fails.Assistant
The tool call failed. The
edittool has a different format. Let me use the propereditcommand format with--fileand proper line ranges.First, let me find the line numbers for the content I want to replace:
<tool_call> <function=bash_terminal> <parameter=command> wc -l app/core/clients/codex_version.py </tool_call>
Assistant
Let me run the wc command to count the lines in the file.
Assistant
The file has 86 lines. Let me use a different approach - I'll open the file in the editor and make changes. Let me first try the
createcommand to create a new file with the updated content, and then use bash to move it.<tool_call> <function=bash_terminal> <parameter=command> cp app/core/clients/codex_version.py app/core/clients/codex_version.py.bak </tool_call>
Assistant
I need to run the bash command to back up the file.
Assistant
Assistant
I need to run the cat command to create the new file. Let me try again with proper syntax.
Assistant
Good, the file was created. Let me verify it was written correctly by checking its contents:
<tool_call> <function=bash_terminal> <parameter=command> cat app/core/clients/codex_version.py </tool_call>
Assistant
Let me run the cat command properly to view the file contents.
Assistant
The file has been updated successfully with the npm registry fallback. Now I also need to bump the default version in
settings.pyfrom"0.101.0"to a more recent version to provide better coverage for newer models. Let me check the exact line in settings.py:Assistant
Now let me update the default version in settings.py. I'll use sed to replace the old default with a newer one:
Assistant
Let me verify the change was made:
Assistant
Now I need to update the test file to include tests for the npm registry fallback. Let me also run the existing tests to make sure they still pass:
Assistant
I need to install the dependencies first. Let me check the pyproject.toml to see how to install dependencies:
Assistant
Let me try to use the virtual environment that's already set up in the repository:
<tool_call> <function=bash_terminal> <parameter=command> source .venv/bin/activate && python -m pytest tests/unit/test_codex_version.py -v 2>&1 | head -100 </tool_call>
Assistant
Let me try to activate the virtual environment and run the tests.
Assistant
The tests are failing because I changed the default version from "0.101.0" to "0.140.0" in settings.py. The tests need to be updated to reflect this new default. Also, the tests are patching aiohttp.ClientSession which causes the npm registry fallback to fail with the mocked session.
I have two options:
- Update the tests to use the new default version "0.140.0"
- Keep the old default version and only rely on the npm registry fallback
The better approach would be to update the tests to use the new default version since I intentionally changed it to a more recent version. Let me update the test file:
<tool_call> <function=bash_terminal> <parameter=command> sed -i 's/assert version == "0.101.0"/assert version == "0.140.0"/g' tests/unit/test_codex_version.py </tool_call>
Assistant
The sed command was invoked, let me verify the changes were applied correctly and run the tests again.
Assistant
I see that the sed command didn't work as expected. Let me view the test file and update it properly:
Assistant
I see. The sed command didn't work. Let me manually edit the test file to update the expected version from "0.101.0" to "0.140.0":
<tool_call> <function=bash_terminal> <parameter=command> sed -i 's/0.101.0/0.140.0/g' tests/unit/test_codex_version.py </tool_call>
Assistant
I need to run the sed command to update the test file. Let me try again with the proper syntax.
Assistant
Let me verify the changes and run the tests again.
Assistant
All tests pass. Now let me add a test for the npm registry fallback to ensure the new functionality is properly tested:
Assistant
Let me run the tests again to make sure the new tests pass:
Assistant
The test I added has issues with the async mock. Let me rewrite the test file with proper async mock handling:
Assistant
Let me view the current test file and properly add the new tests:
Assistant
The test file was cut off. Let me recreate it properly with the new tests:
Assistant
Let me run the tests again to make sure all tests pass:
Assistant
Assistant
I need to run the cat command to create the test file with proper async mock handling.
Assistant
Now let me run the tests again to verify they all pass:
<tool_call> <function=bash_terminal> <parameter=command> source .venv/bin/activate && python -m pytest tests/unit/test_codex_version.py -v 2>&1 </tool_call>
Assistant
I need to run the pytest command to verify all tests pass.
Assistant
Assistant
Let me run the cat command to update the test file with sync mock functions instead of async ones.
Assistant
Now let me run the tests again to see if they all pass:
<tool_call> <function=bash_terminal> <parameter=command> source .venv/bin/activate && python -m pytest tests/unit/test_codex_version.py -v 2>&1 </tool_call>
Assistant
I need to run the pytest command to verify the tests pass. Let me execute it properly.
Assistant
All 15 tests pass. Now let me also run some additional tests related to the model fetcher and model registry to ensure I didn't break anything:
Assistant
All related tests pass. Now let me create a simple script to verify that the fix works as expected by simulating the scenario described in the issue:
Assistant
I need to run the test script to verify the fix works correctly. Let me execute the command properly.
Assistant
The file wasn't created properly. Let me create it again and run it.
<tool_call> <function=bash_terminal> <parameter=command> cat > /tmp/test_fix.py << 'EOF' """Test script to verify the fix for GitHub rate-limit fallback.""" import asyncio from unittest.mock import AsyncMock, MagicMock, patch import aiohttp
Assistant
I need to run the bash command to create and execute the test script. Let me do that.
Assistant
The fix works correctly. The test shows that when GitHub API returns 403, the code falls back to the npm registry and gets a valid version.
Now let me clean up and summarize the changes made:
-
Modified
app/core/clients/codex_version.py:- Added npm registry URL constant
_NPM_REGISTRY_URL - Added
jsonimport for parsing JSON response - Added new method
_fetch_from_npm()to fetch version from npm registry - Modified
_fetch_latest_version()to try GitHub first, then fallback to npm registry
- Added npm registry URL constant
-
Modified
app/core/config/settings.py:- Updated default
model_registry_client_versionfrom"0.101.0"to"0.140.0"
- Updated default
-
Updated
tests/unit/test_codex_version.py:- Updated all test assertions to expect
"0.140.0"instead of"0.101.0" - Added 3 new tests for npm registry fallback behavior
- Updated all test assertions to expect
Let me verify the changes and clean up the backup file:
<tool_call> <function=bash_terminal> <parameter=command> rm -f app/core/clients/codex_version.py.bak /tmp/test_fix.py /tmp/test_codex_version_temp.py </tool_call>
-
Assistant
I need to run the command to clean up the backup file and temporary files.
Assistant
Now let me verify all the changes made by running all related tests to ensure everything works correctly:
Assistant
All 35 tests pass. Now let me verify the changes I made are correct by looking at the git diff:
<tool_call> <function=bash_terminal> <parameter=command> git diff </tool_call>
Assistant
I need to run git diff to see all the changes I made.
Assistant
I notice that I added
import jsonbut didn't actually use it (I'm usingresp.json()which is the aiohttp response method, not the json module). Let me remove the unused import:Assistant
Let me verify the change and run the tests again:
Assistant
All tests pass. Let me verify the final diff:
Assistant
All changes look correct. Let me now summarize the changes and submit:
Summary of Changes
The issue described that when the GitHub releases API returns HTTP 403 (rate-limited), the system falls back to a stale default version (
0.101.0), causing newer models likegpt-5.5to be unavailable, resulting in 503 errors.Changes Made:
-
app/core/clients/codex_version.py:- Added npm registry URL constant
_NPM_REGISTRY_URL - Split
_fetch_latest_version()into two methods: and
- Added npm registry URL constant
-
Assistant
All tests pass. The fix is complete and addresses the issue by adding the npm registry as a fallback when GitHub's API returns HTTP 403. Let me submit the changes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.