xonecas.io
64875
Mc

mini-coder / commit 80fbdaf

fix: strip date suffix from model ID at inference time for OAuth

The date stripping in model-info-fetch only affected the cached model
list. The actual model ID sent to the API still had the date suffix.
Now stripDateSuffix is applied in resolveAnthropicModel right before
the inference call, so any model ID works regardless of source.

xonecas2026-03-16 80fbdaf451d8780e608121d4d92f43a8647218b0 parent c961c85

1 file changed

src/llm-api/providers.ts+13−4
@@ -178,6 +178,15 @@ 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+
181190 async function resolveAnthropicModel(modelId: string): Promise<LanguageModel> {
182191 // OAuth token takes priority over env var
183192 if (isLoggedIn("anthropic")) {
@@ -195,7 +204,7 @@ async function resolveAnthropicModel(modelId: string): Promise<LanguageModel> {
195204 }),
196205 };
197206 }
198- return oauthAnthropicCache.provider(modelId);
207+ return oauthAnthropicCache.provider(stripDateSuffix(modelId));
199208 }
200209 }
201210 // Fallback to ANTHROPIC_API_KEY env var
@@ -241,10 +250,10 @@ export async function resolveModel(
241250 export function autoDiscoverModel(): string {
242251 if (process.env.OPENCODE_API_KEY) return "zen/claude-sonnet-4-6";
243252 if (process.env.ANTHROPIC_API_KEY || isLoggedIn("anthropic"))
244- return "anthropic/claude-sonnet-4-5-20250929";
245- if (process.env.OPENAI_API_KEY) return "openai/gpt-4o";
253+ return "anthropic/claude-sonnet-4-6";
254+ if (process.env.OPENAI_API_KEY) return "openai/gpt-5.4";
246255 if (process.env.GOOGLE_API_KEY ?? process.env.GEMINI_API_KEY)
247- return "google/gemini-2.0-flash";
256+ return "google/gemini-3.1-pro";
248257 return "ollama/llama3.2";
249258 }