From ea3930cf3dd039489d609daed978f929f92e57a6 Mon Sep 17 00:00:00 2001 From: Stefan de Vogelaere Date: Mon, 19 Jan 2026 21:17:05 +0100 Subject: [PATCH] fix: convert OpenCode model format to CLI slash format (#605) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: convert OpenCode model format to CLI slash format The OpenCode CLI expects models in provider/model format (e.g., opencode/big-pickle), but after commit 4b0d1399 changed model IDs from slash format to prefix format, the buildCliArgs() method was not updated to convert back to CLI format. Root cause: - Commit 4b0d1399 changed OpenCode model IDs from opencode/model to opencode-model - The old code used stripProviderPrefix() which just removed the prefix - This resulted in bare model names (e.g., "big-pickle") being passed to CLI - CLI interpreted "big-pickle" as a provider ID, causing ProviderModelNotFoundError Fix: - Updated buildCliArgs() to properly convert model formats for CLI - Bare model names (after prefix strip) now get opencode/ prepended - Models with slashes (dynamic providers) pass through unchanged Model conversion examples: - opencode-big-pickle → (stripped to) big-pickle → opencode/big-pickle - opencode-github-copilot/gpt-4o → (stripped to) github-copilot/gpt-4o → github-copilot/gpt-4o - google/gemini-2.5-pro → google/gemini-2.5-pro (unchanged) * refactor: simplify OpenCode model format conversion logic Address review feedback from Gemini Code Assist to reduce code repetition. The conditional logic for handling models with/without slashes is now unified into a simpler two-step approach: 1. Strip opencode- prefix if present 2. Prepend opencode/ if no slash exists --- apps/server/src/providers/opencode-provider.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/server/src/providers/opencode-provider.ts b/apps/server/src/providers/opencode-provider.ts index 6babb978..0fd8f851 100644 --- a/apps/server/src/providers/opencode-provider.ts +++ b/apps/server/src/providers/opencode-provider.ts @@ -25,7 +25,6 @@ import type { InstallationStatus, ContentBlock, } from '@automaker/types'; -import { stripProviderPrefix } from '@automaker/types'; import { type SubprocessOptions, getOpenCodeAuthIndicators } from '@automaker/platform'; import { createLogger } from '@automaker/utils'; @@ -328,10 +327,18 @@ export class OpencodeProvider extends CliProvider { args.push('--format', 'json'); // Handle model selection - // Strip 'opencode-' prefix if present, OpenCode uses format like 'anthropic/claude-sonnet-4-5' + // Convert canonical prefix format (opencode-xxx) to CLI slash format (opencode/xxx) + // OpenCode CLI expects provider/model format (e.g., 'opencode/big-model') if (options.model) { - const model = stripProviderPrefix(options.model); - args.push('--model', model); + // Strip opencode- prefix if present, then ensure slash format + const model = options.model.startsWith('opencode-') + ? options.model.slice('opencode-'.length) + : options.model; + + // If model has slash, it's already provider/model format; otherwise prepend opencode/ + const cliModel = model.includes('/') ? model : `opencode/${model}`; + + args.push('--model', cliModel); } // Note: OpenCode reads from stdin automatically when input is piped