xonecas.io
64875
Mc

mini-coder / commit 69341e7

fix: remove date suffix stripping, bump model cache version

The Anthropic /v1/models API returns correct model IDs for OAuth
(e.g. claude-opus-4-6, claude-sonnet-4-6). The earlier 404s were
caused by stale cached data from a previous fetch attempt. Bump
the model info cache version to force a re-sync on next start.

xonecas2026-03-16 69341e795f5cc56c148734ecad2490c2b3b16097 parent 80fbdaf

3 files changed

src/llm-api/model-info-fetch.ts+1−18
@@ -155,24 +155,11 @@ async function getAnthropicApiKey(): Promise<string | null> {
155155 return null;
156156 }
157157
158-/**
159- * Strip the trailing date suffix from an Anthropic model ID to produce the
160- * short alias that the OAuth / Claude Code inference endpoint expects.
161- * e.g. "claude-sonnet-4-6-20250725" → "claude-sonnet-4-6"
162- * "claude-opus-4-0-20250514" → "claude-opus-4-0"
163- * Returns null if the ID has no date suffix.
164- */
165-function stripAnthropicDateSuffix(modelId: string): string | null {
166- const match = modelId.match(/^(.+)-(\d{8})$/);
167- return match?.[1] ?? null;
168-}
169-
170158 async function fetchAnthropicModels(): Promise<
171159 ProviderModelCandidate[] | null
172160 > {
173161 const key = await getAnthropicApiKey();
174162 if (!key) return null;
175- const usingOAuth = !process.env.ANTHROPIC_API_KEY;
176163
177164 const payload = await fetchJson(
178165 `${ANTHROPIC_BASE}/v1/models`,
@@ -190,12 +177,8 @@ async function fetchAnthropicModels(): Promise<
190177 item.display_name.trim().length > 0
191178 ? item.display_name
192179 : modelId;
193- // OAuth inference requires short aliases (no date suffix).
194- const effectiveId = usingOAuth
195- ? (stripAnthropicDateSuffix(modelId) ?? modelId)
196- : modelId;
197180 return {
198- providerModelId: effectiveId,
181+ providerModelId: modelId,
199182 displayName,
200183 contextWindow: null,
201184 free: false,
src/llm-api/model-info.ts+1−1
@@ -33,7 +33,7 @@ import {
3333 const MODELS_DEV_SYNC_KEY = "last_models_dev_sync_at";
3434 const PROVIDER_SYNC_KEY_PREFIX = "last_provider_sync_at:";
3535 const CACHE_VERSION_KEY = "model_info_cache_version";
36-const CACHE_VERSION = 2;
36+const CACHE_VERSION = 3;
3737 export const MODEL_INFO_TTL_MS = 7 * 24 * 60 * 60 * 1000;
3838
3939 export {
src/llm-api/providers.ts+1−10
@@ -178,15 +178,6 @@ type AsyncModelResolver = (
178178 let oauthAnthropicCache: { token: string; provider: AnthropicProvider } | null =
179179 null;
180180
181-/**
182- * Strip the trailing -YYYYMMDD date suffix from Anthropic model IDs.
183- * OAuth inference accepts short aliases (e.g. "claude-sonnet-4-6")
184- * but the /v1/models listing returns dated IDs (e.g. "claude-sonnet-4-6-20250725").
185- */
186-function stripDateSuffix(modelId: string): string {
187- return modelId.replace(/-\d{8}$/, "");
188-}
189-
190181 async function resolveAnthropicModel(modelId: string): Promise<LanguageModel> {
191182 // OAuth token takes priority over env var
192183 if (isLoggedIn("anthropic")) {
@@ -204,7 +195,7 @@ async function resolveAnthropicModel(modelId: string): Promise<LanguageModel> {
204195 }),
205196 };
206197 }
207- return oauthAnthropicCache.provider(stripDateSuffix(modelId));
198+ return oauthAnthropicCache.provider(modelId);
208199 }
209200 }
210201 // Fallback to ANTHROPIC_API_KEY env var