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
I'll start by exploring the repository structure to understand the codebase and locate relevant files mentioned in the issue. Let's first list the files in the root directory.
- Assistant
Good, I can see the relevant files. Let's first examine the codex_version.py to understand the current fallback logic. Let's open it.
- Assistant
Now let me examine the other relevant files to understand the full picture.
- Assistant
Now let me look at the model_fetcher.py to understand how it uses client_version.
- Assistant
Now let me check the settings to understand the default client_version and other configurations.
- Assistant
Now let me look at the load_balancer.py to understand the
_filter_accounts_for_modelfunction. - Assistant
Let me examine the _filter_accounts_for_model function and surrounding code to understand the flow better.
- Assistant
Now let me examine the existing tests related to the codex_version module to understand the test structure.
- Assistant
Now let me check how the load_balancer.py responds when
_filter_accounts_for_modelreturns empty: - Assistant
Let me look for how that constant is used:
- Assistant
Let me run the existing tests to see if they pass and understand the current behavior:
- Assistant
Let me install test dependencies.
- Assistant
Good, I need to install pytest-asyncio separately:
- Assistant
Let me run the tests again now.
- Assistant
Good, all tests pass. Now let me understand the overall problem better by examining the model registry and load balancer code flow:
- Assistant
Let me check if there's a way to get the client's own version from the request:
- Assistant
Let me check the proxy endpoints to see how client_version is passed:
- Assistant
Let me look at the proxy endpoint to see how requests arrive and if the client version is available from the request:
- Assistant
Let me look at the proxy endpoint to see how the model is determined and if there's a client_version query param from the actual codex CLI request:
- Assistant
Let me look at the proxy endpoint to see what query parameters or headers the Codex CLI sends:
- Assistant
Let me look at how the request from the Codex CLI reaches the load balancer to see if client_version is available somewhere in the request:
- Assistant
Let me look at how the load balancer receives requests to see if the client's own version is available:
- Assistant
Let me look at the existing test for model_fetcher and load_balancer to understand how they're structured:
- Assistant
Now let me check the npm registry format to understand the structure:
- Assistant
Great! The npm registry returns a JSON object with a
versionfield. This is a reliable secondary source.Now let me create a reproduction script to verify the current behavior. First, let me check the current file structure:
- Assistant
Perfect! I can see the issue clearly. When GitHub returns 403, the version falls back to the hardcoded
0.101.0. Now let me plan the fix:I'll implement option #2 from the suggested fixes: Add a secondary version source (npm registry) since it's not rate-limited like the GitHub anonymous API. This is a clean solution that:
- Tries GitHub first (official source)
- Falls back to npm registry if GitHub fails
- Falls back to stale cache or settings default if both fail
Let me implement this fix in
codex_version.py: - Assistant
Now let me apply the fix to the actual file:
- Assistant
Now I'll apply the fix. First, I'll add the npm registry URL constant:
- Assistant
Now I need to modify the
_fetch_latest_versionmethod to try npm when GitHub fails: - Assistant
Now I should also update the warning messages to be more accurate since we're now trying npm as well. Let me update the stale cache and settings default warning messages:
- Assistant
Now let me run the existing tests to see which ones fail due to my changes:
- Assistant
Great! All tests pass. However, I need to verify that my changes actually work as expected. Let me create a test script to verify the npm fallback behavior:
- Assistant
Perfect! The fix works correctly. Now let me run all the tests to make sure I haven't broken anything:
- Assistant
Perfect! All tests pass. Let me also run the full test suite to make sure I haven't broken anything else:
- Assistant
Excellent! All tests pass. Let me verify my fix one more time by looking at the final state of the file:
- Assistant
Perfect! Now let me create a comprehensive test to verify the fix works for the exact scenario described in the issue:
- Assistant
Perfect! The fix works exactly as expected. Now let me complete the checklist and prepare for submission. Let me first check if there are any integration tests:
- Assistant
Now let me write a comprehensive test to verify edge cases and ensure the fix is robust:
- Assistant
Excellent! All edge cases are handled correctly. Now let me complete the checklist and prepare for submission. Let me first verify the changes one more time:
- Assistant
Let me review the complete diff:
- Assistant
Perfect! The diff looks clean and minimal. Let me run the tests one final time to confirm everything passes:
- Assistant
Perfect! All tests pass. Now let me complete the checklist and provide my final answer:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.