jackwener/OpenCLI · error · CommandExecutionError
result?.reason || 'Failed to select Gemini model "' + modelI
Error message
result?.reason || 'Failed to select Gemini model "' + modelId + '"'
What it means
CommandExecutionError thrown when the in-page script that clicks the matching model menu item reports failure. The picker opened, but selecting the requested modelId inside the menu failed.
Source
Thrown at clis/gemini/utils.js:2739
await ensureGeminiPage(page);
// Open the picker menu.
const pickerRaw = await page.evaluate(openModelPickerForThinkingScript());
const pickerResult = unwrapGeminiEvaluateResult(pickerRaw, 'Gemini model picker');
if (!pickerResult || !pickerResult.ok) {
throw new CommandExecutionError(
pickerResult?.reason || 'Failed to open model picker for model selection'
);
}
// Wait for React to render the menu.
await page.wait(0.8);
// Find and click the matching menu item.
const raw = await page.evaluate(selectModelInMenuScript(modelId));
const result = unwrapGeminiEvaluateResult(raw, 'Gemini model selection');
if (!result || !result.ok) {
throw new CommandExecutionError(
result?.reason || 'Failed to select Gemini model "' + modelId + '"'
);
}
await page.wait(0.5);
const selectedModelId = await getCurrentGeminiModel(page);
if (selectedModelId !== modelId) {
throw new CommandExecutionError(
selectedModelId
? `Gemini model selection read-back returned "${selectedModelId}", expected "${modelId}"`
: `Gemini model selection did not expose selected model "${modelId}" after click`
);
}
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Verify the exact modelId matches a menu entry (use the model listing command if available)
- Re-run after the menu fully renders
- Update the CLI for current Gemini menu DOM
Example fix
// before opencli gemini model --set gemini-1.5-ultra // after opencli gemini model --set gemini-2.5-pro
Defensive patterns
Strategy: retry
Validate before calling
const KNOWN_MODELS = ['gemini-2.5-pro','gemini-2.5-flash'];
if (!KNOWN_MODELS.includes(modelId)) {
throw new Error(`Unknown modelId '${modelId}' — use an exact menu entry name`);
} Try / catch
try {
await selectGeminiModel(page, modelId);
} catch (err) {
if (err.message.includes('Failed to select Gemini model')) {
const list = await listGeminiModels(page);
console.error(`Model '${modelId}' not found. Available: ${list.join(', ')}`);
}
throw err;
} Prevention
- Use the exact model name shown in the picker menu
- Confirm your account has access to the requested model
- Retry after the menu finishes rendering
When it happens
Trigger: selectModelInMenuScript(modelId) at clis/gemini/utils.js:2739 returns ok:false or a reason — the menu item for modelId was not found or the click did not register.
Common situations: Requesting a model id/name that no longer exists in the menu; model renamed by Google; menu rendered before items hydrated; account lacks access to the requested model.
Related errors
- pickerResult?.reason || 'Failed to open model picker for mod
- Failed to extract Booking.com cards: ${err?.message || err}
- coupang add-to-cart evaluation failed: ${error?.message || e
- coupang search
- coupang search extraction failed: ${error?.message || error}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/309740430f20df9e.
Report an issue: GitHub.