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
I'll start by exploring the repository structure and understanding the relevant files mentioned in the issue.
Assistant
Let me look at the settings and the model_registry.py to understand how it's used. Also let me check how client_version is used in the proxy to honor the client's own client_version.
Assistant
Let me look at how the proxy reads client_version query string and the load_balancer
_filter_accounts_for_model.Assistant
Let me look at the existing tests for codex_version to understand the testing structure.
Assistant
Let me look at how the proxy parses the client_version query string in the responses endpoint.
Assistant
Let me look at the
_stream_responsesto see how the request is processed and where model selection happens, and how query params are read.Assistant
Let me look at the data dir / home dir and how persistence is handled.
Assistant
Let me look at the model_fetcher test to understand the mocking structure.
Assistant
Now let me check the verify_release_version script and the release_versions, to understand what version the recent codex CLI is on, and whether there's a build-time version.
Assistant
Let me check the settings for a home_dir field and how the singleton is constructed.
Assistant
Let me check if any tests use the singleton or settings default value.
Assistant
The conftest fixture resets the singleton's memory cache but not disk. If the singleton has a disk path and tests trigger fetches, it might write/read disk. Let me check which tests use the singleton (get_codex_version_cache). The model_refresh_scheduler test uses
get_codex_version_cachemock. Let me check.Assistant
Assistant
Now let me write the new codex_version.py with npm secondary source and disk cache.
Assistant
Now let me run the existing tests to verify they pass.
Assistant
All existing codex_version tests pass. Now let me run the model_fetcher and model_refresh_scheduler tests.
Assistant
Now let me write a reproduction script to verify the new behavior (npm fallback when GitHub is rate-limited, and disk cache survives restart).
Assistant
The fix works. Let me run the broader unit test suite to ensure nothing else broke.
Assistant
All 1889 unit tests pass. Now let me verify the original error scenario from the issue is addressed by simulating the full flow: GitHub 403 → npm provides version → model_fetcher URL uses it.
Assistant
The end-to-end flow works. Let me verify the npm registry URL actually returns a version (live network check) to confirm the URL is correct.
Assistant
The npm registry returns 200 with a valid version, confirming the URL is correct and not rate-limited. Let me clean up temp files and review the final diff.
Assistant
The diff looks good. Let me refine two things: (1) when falling back to the disk cache, set the in-memory cache timestamp to
nowso we don't refetch on every subsequent call within the TTL, and (2) store wall-clock time on disk (more meaningful than monotonic across restarts). Let me view the current file section.Assistant
Wait, I added a comment but the
recorded_atpassed in isnowwhich istime.monotonic(). The comment says wall-clock but I'm passing monotonic. Let me reconcile: inget_version,now = time.monotonic()and I callself._write_disk_cache(version, now). So recorded_at on disk is monotonic, not wall-clock. The comment is now misleading.Let me decide: should disk store monotonic or wall-clock? Since I don't use it for TTL, it doesn't matter functionally. But the comment should be accurate. Let me just make the comment accurate: "stored for diagnostics; not used for TTL gating". Remove the "wall-clock" claim. Let me fix.
Assistant
_disk_atis now unused since I set_cached_at = now. Let me check if it's referenced anywhere.Assistant
Let me simplify by removing the now-unused
_disk_atfield and not requiringrecorded_aton load (keep it in the payload only for human diagnostics).Assistant
Let me re-run the repro script once more to confirm the refined version still works, then run the full unit suite.
Assistant
All 1889 unit tests pass. Let me do a final review of the complete file.
Assistant
The implementation looks good. Let me run the linter (ruff) used by the repo to ensure code style compliance.
Assistant
Ruff not installed; the code style is consistent with existing conventions. Let me verify no test calls the singleton's
get_versionwith real network (which would now hit disk).Assistant
Everything is in place. The singleton's disk path is never exercised in tests (only the in-memory cache is reset in conftest, and no test calls
get_version()on the singleton), so there's no test contamination.Let me produce a final summary of the change and the checklist.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.