From 0480f6ccd68b76a88f6d9b39b5adfeb01523bf57 Mon Sep 17 00:00:00 2001 From: DhanushSantosh Date: Sat, 17 Jan 2026 21:13:47 +0530 Subject: [PATCH] fix: handle dynamic model IDs with slashes in the model name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit isOpencodeModel was rejecting valid dynamic model IDs like 'openrouter/qwen/qwen3-14b:free' because it was splitting on all slashes and expecting exactly 2 parts. This caused valid OpenCode models to be treated as unknown, falling back to Claude. Now correctly splits on the FIRST slash only, allowing model names like 'qwen/qwen3-14b:free' to be recognized as valid. Fixes: User selects openrouter/qwen/qwen3-14b:free → server falls back to Claude Co-Authored-By: Claude Haiku 4.5 --- libs/types/src/provider-utils.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libs/types/src/provider-utils.ts b/libs/types/src/provider-utils.ts index 3143b336..4e4501fe 100644 --- a/libs/types/src/provider-utils.ts +++ b/libs/types/src/provider-utils.ts @@ -125,11 +125,14 @@ export function isOpencodeModel(model: string | undefined | null): boolean { // - github-copilot/gpt-4o // - google/gemini-2.5-pro // - xai/grok-3 - // Pattern: provider-id/model-name (must have exactly one / and not be a URL) + // - openrouter/qwen/qwen3-14b:free (model names can contain / or :) + // Pattern: provider-id/model-name (at least one /, not a URL) if (model.includes('/') && !model.includes('://')) { - const parts = model.split('/'); - // Valid dynamic model format: provider/model-name (exactly 2 parts) - if (parts.length === 2 && parts[0].length > 0 && parts[1].length > 0) { + const slashIndex = model.indexOf('/'); + const providerId = model.substring(0, slashIndex); + const modelName = model.substring(slashIndex + 1); + // Valid dynamic model format: provider-id/model-name (both parts non-empty) + if (providerId.length > 0 && modelName.length > 0) { return true; } }