{"record":{"id":"4511cc157229086a","repo":"jackwener/OpenCLI","slug":"could-not-enable-adaptive-thinking","errorCode":null,"errorMessage":"Could not enable Adaptive thinking","messagePattern":"Could not enable Adaptive thinking","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/claude/ask.js","lineNumber":102,"sourceCode":"            }\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');\n                }\n            } catch (err) {\n                // SPA navigates after send; \"Promise was collected\" means send succeeded\n                if (!String(err?.message || err).includes('Promise was collected')) throw err;\n            }\n            // Pre-waitForResponse settle dropped — waitForResponse's first 3 s polling\n            // tick covers the same window without an unconditional sleep.\n            const result = await waitForResponse(page, baseline, prompt, timeoutMs);","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/claude/ask.js#L84-L120","documentation":"When --think is enabled, setAdaptiveThinking() must flip the Adaptive thinking toggle. If it returns {ok:false} after retries, the library throws CommandExecutionError because the requested thinking mode could not be enabled.","triggerScenarios":"Running `claude ask ... --think` where the Adaptive thinking toggle is absent from the DOM, already in a conflicting state, or not clickable within retries; wantThink is true and thinkResult.ok is false.","commonSituations":"Plan or model that doesn't support adaptive thinking (toggle hidden); Claude UI change moving/removing the toggle; page not fully hydrated when the toggle is clicked.","solutions":["Re-run the command to give the page more time to render the toggle.","Drop --think if the current model/plan doesn't offer Adaptive thinking.","Update opencli if the toggle markup changed in a Claude UI update."],"exampleFix":"// before\nopencli claude ask \"solve this\" --think --model haiku\n// after\nopencli claude ask \"solve this\" --model sonnet --think  # model supporting adaptive thinking","handlingStrategy":"fallback","validationCode":"// Only request --think for models/plans that expose the toggle\nconst supportsThinking = ['sonnet', 'opus'].includes(opts.model);\nif (!supportsThinking) delete opts.think;","typeGuard":null,"tryCatchPattern":"try {\n  return await opencli.claude.ask(prompt, { think: true, model: 'sonnet', new: true });\n} catch (e) {\n  if (/Could not enable Adaptive thinking/.test(e.message)) {\n    return await opencli.claude.ask(prompt, { model: 'sonnet', new: true }); // retry without --think\n  }\n  throw e;\n}","preventionTips":["Use --think only with models that support adaptive thinking.","Treat --think as best-effort: fall back to a non-thinking run.","Update opencli when Claude changes the toggle markup."],"tags":["browser-automation","ui-toggle","feature-unsupported"],"backgroundTag":"ui-toggle-failure","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}