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
Let me start by exploring the repository structure to understand the codebase.
Assistant
Let me explore the repo structure.
Assistant
Now let me look at the settings file and model_fetcher.
Assistant
Let me look at the settings file to understand the context:
Assistant
Now let me look at the tests for codex_version and look at the broader testing infrastructure.
Assistant
Now let me check tests directory structure more thoroughly and see if there's already a test that we need to be aware of:
Assistant
Let me look at how
fetch_models_for_planis being called and understand the model registry refresh flow:Assistant
Let me explore how requests come in to see if we can detect the client's client_version:
Assistant
The client sends an
x-openai-client-versionheader to upstream but this is currently just forwarded, not consumed. Let me look at what's in service.py and see how client_version is received:Assistant
Let me look at the load balancer to understand how the model is matched for routing:
Assistant
Let me look at existing tests for the load balancer and look at existing test fixtures to understand the conventions:
Assistant
Let me also check the proxy module to understand how the request flow works:
Assistant
Let me check what happens when the registry is empty or doesn't have the model:
Assistant
Let me check what data directory is used and look at related code:
Assistant
Now let me look at how the tests use
_filter_accounts_for_modeland the overall request flow:Assistant
Let me look at how upstream requests are made in the proxy:
Assistant
Now I have a clear plan. Let me create a reproduction script first to confirm my understanding:
Assistant
The bug is confirmed. Now let me implement the fix. I'll:
- Add npm registry as a secondary version source (not rate-limited like GitHub's anonymous API)
- Add disk-based persistence so cached version survives container restarts
- Update default
model_registry_client_versionto a more recent version
Let me first look more carefully at how the disk-based persistence should work:
Assistant
Let me look at how the data directory gets created:
Assistant
Now let me look at what versions are referenced elsewhere (related to npm registry or fixtures):
Assistant
Now let me design my implementation. First, let me look at relevant parts of the code:
Assistant
Now let me implement the fix. I'll modify
codex_version.pyto:- Add npm registry fallback as a secondary version source
- Add disk-based persistence of fetched version
Assistant
Let me now write the comprehensive fix. I'll make these changes:
codex_version.py- Add disk-based caching and npm registry fallbacksettings.py- Update default version to be more current
Assistant
Now let me update the
settings.pyto bump the default. Let me also update the conftest fixture to reset the new disk cache path:Assistant
Let me re-examine my approach and refine the disk cache behavior:
Assistant
Let me clean up the type hints using the
Ellipsistype directly rather than the convolutedtype(...)pattern:Assistant
Now let me run the existing tests to see if my changes broke anything:
Assistant
Let me check the conftest setup more carefully:
Assistant
I need to rethink the disk cache default. Let me check whether existing tests would break due to disk cache pollution between tests:
Assistant
I need to make disk cache opt-in by default, to avoid breaking existing tests. Let me update:
Assistant
Now let's run the tests:
Assistant
All tests pass. Now let me write a more thorough reproduction script to verify my fix works:
Assistant
Excellent! All four scenarios pass. Let me run the full test suite to ensure nothing else is broken:
Assistant
All 1889 unit tests pass. Let me also check the integration tests:
Assistant
Let me verify everything still works with a more thorough test of all related test files:
Assistant
Let me check if there's any other reference to codex_version that might be affected:
Assistant
Let me also run a more rigorous subset of tests around the model registry and proxy to make sure my changes don't break anything:
Assistant
Let me also verify with the
test_proxy_api_responses_contract.pywhich seems most relevant:Assistant
Let me check the container detection logic to verify the disk cache path resolution:
Assistant
Let me write a more thorough end-to-end test to simulate the actual reported scenario:
Assistant
Let me check if there are any additional project guidelines I should follow:
Assistant
Let me verify the model_fetcher.py is unchanged in its core behavior:
Assistant
Let me run my comprehensive verification one more time after all changes:
Assistant
Let me run all unit tests and the integration tests one more time to make sure everything is intact:
Assistant
Let me also run the complete unit test suite one more time:
Assistant
Let me check that linting is clean:
Assistant
Let me verify everything still passes after formatting:
Assistant
Let me also re-verify the fix scenarios pass after reformat:
Assistant
Let me check the final code:
Assistant
Let me check my git diff to see all the changes I've made:
Assistant
Let me clean up my temporary test files and finalize:
Assistant
Let me run the tests one final time:
Assistant
Let me also run all the model-related integration tests:
Assistant
Let me also re-verify the existing test for stale cache fallbacks still passes:
Assistant
Let me confirm my final state and that all changes are clean:
Assistant
All changes look clean. Let me provide a final review of my approach:
Checklist review:
-
Reproduced the error: ✅ I wrote and ran a reproduction script that confirmed the bug: with GitHub 403 (rate limited), the system falls back to the stale
0.101.0default. -
Confirmed my fix resolves the error: ✅ I verified all scenarios:
- GitHub 403 + npm registry works → returns current npm version (e.g.,
0.130.5), not the stale default. - Container restart + total network failure → returns the disk-cached version (e.g.,
0.130.0), not the stale default. - Total network failure + no cache → returns the settings default (preserved as last-resort fallback).
- Successful GitHub fetch → persists to disk for future restarts.
- GitHub 403 + npm registry works → returns current npm version (e.g.,
-
Thought about edge cases: ✅ I considered and handled:
- Invalid JSON in disk cache (silently ignored).
- Read-only disk (OSError caught).
- Both GitHub and npm return invalid version.
- Concurrent calls during network failure (lock prevents thundering herd).
- Stale in-memory cache (reset
cached_aton use so next call retries after TTL). - Test isolation (disk caching is opt-in via constructor parameter).
-
Ran existing tests: ✅ All 1889 unit tests and 649 integration tests pass. Specifically:
- All 11 tests in
tests/unit/test_codex_version.pypass without modification. - Related tests in
test_model_fetcher.py,test_model_refresh_scheduler.py,test_model_registry.py,test_model_registry_lock.py,test_load_balancer.pyall pass.
- All 11 tests in
-
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 →
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 →