Skip to content

Commit 124a2b1

Browse files
authored
fix(codex): keep native eligibility metadata off routed catalog rows (#2862)
deriveEntry deep-clones a native template and deletes a fixed denylist, so supported_in_api, available_in_plans, minimal_client_version, availability_nux and upgrade survive onto routed rows. A model backed by unrelated provider credentials ends up advertising ChatGPT plan eligibility it does not have. findNativeTemplate also accepted ANY bare row carrying base_instructions, so a row the client injects that opencodex has never seen could become the template every routed model inherits from. #2813 reports exactly such a row: a reserve fallback that appears when the native five-hour quota runs out. Adds findSupportedNativeTemplate, restricted to the known native roster, and switches the three template-SELECTION sites to it. The four catalog VALIDITY gates deliberately keep the permissive function: narrowing them would make a catalog holding only a newly launched native model look invalid and get replaced by stale fallback data, trading a latent bug for an active one. A regression test fails if anyone narrows them later. The sanitation lives in ensureStrictCatalogFields rather than normalizeRoutedCatalogEntry because the latter only runs on freshly derived rows. Degraded-provider and foreign routed rows are preserved from disk and reach the merge through ensureStrictCatalogFields alone, so sanitizing there would leave rows already on disk contaminated. Both paths now converge on one guarantee, and native rows keep their own eligibility metadata. None of this can re-enable a picker row the client greyed out; that gate is applied before a request reaches the proxy. Documents the limitation, and the explicit provider/model selection path, in English and all seven locales, saying plainly that proxy-side routing is proven while app behaviour under reserve mode is not. Verification: tests/codex-catalog.test.ts 214 pass; codex-runtime, codex-retained-root-serialization, codex-tool-mode, cursor-static-catalog and provider-registry-parity 94 pass; typecheck clean; privacy:scan passed. Five mutations driven red, each sanitizer independently, plus the narrow-validity mutation that proves the rejected design would break catalog loading. Refs #2813
1 parent 7b13e38 commit 124a2b1

13 files changed

Lines changed: 339 additions & 10 deletions

File tree

‎docs-site/src/content/docs/fr/guides/codex-app-models.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,26 @@ Tant que Desktop ne permet pas de contrôler cette liste d'autorisation :
244244
- Utilisez Codex CLI ou TUI plutôt que le sélecteur de Desktop ; ces interfaces n'appliquent pas la liste d'autorisation et répertorient normalement les modèles routés.
245245

246246
## Actualisation de l'état des modèles
247+
## Limitation du repli sur quota natif
248+
249+
Lorsque l'application Codex épuise son quota natif de cinq heures, elle peut basculer vers un modèle de repli de réserve et griser les autres lignes de son sélecteur. Signalé dans [#2813](https://github.com/lidge-jun/opencodex/issues/2813), ce filtrage masque aussi les lignes routées par opencodex, alors que celles-ci utilisent des identifiants de fournisseur sans rapport et ne consomment aucun quota ChatGPT.
250+
251+
Ce filtrage est appliqué par le client avant que la requête n'atteigne le proxy, donc opencodex ne peut pas le lever. Les lignes routées sont écrites avec `visibility: "list"`, le filtrage du catalogue ne consulte que `disabledModels` et le `selectedModels` de chaque fournisseur, et aucune valeur de quota n'intervient dans la visibilité routée.
252+
253+
Sélectionner un modèle routé explicitement ne passe pas par le sélecteur. Définissez le modèle dans `config.toml` :
254+
255+
```toml
256+
model = "anthropic/claude-sonnet-5"
257+
```
258+
259+
ou envoyez-le directement :
260+
261+
```bash
262+
ocx access test anthropic/claude-sonnet-5 --protocol responses
263+
```
264+
265+
Les deux chemins routent correctement **dès que la requête atteint le proxy** — c'est couvert par des tests. Ce qui n'est pas établi, c'est si l'application envoie encore le modèle configuré pendant le mode réserve ; si le client le réécrit ou le refuse avant l'envoi, aucun réglage côté proxy n'y change quoi que ce soit. Considérez la sélection explicite comme une piste à essayer plutôt qu'un contournement confirmé.
266+
247267

248268
Si le sélecteur affiche encore des entrées obsolètes, actualisez le catalogue et redémarrez l'interface Codex concernée :
249269

‎docs-site/src/content/docs/guides/codex-app-models.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,38 @@ them by ignoring `visibility`. See [Codex Desktop native-allowlist compatibility
105105
for the command, disable-key semantics, and safety constraints.
106106

107107
## Integration path
108+
## Native quota fallback limitation
109+
110+
When the Codex app exhausts its native five-hour quota it can switch to a reserve
111+
fallback model and grey out the other rows in its picker. Reported in
112+
[#2813](https://github.com/lidge-jun/opencodex/issues/2813), that gating also hides routed
113+
opencodex rows, even though those use unrelated provider credentials and consume none of the
114+
ChatGPT quota.
115+
116+
This gate is applied by the client before a request reaches the proxy, so opencodex cannot lift
117+
it. Routed rows are written with `visibility: "list"`, catalog filtering consults only
118+
`disabledModels` and each provider's `selectedModels`, and no quota value takes part in routed
119+
visibility.
120+
121+
Selecting a routed model explicitly does not go through the picker. Set the model in
122+
`config.toml`:
123+
124+
```toml
125+
model = "anthropic/claude-sonnet-5"
126+
```
127+
128+
or send it directly:
129+
130+
```bash
131+
ocx access test anthropic/claude-sonnet-5 --protocol responses
132+
```
133+
134+
Both paths route correctly **once the request reaches the proxy** — that part is covered by
135+
tests. What is not established is whether the app still sends the configured model while reserve
136+
mode is active; if the client rewrites or refuses it before the request leaves, no proxy-side
137+
setting changes that. Treat the explicit-selection route as worth trying rather than a confirmed
138+
workaround.
139+
108140

109141
`ocx init`, `ocx start`, and `ocx sync` wire the shared Codex config and catalog into the proxy; see
110142
[Codex Integration](/guides/codex-integration/) for config injection, catalog sync, shims, WebSocket

‎docs-site/src/content/docs/ja/guides/codex-app-models.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,26 @@ Desktop が許可リストの制御を提供するまでは:
118118
- Desktop ピッカーの代わりに Codex CLI または TUI を使用します。これらは許可リストを適用せず、ルーティングモデルを通常どおり一覧表示します。
119119

120120
## モデルの状態を更新しています
121+
## ネイティブクォータのフォールバック制限
122+
123+
Codex アプリがネイティブの 5 時間クォータを使い切ると、リザーブのフォールバックモデルに切り替わり、ピッカーの他の行がグレーアウトすることがあります。[#2813](https://github.com/lidge-jun/opencodex/issues/2813) で報告されたこの制御は、opencodex がルーティングした行も隠します。これらは無関係なプロバイダー資格情報を使い、ChatGPT のクォータを一切消費しません。
124+
125+
この制御はリクエストがプロキシに届く前にクライアント側で適用されるため、opencodex では解除できません。ルーティング行は `visibility: "list"` で書き込まれ、カタログのフィルタリングは `disabledModels` と各プロバイダーの `selectedModels` だけを参照し、クォータ値はルーティング行の可視性に一切関与しません。
126+
127+
ルーティングモデルを明示的に選ぶ経路はピッカーを通りません。`config.toml` でモデルを指定します。
128+
129+
```toml
130+
model = "anthropic/claude-sonnet-5"
131+
```
132+
133+
または直接送信します。
134+
135+
```bash
136+
ocx access test anthropic/claude-sonnet-5 --protocol responses
137+
```
138+
139+
どちらの経路も **リクエストがプロキシに届いた後は** 正しくルーティングされ、これはテストで確認済みです。確認できていないのは、リザーブモード中にアプリが設定したモデルを実際に送るかどうかです。クライアントが送信前に書き換えたり拒否したりする場合、プロキシ側の設定では変えられません。明示的な指定は確定した回避策ではなく、試す価値のある手段として扱ってください。
140+
121141

122142
ピッカーに古いエントリがまだ表示されている場合は、カタログを更新し、ターゲットの Codex サーフェスを再起動します。
123143

‎docs-site/src/content/docs/ko/guides/codex-app-models.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,26 @@ Desktop이 허용 목록을 제어할 수 있게 될 때까지:
204204
라우팅 모델을 정상적으로 나열합니다.
205205

206206
## 모델 상태 새로고침
207+
## 네이티브 쿼터 폴백 제한
208+
209+
Codex 앱이 네이티브 5시간 쿼터를 다 쓰면 리저브 폴백 모델로 넘어가면서 피커의 다른 줄을 회색으로 만들 수 있습니다. [#2813](https://github.com/lidge-jun/opencodex/issues/2813)에 보고된 이 차단은 opencodex가 넣은 라우팅 줄까지 가립니다. 그 줄들은 관계없는 프로바이더 자격 증명을 쓰고 ChatGPT 쿼터를 전혀 쓰지 않습니다.
210+
211+
이 차단은 요청이 프록시에 닿기 전에 클라이언트가 적용하므로 opencodex가 풀 수 없습니다. 라우팅 줄은 `visibility: "list"`로 기록되고, 카탈로그 필터링은 `disabledModels`와 프로바이더별 `selectedModels`만 봅니다. 쿼터 값은 라우팅 줄의 노출에 관여하지 않습니다.
212+
213+
라우팅 모델을 직접 지정하는 경로는 피커를 거치지 않습니다. `config.toml`에 모델을 적습니다.
214+
215+
```toml
216+
model = "anthropic/claude-sonnet-5"
217+
```
218+
219+
또는 바로 보냅니다.
220+
221+
```bash
222+
ocx access test anthropic/claude-sonnet-5 --protocol responses
223+
```
224+
225+
두 경로 모두 **요청이 프록시에 도달한 뒤에는** 정상 라우팅되고, 이건 테스트로 덮여 있습니다. 확인되지 않은 부분은 리저브 모드에서 앱이 설정한 모델을 실제로 보내는지입니다. 클라이언트가 보내기 전에 바꾸거나 거부하면 프록시 설정으로는 바꿀 수 없습니다. 명시적 지정은 확정된 우회책이 아니라 시도해 볼 방법으로 보세요.
226+
207227

208228
picker에 오래된 항목이 계속 보이면 카탈로그를 새로 쓰고 대상 Codex 서피스를 다시 시작합니다:
209229

‎docs-site/src/content/docs/ru/guides/codex-app-models.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,26 @@ Codex сортирует видимые в picker'е записи каталог
187187
показывают маршрутизированные модели как обычно.
188188

189189
## Обновление состояния моделей
190+
## Ограничение при откате по нативной квоте
191+
192+
Когда приложение Codex исчерпывает нативную пятичасовую квоту, оно может переключиться на резервную модель и сделать остальные строки в своём списке недоступными. Судя по [#2813](https://github.com/lidge-jun/opencodex/issues/2813), это ограничение скрывает и маршрутизируемые строки opencodex, хотя они используют не связанные с ChatGPT учётные данные провайдеров и не расходуют его квоту.
193+
194+
Ограничение применяет клиент до того, как запрос доходит до прокси, поэтому opencodex не может его снять. Маршрутизируемые строки записываются с `visibility: "list"`, фильтрация каталога смотрит только на `disabledModels` и `selectedModels` каждого провайдера, и никакое значение квоты не участвует в видимости маршрутизируемых строк.
195+
196+
Явный выбор маршрутизируемой модели не проходит через список. Укажите модель в `config.toml`:
197+
198+
```toml
199+
model = "anthropic/claude-sonnet-5"
200+
```
201+
202+
или отправьте её напрямую:
203+
204+
```bash
205+
ocx access test anthropic/claude-sonnet-5 --protocol responses
206+
```
207+
208+
Оба пути маршрутизируются корректно **после того, как запрос дошёл до прокси**, и это покрыто тестами. Не установлено другое: отправляет ли приложение настроенную модель в резервном режиме. Если клиент переписывает или отклоняет её до отправки, никакая настройка на стороне прокси этого не изменит. Считайте явный выбор способом, который стоит попробовать, а не подтверждённым обходным путём.
209+
190210

191211
Если picker всё ещё показывает устаревшие записи, обновите каталог и перезапустите нужную
192212
поверхность Codex:

‎docs-site/src/content/docs/tr/guides/codex-app-models.md‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,26 @@ Desktop izin listesi için bir denetim sunana kadar:
283283
uygulamaz ve yönlendirilen modelleri normal şekilde listeler.
284284

285285
## Model durumunu yenileme
286+
## Yerel kota geri dönüş kısıtı
287+
288+
Codex uygulaması yerel beş saatlik kotasını tükettiğinde bir rezerv yedek modeline geçip seçicideki diğer satırları soluklaştırabilir. [#2813](https://github.com/lidge-jun/opencodex/issues/2813) numaralı raporda görüldüğü gibi bu kısıtlama, ilgisiz sağlayıcı kimlik bilgileri kullanan ve ChatGPT kotasından hiç tüketmeyen opencodex yönlendirmeli satırları da gizliyor.
289+
290+
Bu kısıt istek proxy'ye ulaşmadan önce istemci tarafında uygulanır, dolayısıyla opencodex onu kaldıramaz. Yönlendirilen satırlar `visibility: "list"` ile yazılır, katalog filtrelemesi yalnızca `disabledModels` ve her sağlayıcının `selectedModels` değerine bakar ve hiçbir kota değeri yönlendirilen görünürlüğe katılmaz.
291+
292+
Yönlendirilen bir modeli açıkça seçmek seçiciden geçmez. Modeli `config.toml` içinde ayarlayın:
293+
294+
```toml
295+
model = "anthropic/claude-sonnet-5"
296+
```
297+
298+
ya da doğrudan gönderin:
299+
300+
```bash
301+
ocx access test anthropic/claude-sonnet-5 --protocol responses
302+
```
303+
304+
Her iki yol da **istek proxy'ye ulaştıktan sonra** doğru yönlendirilir; bu testlerle kapsanıyor. Kanıtlanmayan nokta, rezerv modu etkinken uygulamanın yapılandırılan modeli hâlâ gönderip göndermediğidir; istemci onu göndermeden önce değiştirir ya da reddederse proxy tarafındaki hiçbir ayar bunu değiştirmez. Açık seçimi doğrulanmış bir geçici çözüm değil, denemeye değer bir yol olarak görün.
305+
286306

287307
Seçici hala eski girdileri gösteriyorsa kataloğu yenileyin ve hedef Codex
288308
yüzeyini yeniden başlatın:
@@ -295,4 +315,3 @@ opencodex, katalog görünürlüğü, önceliği veya meta verileri her değişt
295315
`models_cache.json` dosyasını kasıtlı olarak eski bir önbellek sarmalayıcısıyla
296316
yeniden yazar, böylece bir sonraki Codex model yenilemesi yeni kataloğu okur.
297317

298-

‎docs-site/src/content/docs/zh-cn/guides/codex-app-models.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,26 @@ Codex Desktop 的远程服务器模式会针对客户端自己的 `available_mod
131131
- 改用 Codex CLI 或 TUI,而不是 Desktop 选择器;它们不应用该白名单,会正常列出路由模型。
132132

133133
## 刷新模型状态
134+
## 原生配额回退限制
135+
136+
Codex 应用用完原生的五小时配额后,可能切换到预备回退模型,并把选择器里其他行置灰。正如 [#2813](https://github.com/lidge-jun/opencodex/issues/2813) 所报告的,这个限制同样会隐藏 opencodex 路由的行,而那些行使用的是无关的提供方凭据,不消耗任何 ChatGPT 配额。
137+
138+
这个限制由客户端在请求到达代理之前施加,因此 opencodex 无法解除。路由行写入时带 `visibility: "list"`,目录过滤只读取 `disabledModels` 和各提供方的 `selectedModels`,任何配额值都不参与路由行的可见性。
139+
140+
显式选择路由模型不经过选择器。在 `config.toml` 中设置模型:
141+
142+
```toml
143+
model = "anthropic/claude-sonnet-5"
144+
```
145+
146+
或者直接发送:
147+
148+
```bash
149+
ocx access test anthropic/claude-sonnet-5 --protocol responses
150+
```
151+
152+
**请求到达代理之后**,两条路径都能正确路由,这一点有测试覆盖。尚未确认的是:预备模式生效时,应用是否仍会发送已配置的模型。如果客户端在发出之前重写或拒绝它,代理端的任何设置都改变不了。请把显式选择当作值得一试的做法,而不是已确认的规避方案。
153+
134154

135155
如果选择器里仍然显示旧条目,请刷新目录并重启目标 Codex 界面:
136156

‎docs-site/src/content/docs/zh-tw/guides/codex-app-models.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,26 @@ allowlist 上的項目。opencodex 無法介入該清單;上游錯誤追蹤於
178178
- 改用 Codex CLI 或 TUI 而不是 Desktop 選擇器;它們不會套用 allowlist,會正常列出路由模型。
179179

180180
## 重新整理模型狀態
181+
## 原生配額回退限制
182+
183+
Codex 應用程式用完原生的五小時配額後,可能切換到預備回退模型,並把選擇器裡其他列變灰。如 [#2813](https://github.com/lidge-jun/opencodex/issues/2813) 所報告,這個限制同樣會隱藏 opencodex 路由的列,而那些列使用的是無關的供應商憑證,不消耗任何 ChatGPT 配額。
184+
185+
這個限制由用戶端在請求抵達代理之前施加,因此 opencodex 無法解除。路由列寫入時帶 `visibility: "list"`,目錄過濾只讀取 `disabledModels` 與各供應商的 `selectedModels`,任何配額值都不參與路由列的可見性。
186+
187+
明確選擇路由模型不會經過選擇器。在 `config.toml` 中設定模型:
188+
189+
```toml
190+
model = "anthropic/claude-sonnet-5"
191+
```
192+
193+
或直接送出:
194+
195+
```bash
196+
ocx access test anthropic/claude-sonnet-5 --protocol responses
197+
```
198+
199+
**請求抵達代理之後**,兩條路徑都能正確路由,這點有測試覆蓋。尚未確認的是:預備模式生效時,應用程式是否仍會送出已設定的模型。如果用戶端在送出前改寫或拒絕它,代理端的任何設定都改變不了。請把明確選擇當成值得一試的做法,而非已確認的規避方案。
200+
181201

182202
如果選擇器仍顯示舊條目,請重新整理目錄並重新開啟目標 Codex 介面:
183203

‎src/codex/catalog/bundled.ts‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { redactSecretString } from "../../lib/redact";
3131
import upstreamModelsSnapshot from "../data/upstream-models.json";
3232

3333

34-
import { activeCodexModelsCachePath, catalogBackupPathFor, findNativeTemplate, isDefaultCatalogPath, legacyCatalogBackupPath, parseCatalogJson, readCatalog, readCatalogBackup, readCodexCatalogPath } from "./parsing";
34+
import { activeCodexModelsCachePath, catalogBackupPathFor, findNativeTemplate, findSupportedNativeTemplate, isDefaultCatalogPath, legacyCatalogBackupPath, parseCatalogJson, readCatalog, readCatalogBackup, readCodexCatalogPath } from "./parsing";
3535
import type { RawCatalog, RawEntry } from "./parsing";
3636
import { codexExecInvocation, isSpawnableCodexCandidate } from "../exec-invocation";
3737
import {
@@ -541,9 +541,11 @@ export function readCurrentCodexModelsCache(): RawCatalog | null {
541541
export function loadCatalogTemplate(): RawEntry | null {
542542
const catalogPath = readCodexCatalogPath();
543543
const bundled = loadBundledCodexCatalog();
544-
const native = findNativeTemplate(readCatalog(catalogPath))
545-
?? findNativeTemplate(readCatalogBackup(catalogPath))
546-
?? findNativeTemplate(readCatalog(activeCodexModelsCachePath()))
547-
?? findNativeTemplate(bundled ? JSON.parse(JSON.stringify(bundled)) as RawCatalog : null);
544+
// Template inheritance only. The validity gates in this file keep `findNativeTemplate`
545+
// so a catalog carrying only a newly launched native row stays valid (#2813).
546+
const native = findSupportedNativeTemplate(readCatalog(catalogPath))
547+
?? findSupportedNativeTemplate(readCatalogBackup(catalogPath))
548+
?? findSupportedNativeTemplate(readCatalog(activeCodexModelsCachePath()))
549+
?? findSupportedNativeTemplate(bundled ? JSON.parse(JSON.stringify(bundled)) as RawCatalog : null);
548550
return native ? JSON.parse(JSON.stringify(native)) : null;
549551
}

0 commit comments

Comments
 (0)