jackwener/OpenCLI · error · CommandExecutionError

Grok composer rejected the prompt: ${JSON.stringify(sendResu

Error message

Grok composer rejected the prompt: ${JSON.stringify(sendResult)}

What it means

After typing the prompt into the Grok composer, sendPrompt reports whether submission succeeded; if it returns falsy or {ok:false}, this CommandExecutionError is thrown with the raw sendResult serialized. It means Grok's composer did not accept or submit the prompt, and the SESSION_HINT guides the user toward session/browser-state problems.

Source

Thrown at clis/grok/image.js:267

    const timeoutMs = (kwargs.timeout || 240) * 1000;
    const newChat = normalizeBooleanFlag(kwargs.new);
    const minCount = normalizePositiveInteger(kwargs.count, 1, 'count');
    const outDir = (kwargs.out || '').toString().trim();

    if (newChat) {
      await page.goto(GROK_URL);
      await page.wait(2);
      await tryStartFreshChat(page);
      await page.wait(2);
    } else if (!(await isOnGrok(page))) {
      await page.goto(GROK_URL);
      await page.wait(3);
    }

    const baselineBubbleCount = (await getBubbleImageSets(page)).length;
    const sendResult = await sendPrompt(page, prompt);
    if (!sendResult || !sendResult.ok) {
      throw new CommandExecutionError(
        `Grok composer rejected the prompt: ${JSON.stringify(sendResult)}`,
        SESSION_HINT,
      );
    }

    const startTime = Date.now();
    let lastSignature = '';
    let stableCount = 0;
    let lastImages = [];

    while (Date.now() - startTime < timeoutMs) {
      await page.wait(3);
      const bubbleImageSets = await getBubbleImageSets(page);
      const images = pickLatestImageCandidate(bubbleImageSets, baselineBubbleCount);

      if (images.length >= minCount) {
        const signature = imagesSignature(images);
        if (signature === lastSignature) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Reload the grok.com tab, confirm the composer is visible and you are logged in, then retry.
  2. Check the serialized sendResult in the message for the specific failing step.
  3. Dismiss any dialogs/banners overlaying the composer.
  4. Update the library if Grok's DOM changed (stale selectors).

Example fix

// before
sendPrompt(page, prompt) // -> {ok:false, step:'send-button-disabled'}
// after
// close the overlay dialog in the tab / log in again, then re-run the send command
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure the composer is present before sending:
const hasComposer = await page.waitForSelector('textarea', { timeout: 5000 }).catch(() => null);
if (!hasComposer) throw new Error('Grok composer not found — check session and UI state');

Try / catch

try {
  await cli.image({ prompt, outDir });
} catch (e) {
  if (e instanceof CommandExecutionError && e.message.includes('Grok composer rejected the prompt')) {
    const payload = e.message.match(/\{.*\}/s)?.[0];
    console.error('Composer rejected prompt; sendResult =', payload);
  } else throw e;
}

Prevention

When it happens

Trigger: sendPrompt returns {ok:false} or null because the composer textarea was not found, the send button was disabled, or submission did not register after waiting 3 page-seconds.

Common situations: Grok UI redesign moving composer selectors, a modal/upsell dialog covering the composer, rate-limit or quota banner replacing the input, or the page rendering a logged-out state.

Related errors


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