diff --git a/lib/hooks/image-analyzer-transformer.cjs b/lib/hooks/image-analyzer-transformer.cjs index b041dd17..8fa3686c 100755 --- a/lib/hooks/image-analyzer-transformer.cjs +++ b/lib/hooks/image-analyzer-transformer.cjs @@ -177,16 +177,16 @@ function getModelsToTry() { seen.add(providerModels[currentProvider]); } - // 2. Default model - if (!seen.has(DEFAULT_MODEL)) { + // 2. Default model — only when no provider-specific model is configured, + // since DEFAULT_MODEL (gemini-2.5-flash) may not be routable on the + // current provider's CLIProxy endpoint (e.g. codex, claude) + if (models.length === 0 && !seen.has(DEFAULT_MODEL)) { models.push(DEFAULT_MODEL); seen.add(DEFAULT_MODEL); } - // 3. ANTHROPIC_MODEL fallback - if (anthropicModel && !seen.has(anthropicModel)) { - models.push(anthropicModel); - } + // 3. ANTHROPIC_MODEL fallback — skip, the main chat model is not + // necessarily vision-capable and adds unnecessary retry latency return models; } @@ -382,7 +382,10 @@ function analyzeViaCliProxy(base64Data, mediaType, model, timeoutMs) { try { const response = JSON.parse(data); - const text = response.content?.[0]?.text; + // Find the first text block — skip thinking blocks which use + // .thinking instead of .text (e.g. codex models with thinking enabled) + const textBlock = response.content?.find(b => b.type === 'text' && b.text); + const text = textBlock?.text; if (!text) { reject(new Error('No text content in response'));