jackwener/OpenCLI · error · CommandExecutionError
Could not find the ChatGPT ${target.label} tool option.
Error message
Could not find the ChatGPT ${target.label} tool option. What it means
selectChatGPTTool automates selecting a tool (e.g. web search, image gen) in the ChatGPT UI by repeatedly trying to locate and check the tool's option element. It throws this CommandExecutionError when, after retrying, it cannot find a clickable option matching the requested target.label on the page.
Source
Thrown at clis/chatgpt/utils.js:918
];
return haystacks.some(matchesLabel);
});
if (!(option instanceof HTMLElement)) return { found: false };
const checked = option.getAttribute('aria-checked') === 'true' || option.getAttribute('aria-selected') === 'true';
option.scrollIntoView({ block: 'center', inline: 'center' });
const rect = option.getBoundingClientRect();
return {
found: true,
checked,
x: Math.round(rect.left + rect.width / 2),
y: Math.round(rect.top + rect.height / 2),
};
})()`)), 'chatgpt tool option click');
if (optionCenter.found) break;
await page.wait(0.5);
}
if (!optionCenter?.found) {
throw new CommandExecutionError(`Could not find the ChatGPT ${target.label} tool option.`);
}
if (!optionCenter.checked) {
await page.nativeClick(Number(optionCenter.x), Number(optionCenter.y));
}
await page.wait(0.5);
const after = await getCurrentChatGPTTool(page);
if (after.tool !== target.key) {
throw new CommandExecutionError(`ChatGPT tool did not switch to ${target.label}.`);
}
return { Status: optionCenter.checked ? 'Already selected' : 'Success', Tool: target.label };
}
export async function clearChatGPTDraft(page) {
await page.evaluate(`
(() => {
const removeLabels = [/^remove file/i, /^移除文件/];
for (let pass = 0; pass < 10; pass += 1) {View on GitHub (pinned to 49907e53dc)
Solutions
- Update/re-run on a freshly loaded chatgpt.com page and verify the tool option exists in the UI manually
- Retry with longer waits between attempts (the loop waits 0.5s per try)
- Check whether the ChatGPT UI/layout changed and update the selector/option-click automation in utils.js
- Confirm the account actually has the requested tool available (some tools are plan- or region-gated)
- If the tool is already active in the UI, skip selectChatGPTTool
Example fix
// before
await selectChatGPTTool(page, { key: 'search', label: 'Web search' });
// after
await page.wait(2); // let the composer fully render
await selectChatGPTTool(page, { key: 'search', label: 'Web search' }); Defensive patterns
Strategy: retry
Validate before calling
const current = await getCurrentChatGPTTool(page);
if (current.tool === target.key) return { Status: 'Already selected', Tool: target.label };
if (!(await page.locator('composer tools menu visible'))) throw new Error('Tools menu not rendered; reload page before selectChatGPTTool'); Type guard
function isToolTarget(t) {
return typeof t === 'object' && t !== null && typeof t.key === 'string' && typeof t.label === 'string';
} Try / catch
try {
await selectChatGPTTool(page, target);
} catch (err) {
if (err instanceof CommandExecutionError && /tool option/.test(err.message)) {
await page.reload();
await selectChatGPTTool(page, target); // retry once on fresh page
} else throw err;
} Prevention
- Wait for the composer to fully render before selecting a tool
- Verify the tool exists in the current UI mode before targeting it
- Keep selectors/labels updated when ChatGPT changes its UI
- Pre-check current tool with getCurrentChatGPTTool to skip needless selection
When it happens
Trigger: Calling selectedTool for a target whose option button is absent: ChatGPT UI changed/moved the tools menu, the prompt box has no tools menu in the current mode, the label text changed upstream (locale/branding), or the page did not finish loading before the retry loop exhausted.
Common situations: ChatGPT A/B UI rollout renamed or relocated the tools menu; automation running against a logged-out or capped account where tools are unavailable; stale page after navigation so the menu never renders; timeout too short for slow loading.
Related errors
- ChatGPT tool did not switch to ${target.label}.
- Could not find Antigravity input box
- Could not find input box
- Could not find antigravity.agentSidePanelInputBox
- Could not find Antigravity input box
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/277ed9b2caa484e3.
Report an issue: GitHub.