jackwener/OpenCLI · error · ArgumentError

Could not select thinking level '${thinkingValue}' in the Ge

Error message

Could not select thinking level '${thinkingValue}' in the Gemini web UI

What it means

An ArgumentError raised when clicking the requested thinking-level option in the Gemini web UI failed after validation passed. The message collects hint parts (per-model or union values plus the `opencli gemini models` pointer) to help the user pick a workable value.

Source

Thrown at clis/gemini/ask.js:253

                const availableList = [...allThinking].sort().join(', ');
                throw new ArgumentError(
                    `--thinking '${thinkingValue}' is not currently available`,
                    `Available thinking values: ${availableList}. Run \`opencli gemini models\` for details.`,
                );
            }

            // Select the requested thinking level before snapshot.
            const selected = await selectGeminiThinking(page, thinkingValue);
            if (!selected) {
                // Build an informative hint from what we know.
                const hintParts = [];
                if (targetModelThinking && targetModelThinking.length > 0) {
                    hintParts.push(`Model '${targetModelId}' supports: ${targetModelThinking.sort().join(', ')}.`);
                } else if (allThinking.size > 0) {
                    hintParts.push(`Available thinking values: ${[...allThinking].sort().join(', ')}.`);
                }
                hintParts.push('Run `opencli gemini models` for details.');
                throw new ArgumentError(
                    `Could not select thinking level '${thinkingValue}' in the Gemini web UI`,
                    hintParts.join(' '),
                );
            }
        }

        const before = await readGeminiSnapshot(page);
        await sendGeminiMessage(page, prompt);
        const submissionStartedAt = Date.now();
        const submitted = await waitForGeminiSubmission(page, before, timeout);
        if (!submitted) {
            return [{ response: `💬 ${NO_RESPONSE_PREFIX} No Gemini response within ${timeout}s.` }];
        }
        const remainingTimeoutSeconds = Math.max(0, timeout - Math.ceil((Date.now() - submissionStartedAt) / 1000));
        const response = await waitForGeminiResponse(page, submitted, prompt, remainingTimeoutSeconds);
        if (!response) {
            return [{ response: `💬 ${NO_RESPONSE_PREFIX} No Gemini response within ${timeout}s.` }];
        }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry the command — a transient render race may have caused the click to miss
  2. Verify the value via `opencli gemini models` and re-run with an exact listed value
  3. Update the thinking-option selector in clis/gemini/ask.js if Gemini's UI changed
  4. Increase wait time between opening the settings menu and clicking the option

Example fix

// before
await page.wait(0.5);
await clickThinkingOption(value);
// after
await page.wait(2.0); // let the thinking menu render
await clickThinkingOption(value);
Defensive patterns

Strategy: retry

Validate before calling

const models = await getGeminiModels();
if (!models.some(m => (m.thinking || []).includes(thinkingValue))) {
  throw new Error(`'${thinkingValue}' not offered — check opencli gemini models`);
}

Try / catch

try {
  await askWithThinking(value);
} catch (e) {
  if (/Could not select thinking level/.test(e.message)) {
    await page.reload(); await page.wait(3); // retry once
  } else throw e;
}

Prevention

When it happens

Trigger: The UI interaction in the thinking-selection step after validation throws or returns failure, reaching the throw at clis/gemini/ask.js:253 (hintParts already built from targetModelThinking/allThinking).

Common situations: Gemini changed the thinking menu DOM so the option click misses; the option is present in discovery data but not rendered for the account/region; menu collapsed or re-rendered between open and click.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/c20f1633129fed12. Report an issue: GitHub.