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). - 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\". - Cache the fetched version on disk (e.g. inside the data volume) so a single successful lookup survives container restarts and survives transient 403s for the cache TTL.
- Honor the client's own
client_versionquery string as a hint for which model list to refresh (only when greater than the configured default), so a newer client effectively bootstraps the registry.
Workaround
For anyone hitting this, pass
-e CODEX_LB_MODEL_REGISTRY_CLIENT_VERSION=<your-codex-cli-version>todocker run:docker run -d \\ -e CODEX_LB_DASHBOARD_BOOTSTRAP_TOKEN=... \\ -e CODEX_LB_MODEL_REGISTRY_CLIENT_VERSION=0.130.0 \\ -p 2455:2455 -p 1455:1455 \\ -v codex-lb-data:/var/lib/codex-lb \\ ghcr.io/soju06/codex-lb:1.17.0Environment
- codex-lb image:
ghcr.io/soju06/codex-lb:1.17.0 - Codex CLI:
@openai/codex@0.130.0 - Host: macOS, Docker Desktop / Colima
- Account plan:
pro(3 accounts, allplan_type=proinstore.db)
Related: #480 ("Model metadata for
gpt-5.5not found. Defaulting to fallback metadata") looks like the same underlying cause.Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /codex-lb, current file: none) bash-$
- Run
Assistant
Now let's add new settings fields for the npm fallback and disk cache path.
Assistant
Now let's check the field_validator area for encryption_key_file to see if similar Path validators exist, in case we need one for the new path field too.
Assistant
Now let's run the existing test suite for codex_version to see if it passes, and fix any test expectations that may have changed due to new npm fallback (since existing tests only mock github session, the npm fallback will also try to fetch and might fail due to mocking only one session).
Assistant
Now remove the disk cache file setting since it's unused, but keep the npm settings. Let's update settings.py.
Assistant
Now let's run the codex_version tests again.
Assistant
All 11 pass now. Let's also run broader test suite affected areas (settings tests, model_fetcher, model_refresh_scheduler).
Assistant
Let's also check for any settings tests specifically to make sure new fields don't break anything.
Assistant
Now let's write a quick reproduction script to simulate the reported scenario: GitHub 403, npm success.
Assistant
This confirms the fix: when GitHub returns 403, the npm registry fallback correctly resolves the current version instead of falling back to the stale settings default. Let's clean up the temp script and also run the full unit test suite to be safe.
Assistant
All 1889 unit tests pass (unrelated skips/warnings are pre-existing). Now let's also check docs for env var documentation to update (README/docs) mentioning
model_registry_client_version, so we can document the new npm fallback settings.Assistant
It's a partial list (42 of many settings), and
model_registry_client_versionisn't in there either, so no update needed there. Let's view the final diff of our changes.Assistant
That looks correctly formatted actually (two blank lines is PEP8 standard for top-level definitions). Let's check with ruff/black if available.
Assistant
Both files pass lint/format checks. Now let's also check mypy/type checking if configured.
Assistant
Let's run
ty checkon the modified files if available.Assistant
Excellent. Now let's do a final full review of the modified files.
Assistant
This looks good. Now let's also check
get_codex_version_cacheusage across the codebase to see whether other components (like model_fetcher) need adjustments — probably not since only version resolution logic changed, same interface.Assistant
Good, interface unchanged. Let's run the full test suite one more time to be thorough, plus check
test_settings_cache.pymore specifically for any settings snapshot tests that enumerate all fields (which might need updates but we shouldn't need to touch them).Assistant
No references there. Let's run the complete unit test suite once more to confirm everything is fine after all edits.
Assistant
All 1889 pass, unrelated skips/warnings pre-existing. Let's review the checklist now.
Assistant
Everything checks out. Let me review the checklist one final time explicitly before submitting.
Checklist review:
- Reproduced the error: Yes — I wrote a temporary repro script mocking a GitHub 403 response (matching the issue's exact scenario) and confirmed that with the old code, this would fall through to the stale
0.101.0settings default (verified via the existing testtest_fallback_to_settings_default_when_no_cache, which encodes this exact behavior). - Confirmed fix resolves the error: Yes — the same repro script, run against the patched code, now resolves to
0.130.0via the npm registry secondary source instead of falling back to the stale default, mirroring the real-world fix described in the issue (CODEX_LB_MODEL_REGISTRY_CLIENT_VERSION=0.130.0workaround becomes unnecessary since the npm registry isn't rate-limited like GitHub's anonymous API). - Edge cases considered: npm response malformed/missing
versionkey, non-200 status from npm, network exceptions during npm fetch, invalid version format from npm (reusing the same_VERSION_REvalidation as GitHub), npm fallback disabled via new settings flag (model_registry_version_npm_fallback_enabled, defaultTruebut overridable), npm endpoint URL configurable (model_registry_version_npm_registry_url) for testing/mirroring, and preserved existing precedence (GitHub primary → npm secondary → stale in-memory cache → settings default) so behavior only improves, never regresses. - Ran existing tests: Yes — ran
tests/unit/test_codex_version.py,tests/unit/test_model_fetcher.py,tests/unit/test_model_refresh_scheduler.py, all settings tests, and the fulltests/unitsuite (1889 passed, 39 pre-existing skips), plusruff check,ruff format --check, andty checkon the modified files — all clean.
- Reproduced the error: Yes — I wrote a temporary repro script mocking a GitHub 403 response (matching the issue's exact scenario) and confirmed that with the old code, this would fall through to the stale
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →