jackwener/OpenCLI · error · CommandExecutionError
selectedModelId ? `Gemini model selection read-back returned
Error message
selectedModelId ? `Gemini model selection read-back returned "${selectedModelId}", expected "${modelId}"` : `Gemini model selection did not expose selected model "${modelId}" after click` What it means
CommandExecutionError thrown after a model click when reading back the current model (getCurrentGeminiModel) does not equal the requested modelId — either a different model is reported or no model is exposed at all. This is a post-action verification step to guarantee the selection took effect.
Source
Thrown at clis/gemini/utils.js:2747
);
}
// 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
- Re-run the selection command
- Increase tolerance for UI lag (retry after a short wait)
- Use the exact canonical model id from the picker listing
Defensive patterns
Strategy: validation
Validate before calling
// verify the requested id is canonical before selecting
const available = await listGeminiModels(page);
if (!available.includes(modelId)) {
throw new Error(`'${modelId}' not offered; closest: ${available.filter(m => m.includes(modelId.slice(0,10)))}`);
} Type guard
function matchesRequested(selected: string | null, modelId: string): boolean {
return typeof selected === 'string' && selected.trim() === modelId;
} Try / catch
try {
await selectGeminiModel(page, modelId);
} catch (err) {
if (err.message.includes('read-back')) {
const current = await getCurrentGeminiModel(page);
console.error(`Selection mismatch: got ${current}, wanted ${modelId}; retrying...`);
}
throw err;
} Prevention
- Wait slightly longer between click and read-back if the UI is slow
- Compare against canonical ids, not display labels
- Re-run selection when read-back mismatches instead of proceeding
When it happens
Trigger: At clis/gemini/utils.js:2747 the click succeeded but the UI state read-back returned a mismatched selectedModelId, or returned nothing within the wait window (0.5s).
Common situations: UI state not yet updated at read time; selection silently reverted; ambiguous model names resolving to a different entry; Gemini UI lag.
Related errors
- Gemini model discovery returned a malformed Browser Bridge e
- Gemini model discovery returned a malformed result
- ${pickerResult?.reason || 'Failed to open Gemini model picke
- Could not select thinking level '${thinkingValue}' in the Ge
- Unexpected Gemini probe: ${JSON.stringify(probe)}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/777c408ff71cd40f.
Report an issue: GitHub.