icebear0828 Claude Opus 4.6 commited on
Commit
eea9e24
·
1 Parent(s): cf0807a

fix: filter non-Codex models from backend to prevent resolveModelId fallback breakage

Browse files

Backend model fetch returns ChatGPT-only slugs (gpt-5-2, gpt-5-1, etc.)
that the Codex Responses API doesn't accept. Now only models already in
the static YAML catalog are merged from the backend.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. src/models/model-store.ts +13 -2
src/models/model-store.ts CHANGED
@@ -124,11 +124,21 @@ function normalizeBackendModel(raw: BackendModelEntry): NormalizedModelWithMeta
124
  * - Aliases are never touched (always from YAML)
125
  */
126
  export function applyBackendModels(backendModels: BackendModelEntry[]): void {
 
 
 
 
 
 
 
 
 
 
127
  const staticMap = new Map(_catalog.map((m) => [m.id, m]));
128
  const merged: CodexModelInfo[] = [];
129
  const seenIds = new Set<string>();
130
 
131
- for (const raw of backendModels) {
132
  const normalized = normalizeBackendModel(raw);
133
  seenIds.add(normalized.id);
134
 
@@ -162,8 +172,9 @@ export function applyBackendModels(backendModels: BackendModelEntry[]): void {
162
 
163
  _catalog = merged;
164
  _lastFetchTime = new Date().toISOString();
 
165
  console.log(
166
- `[ModelStore] Merged ${backendModels.length} backend + ${merged.length - backendModels.length} static-only = ${merged.length} total models`,
167
  );
168
  }
169
 
 
124
  * - Aliases are never touched (always from YAML)
125
  */
126
  export function applyBackendModels(backendModels: BackendModelEntry[]): void {
127
+ // Only keep models whose ID already exists in the static catalog.
128
+ // Backend data is used to supplement/update existing models, not to introduce new IDs.
129
+ // This prevents ChatGPT-only slugs (gpt-5-2, gpt-5-1, research, etc.) from
130
+ // entering the catalog and breaking resolveModelId() fallback logic.
131
+ const staticIds = new Set(_catalog.map((m) => m.id));
132
+ const filtered = backendModels.filter((raw) => {
133
+ const id = raw.slug ?? raw.id ?? raw.name ?? "";
134
+ return staticIds.has(id);
135
+ });
136
+
137
  const staticMap = new Map(_catalog.map((m) => [m.id, m]));
138
  const merged: CodexModelInfo[] = [];
139
  const seenIds = new Set<string>();
140
 
141
+ for (const raw of filtered) {
142
  const normalized = normalizeBackendModel(raw);
143
  seenIds.add(normalized.id);
144
 
 
172
 
173
  _catalog = merged;
174
  _lastFetchTime = new Date().toISOString();
175
+ const skipped = backendModels.length - filtered.length;
176
  console.log(
177
+ `[ModelStore] Merged ${filtered.length} backend (${skipped} non-codex skipped) + ${merged.length - filtered.length} static-only = ${merged.length} total models`,
178
  );
179
  }
180