{"record":{"id":"66b7d8317a1e03ae","repo":"jackwener/OpenCLI","slug":"could-not-switch-to-wantmodel-model","errorCode":null,"errorMessage":"Could not switch to ${wantModel} model","messagePattern":"Could not switch to (.+?) model","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/claude/ask.js","lineNumber":94,"sourceCode":"\n        const wantModel = kwargs.model || 'sonnet';\n        if (modelExplicit) {\n            if (inConversation) {\n                throw new ArgumentError(\n                    `Cannot switch to ${wantModel} model inside an existing conversation.`,\n                    'Re-run with --new to start a fresh chat before selecting a model.',\n                );\n            }\n\n            const modelResult = await withRetry(() => selectModel(page, wantModel));\n            if (!modelResult?.ok) {\n                if (modelResult?.upgrade) {\n                    throw new ArgumentError(\n                        `${wantModel} model requires a paid Claude plan.`,\n                        'Pick --model sonnet or --model haiku, or upgrade your account.',\n                    );\n                }\n                throw new CommandExecutionError(`Could not switch to ${wantModel} model`);\n            }\n            // Post-toggle settle dropped — the next CDP eval (setAdaptiveThinking) gives\n            // React enough time to flush aria-checked updates between rountrips.\n        }\n\n        const thinkResult = await withRetry(() => setAdaptiveThinking(page, wantThink));\n        if (!thinkResult?.ok && wantThink) {\n            throw new CommandExecutionError('Could not enable Adaptive thinking');\n        }\n        // Post-toggle settle dropped — the next CDP eval (sendMessage / sendWithFile)\n        // gives React enough time to flush aria-checked updates.\n\n        if (kwargs.file) {\n            const baseline = await withRetry(() => getBubbleCount(page));\n            try {\n                const fileResult = await sendWithFile(page, kwargs.file, prompt);\n                if (fileResult && !fileResult.ok) {\n                    throw new CommandExecutionError(fileResult.reason || 'Failed to attach file');","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/claude/ask.js#L76-L112","documentation":"selectModel() failed for a non-upgrade reason: the model menu could not be opened or the target option was not clickable within retry limits. The library throws CommandExecutionError naming the model it tried to switch to.","triggerScenarios":"withRetry(selectModel) returns {ok:false} without upgrade flag — e.g. the model picker DOM changed, the selector didn't load in time, or a modal/banner covers the menu.","commonSituations":"Claude UI redesign changing menu markup; slow page load so the picker isn't rendered when clicked; overlay dialogs (cookie banners, release notes) intercepting clicks.","solutions":["Re-run the command; withRetry may succeed once the page fully loads.","Reload claude.ai/new and dismiss any overlay dialogs before retrying.","Update opencli if the Claude UI changed and selectors are stale."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-check the model picker is reachable before invoking ask\nawait page.goto('https://claude.ai/new');\nawait page.wait({ selector: '[data-testid=\"model-selector\"]', timeout: 10 });","typeGuard":null,"tryCatchPattern":"try {\n  return await opencli.claude.ask(prompt, { model: 'opus', new: true });\n} catch (e) {\n  if (/Could not switch to .* model/.test(e.message)) {\n    await sleep(3000); // let the page fully render, then retry\n    return await opencli.claude.ask(prompt, { model: 'opus', new: true });\n  }\n  throw e;\n}","preventionTips":["Navigate to a fresh new-chat page and let it fully load before switching models.","Dismiss cookie banners/modals that intercept clicks.","Keep opencli updated against Claude UI changes."],"tags":["browser-automation","ui-selector","timeout"],"backgroundTag":"ui-selector-mismatch","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}