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 understand the issue:
- When the GitHub releases API returns 403 (rate limited), the code falls back to a hardcoded default client version (0.101.0)
- This old client version doesn't have access to newer models like
gpt-5.5 - As a result, the model registry never gets the newer models, causing 503 errors for requests to use those models
The suggested fixes are:
- Bump the baked-in default version on each release
- Add a secondary version source (npm registry)
- Cache the fetched version on disk
- Honor the client's own
client_versionquery string
Let me first explore the repository structure to understand the codebase.
Assistant
Let me look at the main source files mentioned in the issue - the codex_version.py and model_refresh_scheduler.py files.
Assistant
Let me view the codex_version.py file first.
Assistant
<tool_call> <function=bash_terminal> <parameter=command> cat /codex-lb/app/core/clients/codex_version.py </tool_call>
Assistant
Let me use bash_terminal to view the file instead.
Assistant
Now let me look at the settings file to see where the default version is defined.
<tool_call> <function=bash_terminal> <parameter=command> find /codex-lb/app -name "settings.py" | head -5 </tool_call>
Assistant
Let me search for the settings file properly.
Assistant
The issue is about stale 'client_version' fallback causing 503 errors when GitHub releases API rate-limits. Let me understand the problem:
- When GitHub releases API returns 403, the code falls back to a default version (0.101.0)
- This old version doesn't have access to newer models like
gpt-5.5 - The suggested fixes are:
- Bump the baked-in default version on each release
- Add a secondary version source (npm registry)
- Cache the fetched version on disk
- Honor the client's own
client_versionquery string
Let me first see the settings file to understand the default version configuration. </tool_call>
Assistant
I need to use the bash_terminal tool properly to run shell commands. Let me view the settings file.
Assistant
Now let me look at the model_refresh_scheduler.py to understand how it uses the client_version.
<tool_call> <function=bash_terminal> <parameter=command> find /codex-lb/app -name "model_refresh_scheduler.py" 2>/dev/null | head -5 </tool_call>
Assistant
I need to use bash_terminal properly to find the model_refresh_scheduler.py file.
Assistant
The issue is that when GitHub releases API returns 403 (rate-limited), the code falls back to a hardcoded default client version (0.101.0) which is too old for newer models like
gpt-5.5. The suggested fix is to add a secondary version source (npm registry) since npm view @openai/codex version is not rate-limited.Let me first look at the model_refresh_scheduler.py to understand how it uses the client_version.
Assistant
Now let me look at the model_fetcher.py to understand how it uses the client_version. </tool_call>
Assistant
The user wants me to use the bash_terminal tool to run shell commands. I already ran a command successfully. Let me continue reading the model_fetcher.py file to understand how client_version is used.
Assistant
Now I understand the issue better. The problem is:
- In
codex_version.py, when GitHub API returns 403 (rate-limited), it falls back to the default version from settings (0.101.0). - This old version doesn't have access to newer models like
gpt-5.5. - The fix suggested is to add a secondary version source (npm registry) since
npm view @openai/codex versionis not rate-limited.
Looking at the code:
codex_version.pyhas theCodexVersionCacheclass that fetches the latest version from GitHub- If GitHub fails, it falls back to
settings.model_registry_client_version(default 0.101.0) model_fetcher.pycallsget_codex_version_cache().get_version()to get the client version
The fix should:
- Add a fallback to npm registry when GitHub fails
- Keep the current settings default as a last resort
Let me modify the
codex_version.pyfile to add npm registry as a secondary version source.Looking at the npm registry API:
https://registry.npmjs.org/@openai/codexreturns JSON with the latest version in
- In
Assistant
I need to use the bash_terminal tool to run commands. I understand the issue now. Let me implement the fix for the
codex_version.pyfile to add npm registry as a secondary version source when GitHub API rate-limits. </tool_call>Assistant
I need to understand the issue better. Let me look at the codex_version.py file and understand how to add a secondary version source (npm registry) when GitHub API rate-limits.
The issue is:
- When GitHub releases API returns 403 (rate-limited), the code falls back to the default version (0.101.0)
- This old version doesn't have access to newer models like
gpt-5.5 - The suggested fix is to add a secondary version source (npm registry) since npm view @openai/codex version is not rate-limited
I need to modify the
codex_version.pyfile to:- Try GitHub API first
- If GitHub fails, try npm registry as a fallback
- If npm fails, fall back to the settings default
Let me first look at the current code to understand how to modify it. </tool_call>
Assistant
I understand the issue now. The problem is that when GitHub releases API rate-limits with HTTP 403, the code falls back to a hardcoded default version (0.101.0) which is too old for newer models like gpt-5.5. I need to add npm registry as a secondary version source before falling back to the settings default.
Let me first view the current codex_version.py file:
Assistant
Now I understand the issue. When GitHub API rate-limits (returns 403), the code falls back to the settings default (0.101.0), which is too old for newer models like gpt-5.5.
The fix is to add npm registry as a secondary version source before falling back to the settings default. The npm registry API is not rate-limited like GitHub's anonymous API.
The npm registry API for @openai/codex:
- URL: https://registry.npmjs.org/@openai/codex
- Returns JSON with
dist-tags.latestcontaining the latest version
I'll modify the
_fetch_latest_versionmethod to try GitHub first, then npm registry if GitHub fails. </tool_call>Assistant
I need to fix the
codex_version.pyfile to add npm registry as a secondary version source when GitHub API fails. Let me modify the file:Assistant
Good, the file was created. Now let me copy it to the actual location to replace the original file. </tool_call>
Assistant
I need to copy the fixed file to replace the original file. </tool_call>
Assistant
Let me copy the fixed file to the actual location using cp command.
Assistant
The file has been copied successfully. Let me verify the changes are in place by viewing the file. </tool_call>
Assistant
Let me use bash_terminal to view the file and verify the changes. </tool_call>
Assistant
Let me verify the changes by reading the file content.
Assistant
The file has been updated successfully. Now I should check if there are any existing tests in the repository that I should run to make sure my changes don't break anything.
Let me also verify that the npm registry API actually returns the expected format by testing it. </tool_call>
Assistant
Let me test the npm registry API to make sure it returns the expected format, and then look for existing tests in the repository. </tool_call>
Assistant
I need to run the bash_terminal command to test the npm registry API and find existing tests in the repository.
Assistant
The npm registry API returns the expected format with
dist-tags.latestcontaining the latest version. The latest version is0.144.6. However, my regex pattern_VERSION_RE = re.compile(r"^\d+\.\d+\.\d+$")won't match this version because it has the format0.144.6which should match the pattern. Let me verify this.Actually, looking at the version
0.144.6, it matches the pattern^\d+\.\d+\.\d+$(0.144.6). Let me test this regex pattern.Now let me look for existing tests in the repository to make sure my changes don't break anything. </tool_call>
Assistant
Let me search for existing tests related to codex_version or model_fetcher to ensure my changes don't break anything.
Assistant
Let me search for tests related to codex_version or model_refresh:
Assistant
Good, there's a test file for codex_version. Let me look at it to understand the existing tests and make sure my changes are compatible. </tool_call>
Assistant
Let me view the test file for codex_version to understand the existing tests.
Assistant
Assistant
I need to use bash_terminal to run the command to view conftest.py.
Assistant
Now I understand the test setup. The
_reset_codex_version_cachefixture resets the cache between tests to ensure each test starts with a fresh cache.Let me now run the existing tests for codex_version to verify my changes don't break anything. </tool_call>
Assistant
I need to run the existing tests to verify my changes don't break anything. Let me run the test file for codex_version.
Assistant
The test requires pytest_asyncio module which is not installed. Let me check if there's a requirements file or if I can install the dependencies from the project. </tool_call>
Assistant
Let me check if there's a way to install the test dependencies. The project might have a setup.py or pyproject.toml file.
Assistant
The project has a .venv directory. Let me check if I can use the virtual environment to run the tests.
Assistant
The virtual environment has pytest installed. Let me try running the tests using the virtual environment's pytest.
Assistant
All 11 existing tests for codex_version pass! This confirms that my changes don't break the existing functionality.
Now, let me also run some related tests to ensure my changes don't affect other parts of the codebase. Let me run the tests for model_fetcher and model_refresh_scheduler. </tool_call>
Assistant
All 11 existing tests for codex_version pass! Now let me run the related tests for model_fetcher and model_refresh_scheduler to ensure my changes don't affect other parts of the codebase.
Assistant
All related tests pass. Now let me create a simple test script to verify the npm registry fallback behavior works correctly when GitHub fails.
Assistant
The test script confirms that my implementation works correctly:
- When GitHub returns HTTP 403 (rate limited), the code falls back to npm registry and fetches the version from there.
- When GitHub returns an invalid version name, the code falls back to npm registry and fetches the version from there.
- When GitHub returns a valid version, the code uses GitHub and doesn't call npm registry.
Now let me verify the changes one more time by viewing the modified file and then submitting the solution. </tool_call>
Assistant
Let me verify the changes by viewing the git diff:
Assistant
The git diff shows all the changes I made:
- Added
_NPM_REGISTRY_URLconstant for the npm registry endpoint. - Updated the log messages to be more generic (removed "GitHub" from the log messages since the source could be GitHub, npm, or cache).
- Modified
_fetch_latest_version()to try GitHub first, then npm registry, and returnNoneif both fail. - Added
_fetch_from_github()method to extract the GitHub fetching logic. - Added
_fetch_from_npm()method to fetch the version from npm registry.
The changes implement the suggested fix #2 from the issue description: "Add a secondary version source.
npm view @openai/codex versionagainsthttps://registry.npmjs.orgis not rate-limited the way the GitHub anonymous API is, and a static fetch ofhttps://registry.npmjs.org/@openai/codex/latestreturns JSON containing\"version\"."Now let me clean up the temporary test file and submit the solution. </tool_call>
- Added
Assistant
Let me clean up the temporary test file and then submit the solution.
Assistant
Let me run all the unit tests related to codex_version and model_fetcher one more time to ensure everything is working correctly.
Assistant
All 17 tests pass. Now let me submit the solution. </tool_call>
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.