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 the relevant files mentioned in the issue. Let's begin.
- Assistant
Let me explore the repository structure more broadly.
- Assistant
Let me explore the app directory structure.
- Assistant
Let me examine the key files mentioned in the issue. I'll start with multiple files at once.
- Assistant
Now let's look at the model_fetcher.py and model_refresh_scheduler.py to understand how the version is used.
- Assistant
Let me look at the model refresh scheduler and the load balancer to understand the full flow.
- Assistant
Let me look at the load_balancer.py to see how
_filter_accounts_for_modelworks, and also check the settings to understand the default value. - Assistant
Let me look at the load_balancer.py file to find the
_filter_accounts_for_modelfunction. - Assistant
Let me look at the
_filter_accounts_for_modelfunction and its context. - Assistant
Let me look at the load_balancer to see how the filter_accounts_for_model is called and where the no_plan_support_for_model error is raised.
- Assistant
Now let me look at the settings file to see the default value for model_registry_client_version.
- Assistant
Now let me look at the model_registry.py to understand how
plan_types_for_modelworks. - Assistant
Now I understand the full picture. Let me look at existing tests to understand how the codebase is structured and what patterns to follow.
- Assistant
Let me check the existing tests for codex_version.py to understand how they're structured and what patterns to follow.
- Assistant
Let me also check the proxy service to understand how requests come in and whether
client_versionis available in the request query string. - Assistant
Let me check how requests come into the proxy and whether there's a way to get the client's version from requests.
- Assistant
Let me look at the proxy API to see if
client_versionis passed in the request query string. - Assistant
Let me search for how the proxy handles the
/backend-api/codex/modelsendpoint and if there's anyclient_versionquery parameter. - Assistant
Let me look at how the codex models endpoint is set up:
- Assistant
Let me look at the
_build_codex_models_responsefunction to understand how models are returned. - Assistant
Let me look at the load balancer code around line 1168 where
_filter_accounts_for_modelis defined to understand the error flow better: - Assistant
Now I understand the full issue. Let me also check the proxy_api to see if there's a way to get client_version from requests:
- Assistant
Let me check how the proxy handles the responses endpoint:
- Assistant
Let me check the Dockerfile and data directory structure:
- Assistant
Let me look at how the data directory is used:
- Assistant
Let me look at the existing tests to understand what patterns are used for testing:
- Assistant
Now I have a good understanding of the codebase. Let me run the existing tests to see if they pass:
- Assistant
Let me install the dependencies:
- Assistant
Let me try to install all the project dependencies properly using uv since it's a uv-managed project.
- Assistant
Now let me run the existing tests to see if they pass:
- Assistant
The venv might not be activated. Let me check if there's a .venv directory.
- Assistant
Now I have a good understanding of the problem. Let me plan and implement the fix.
The core issue: When GitHub API returns 403,
CodexVersionCachefalls back tosettings.model_registry_client_version(default0.101.0). This causes the model fetcher to request models withclient_version=0.101.0, which excludes newer models likegpt-5.5from the response.My approach will be multi-pronged:
- Add npm registry as a secondary version source - not rate-limited like GitHub API
- Cache the fetched version on disk - survives container restarts and transient failures
- Let the client's
client_versionhint bootstrap the registry - if a newer client sends a higher version, use it as a hint
Let me start implementing:
- Assistant
Now let me implement the changes. I'll modify
codex_version.pyto:- Add npm registry as a secondary version source
- Cache the fetched version on disk
- Allow the client to hint a higher version
- Assistant
Let me write the file directly:
- Assistant
Now let me implement the client version hint in the proxy. I need to find where requests come in and can pass the hint:
- Assistant
Let me look at how the responses endpoint is called and how we can capture the client_version from the request query string.
- Assistant
Let me check if
client_versionis passed as a query parameter in the request: - Assistant
Let me check the
_stream_responsesfunction to see how the request is processed: - Assistant
Let me check the proxy service to see how it processes requests:
- Assistant
Let me check how the proxy service handles requests and where I can add the version hint:
- Assistant
Let me check the proxy service to understand how it processes requests:
- Assistant
Now I need to implement the
hint_newer_versionin the proxy service. Let me find where the proxy forwards requests to understand where the client_version could be extracted: - Assistant
Let me look at the
_stream_responsesfunction more carefully and see how the request flows: - Assistant
Let me look at the startup flow to understand how to hook in the version hint:
- Assistant
Let me look at the main app to see how startup works and where the model refresh scheduler is started:
- Assistant
Now I need to understand how the proxy handles client requests. Let me look at how requests flow to the service:
- Assistant
Let me now look at the proxy responses endpoint more closely to see how to intercept the client_version from requests:
- Assistant
Let me now look at the proxy service's
stream_http_responsesfunction to understand where the client's version could be extracted: - Assistant
Now I understand the full architecture. Let me now look at how the proxy handles requests to understand where to add the client version hint. Let me check if there's any
x-client-versionor similar header from the Codex CLI: - Assistant
Let me check how the proxy processes the query parameters from incoming requests:
- Assistant
Let me look at how the proxy service forwards requests to the upstream:
- Assistant
There's an
x-openai-client-versionheader being used! Let me look at it: - Assistant
The Codex CLI sends an
x-openai-client-versionheader! Let me look at how it's used: - Assistant
Let me look at the proxy service where
x-openai-client-versionis used: - Assistant
Now I understand the full picture. The
x-openai-client-versionheader is sent by the Codex CLI with each request. I can use this to hint the version cache. Let me now implement the client version hint in the proxy API: - Assistant
Let me look at the imports in the proxy API to see what's already imported:
- Assistant
Now let me add the client version hint to the proxy API. I'll add it to the
responsesendpoint where we can extract thex-openai-client-versionheader: - Assistant
Let me verify the patches were applied correctly:
- Assistant
Let me check that the helper function was added correctly:
- Assistant
Good. Now let me verify the codex_version.py changes look correct:
- Assistant
Now let me run the existing tests to see if they still pass:
- Assistant
I see the issue - the disk cache file leaks between tests since they share the same filesystem. I need to make disk caching opt-in so existing tests aren't affected. Let me fix this:
- Assistant
Let me update the codex_version.py to make disk caching opt-in via a constructor parameter:
- Assistant
Now let me run the tests again to see if the disk cache isolation issue is fixed:
- Assistant
All 11 existing tests pass. Now let me run the other unit tests to make sure nothing is broken:
- Assistant
All 1889 unit tests passed. Let me also verify the model_fetcher and model_registry tests pass:
- Assistant
All tests pass. Now let me write a quick script to verify the new behavior works correctly:
- Assistant
All verification tests pass. Let me clean up and run the full test suite one more time:
- Assistant
All 26 tests pass. Let me review the final state of all changes I've made:
- Assistant
Let me see the full diff:
- Assistant
The diff looks clean. Let me run the full unit test suite one more time to make sure everything is still passing:
- Assistant
All 1889 tests pass. Let me clean up any disk cache files that might have been created during verification:
- Assistant
Now let me verify the final state of all modified files:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.