jackwener/OpenCLI · error · CommandExecutionError

Failed to send message to ChatGPT

Error message

Failed to send message to ChatGPT

What it means

CommandExecutionError thrown by `chatgpt send` when `sendChatGPTMessage(page, prompt)` resolves falsy — the automation could not inject/submit the prompt into the composer even though the composer was present.

Source

Thrown at clis/chatgpt/send.js:64

            );
        }

        if (kwargs.conversation) {
            await openChatGPTConversation(page, kwargs.conversation);
        } else if (kwargs.project) {
            await navigateToProject(page, kwargs.project);
        } else if (normalizeBooleanFlag(kwargs.new)) {
            await startNewChat(page);
        } else {
            await ensureOnChatGPT(page);
        }
        // startNewChat / ensureOnChatGPT now wait for the composer selector
        // after navigating, so the previous standalone 2 s settle is redundant.
        await ensureChatGPTComposer(page, 'ChatGPT send requires a logged-in ChatGPT session with a visible composer.');

        const sent = await sendChatGPTMessage(page, prompt);
        if (!sent) {
            throw new CommandExecutionError('Failed to send message to ChatGPT', `Open ${CHATGPT_URL} and verify the composer is ready.`);
        }
        return [{ Status: 'Success', InjectedText: prompt }];
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry the command after confirming the composer is ready at chatgpt.com.
  2. Open chatgpt.com in the browser and try sending manually to check for rate limits or moderation blocks.
  3. Verify the page still has focus and no modal/dialog intercepted the click.
  4. Update the CLI's send automation selectors if the ChatGPT DOM changed.
Defensive patterns

Strategy: retry

Validate before calling

// Confirm composer is interactive before sending
const composer = await page.$('[contenteditable="true"], textarea[data-id="root"]');
if (!composer || !(await composer.isEnabled())) {
  throw new Error('Composer not ready; wait for page load and login');
}

Type guard

function sendSucceeded(s) { return s === true || (s !== null && typeof s === 'object' && Boolean(s.ok)); }

Try / catch

try {
  await run(['chatgpt', 'send', prompt]);
} catch (err) {
  if (String(err.message).includes('Failed to send message to ChatGPT')) {
    await new Promise(r => setTimeout(r, 5000));
    await run(['chatgpt', 'send', prompt]); // one retry after composer settles
  }
}

Prevention

When it happens

Trigger: After ensureChatGPTComposer succeeds, sendChatGPTMessage returns false/undefined: the send button click or Enter injection didn't register, or message injection failed silently.

Common situations: ChatGPT UI redesign moved the send button/composer internals; composer disabled mid-flight (rate limit or moderation); page lost focus; slow network delayed the submit; temporary ChatGPT service issue.

Related errors


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