jackwener/OpenCLI · error · ArgumentError

--thinking must be 'standard' or 'extended', got '${thinking

Error message

--thinking must be 'standard' or 'extended', got '${thinkingRaw}'

What it means

When a `--thinking` flag is present, clis/gemini/ask.js validates its value: after trimming and lowercasing it must equal `standard` or `extended`. Any other string throws this ArgumentError, with a hint to run `opencli gemini models` for available thinking levels.

Source

Thrown at clis/gemini/ask.js:124

        const startFresh = normalizeBooleanFlag(kwargs.new);
        if (startFresh)
            await startNewGeminiChat(page);

        // ── Early validation: model format & thinking value ────────────
        const hasModel = kwargs.model !== undefined && kwargs.model !== null;
        const hasThinking = kwargs.thinking != null;

        let modelValue = null;
        if (hasModel) {
            modelValue = String(kwargs.model).trim();
            validateAskModelValue(modelValue);
        }

        if (hasThinking) {
            const thinkingRaw = String(kwargs.thinking ?? '').trim();
            const thinkingValue = thinkingRaw.toLowerCase();
            if (thinkingValue !== 'standard' && thinkingValue !== 'extended') {
                throw new ArgumentError(
                    `--thinking must be 'standard' or 'extended', got '${thinkingRaw}'`,
                    'Run `opencli gemini models` to see available thinking levels.',
                );
            }
        }

        // ── Model and thinking discovery (shared by both model and
        //    thinking selection) ──────────────────────────────────────
        let discoveredModels = null;
        if (hasModel || hasThinking) {
            await ensureGeminiPage(page);

            // Open the picker menu (click the model-picker button).
            const pickerRaw = await page.evaluate(`
              (() => {
                ${pickModelPickerScript()}
                const picker = findModelPicker();
                if (!picker) return { ok: false, reason: 'Gemini model picker button was not found' };

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use exactly `--thinking standard` or `--thinking extended` (case-insensitive)
  2. Run `opencli gemini models` to confirm the thinking levels offered for your chosen model
  3. Sanitize/whitelist the value in wrapper scripts before forwarding it

Example fix

// before
opencli gemini ask --model 2.5-pro --thinking high ...
// after
opencli gemini ask --model 2.5-pro --thinking extended ...
Defensive patterns

Strategy: validation

Validate before calling

const allowed = ['standard', 'extended'];
if (args.thinking !== undefined && !allowed.includes(String(args.thinking).trim().toLowerCase())) {
  throw new Error(`--thinking must be 'standard' or 'extended', got '${args.thinking}'`);
}

Type guard

function isValidThinking(v) {
  const s = String(v ?? '').trim().toLowerCase();
  return s === 'standard' || s === 'extended';
}

Try / catch

try {
  await geminiAsk(args);
} catch (err) {
  if (err.name === 'ArgumentError' && err.message.includes("--thinking")) {
    console.error('Valid values: standard | extended (see `opencli gemini models`)');
    process.exit(2);
  }
  throw err;
}

Prevention

When it happens

Trigger: `opencli gemini ask --thinking high`, `--thinking on`, `--thinking "Extended "` (fails only if trim/lower somehow bypassed — it doesn't), or numeric values like `--thinking 2`.

Common situations: Using thinking-budget vocabularies from other Gemini SDKs (`low`/`high`, token counts); typos like `extented`; scripts passing raw user input as the thinking level.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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