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 in
app/core/clients/codex_version.py- when it can't fetch the latest codex release from GitHub API (e.g., due to rate limiting), it falls back to a default version (0.101.0). -
This old version causes the model registry to not include newer models like
gpt-5.5, resulting in 503 errors. -
The suggested fixes are:
- Bump the baked-in default
- Add a secondary version source (npm registry)
- Cache the fetched version on disk
- Honor the client's own
client_versionquery string
Let me start by exploring the repository structure to understand the codebase.
-
Assistant
Let me look at the specific file mentioned in the issue.
Assistant
Good, let me look at these three key files to understand the problem.
Assistant
The open command requires a specific format. Let me try again.
Assistant
Now I can see the file. The issue is that when the GitHub API fails, it falls back to a stale default version. The suggested fix #2 (add a secondary version source using npm registry) would be a good approach, along with fix #3 (cache on disk).
Let me also look at the settings to understand the default version.
Assistant
Let me also check the model_fetcher and related files to understand how the client_version is used.
Assistant
Now let me understand the issue more:
- The
CodexVersionCacheclass tries to fetch the latest codex version from GitHub releases API - If that fails (e.g., 403 rate limit), it falls back to a hardcoded default version (0.101.0)
- This old version causes the model registry to not include newer models like gpt-5.5
- The result is 503 errors with
no_plan_support_for_model
The suggested fixes are:
- Bump the default - this works but requires updates on each release
- Add npm registry as a secondary source - not rate-limited like GitHub
- Cache on disk - survives container restarts and transient 403s
- Honor client's client_version query string - new client bootstraps the registry
Looking at the code more carefully, I see that the
CodexVersionCachealready has in-memory caching. But there's no disk caching. The issue is:- When GitHub API fails, it falls back to the stale default version
- The in-memory cache only lasts for the container lifetime (1 hour TTL)
The best approach seems to combine multiple fixes:
- The
Assistant
Now let me check how the
CodexVersionCacheis used throughout the codebase to understand the full impact of changes.Assistant
Now let me see the model_fetcher.py to understand how the version is used.
Assistant
Let me check for existing tests related to codex_version:
Assistant
Let me read the test files to understand what tests exist and how to properly fix the issue.
Assistant
Now I have a clear understanding of the issue. Let me look at the test files and the conftest:
Assistant
Now I have a thorough understanding of the codebase. Let me analyze the issue and plan the fix:
Problem: When GitHub releases API fails (e.g., rate-limited with 403), the
CodexVersionCachefalls back to settings default0.101.0, causing newer models likegpt-5.5to be unavailable.Solution approach: Combine multiple suggested fixes:
- Add npm registry as secondary version source -
https://registry.npmjs.org/@openai/codex/latestis not rate-limited - Add disk caching - Persist version to data directory so it survives restarts and transient failures
- Keep settings default as last resort but with improved fallback chain
Let me implement the fix:
- Add npm registry as secondary version source -
Assistant
Now I have a thorough understanding of the issue. Let me implement the fix by combining multiple suggested approaches:
- Add npm registry as secondary version source (not rate-limited like GitHub)
- Add disk caching (persists across restarts, survives transient failures)
- Improved fallback chain: GitHub → npm → disk cache → settings default
Let me update the
codex_version.pyfile:Assistant
Now let me verify the file was written correctly:
Assistant
Now let me run the existing tests to see what needs updating:
Assistant
Let me install the required dependencies and run the tests.
Assistant
The pip install seems to have completed. Let me check if pytest-asyncio is installed and try running the tests again.
Assistant
Let me try running the tests again now that packages are installed:
Assistant
Let me check if there's a virtual environment in the repo:
Assistant
Good, there's a virtual environment. Let me use it to run the tests.
Assistant
I see the test failures. The issue is that my implementation adds disk caching and npm fallback, but the test conftest only resets the in-memory cache, not the disk cache file. This means tests that expect fallback to settings default are finding the disk cache from previous tests.
I need to update the test conftest to also clean up the disk cache file. Let me also think about edge cases:
Assistant
The test failures are happening because my disk cache persists across tests. The conftest resets the in-memory cache but not the disk cache file. I need to update the conftest to also clean up the disk cache file. Let me do that:
Assistant
Now I need to update the conftest.py to also clean up the disk cache file. Let me edit it.
Assistant
I need to update the conftest to also clean up the disk cache file. Let me edit it:
Assistant
There's a duplicate function now. Let me view the file and fix it properly.
Assistant
The file got corrupted. Let me restore it properly from git and then make a clean edit:
Assistant
Now let me re-examine the file and make a proper edit.
Assistant
Now let me properly edit the
_reset_codex_version_cachefixture to also clean up the disk cache:Assistant
The edit command format seems to not be working properly. Let me try with the proper format.
Assistant
The edit command seems to be having issues. Let me try a different approach using bash to create the new file content.
Assistant
Let me use a different approach to edit the file:
Assistant
Good. Now let me run the tests again to see the current state:
Assistant
All 11 existing tests pass. Now let me add new tests for the npm registry fallback and disk caching features. Let me also check if there are any other tests I should run:
Assistant
All tests pass. Now let me create a script to verify the fix works as described in the issue:
Assistant
The test failed because the disk cache from a previous test run persisted (the verify script runs outside pytest's fixture system). Let me fix the verify script to clean up between tests:
Assistant
I need to add the import for aiohttp in the test script. Let me fix that.
Assistant
All tests pass. Now let me run the full test suite to ensure nothing else is broken:
Assistant
All 1889 tests pass. Let me verify my changes are correct by viewing the final state of the modified files:
Assistant
Let me clean up the temporary verification script and then summarize what was done:
Assistant
The user wants me to submit my changes. I've successfully:
-
Modified
app/core/clients/codex_version.pyto add:- NPM registry as a secondary version source (fix #2 from the issue)
- Disk caching to persist version across container restarts (fix #3 from the issue)
- Improved fallback chain: GitHub → NPM → Disk Cache → Settings Default
-
Modified
tests/conftest.pyto clean up the disk cache file between tests to prevent state leakage
All 1889 unit tests pass. Let me submit.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.