{"record":{"id":"b8738675c94bb9dd","repo":"jackwener/OpenCLI","slug":"send-reason-failed-to-send-grok-prompt","errorCode":null,"errorMessage":"${send?.reason || 'Failed to send Grok prompt'}","messagePattern":"\\$\\{send\\?\\.reason \\|\\| 'Failed to send Grok prompt'\\}","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/grok/send.js","lineNumber":46,"sourceCode":"    func: async (page, kwargs) => {\n        const prompt = String(kwargs.prompt || '').trim();\n        if (!prompt) throw new ArgumentError('prompt', 'is required');\n        const startFresh = normalizeBooleanFlag(kwargs.new, false);\n\n        await ensureOnGrok(page);\n        if (startFresh) {\n            await startNewChat(page);\n        }\n\n        const send = await sendMessage(page, prompt);\n        if (!send?.ok) {\n            // If the composer is missing, the most likely cause is that the\n            // signed-in session expired (Grok then renders a sign-in CTA in\n            // place of the composer). Surface that as AuthRequiredError so\n            // agents can prompt for re-auth instead of treating it as a\n            // generic execution failure.\n            if (!(await isLoggedIn(page))) throw authRequired();\n            throw new CommandExecutionError(send?.reason || 'Failed to send Grok prompt');\n        }\n        return [{ Status: 'sent', Prompt: prompt }];\n    },\n});\n","sourceCodeStart":28,"sourceCodeEnd":51,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/grok/send.js#L28-L51","documentation":"After sendPrompt runs, the command checks its result; on failure it first re-verifies login (throwing AuthRequiredError if logged out) and otherwise throws CommandExecutionError carrying send.reason or the default 'Failed to send Grok prompt'. This means the composer was present and the session valid, but submission still failed for another reason.","triggerScenarios":"sendPrompt returns {ok:false} with a reason while isLoggedIn(page) is true — e.g. the send click didn't register, the composer rejected input, or submission was blocked by a rate limit/dialog.","commonSituations":"Grok rate limiting prompts, an unexpected modal (quota upsell, safety notice) intercepting submission, partial session validity, or DOM changes breaking send mechanics without logging the user out.","solutions":["Read send.reason in the message for the specific failing step.","Retry after a short wait — rate limits and transient click failures often clear.","Reload the tab, dismiss any dialogs, confirm the composer accepts manual input.","Check for Grok usage limits on the account; update the library if the UI changed."],"exampleFix":"// before\ncli send 'hello'  // {ok:false, reason:'send click did not submit'}\n// after\n// dismiss the quota dialog in the tab / wait out the rate limit, then\ncli send 'hello'","handlingStrategy":"try-catch","validationCode":"// Confirm session and composer before sending:\nconst composer = await page.waitForSelector('textarea', { timeout: 5000 }).catch(() => null);\nif (!composer) throw new Error('composer missing — session may need re-auth');","typeGuard":null,"tryCatchPattern":"try {\n  await cli.send({ prompt });\n} catch (e) {\n  if (e instanceof AuthRequiredError) {\n    console.error('Re-authenticate grok.com in the automated tab.');\n  } else if (e instanceof CommandExecutionError && /Failed to send Grok prompt/.test(e.message)) {\n    console.warn('Send failed while logged in; retrying after backoff...');\n    await new Promise(r => setTimeout(r, 5000));\n    return cli.send({ prompt });\n  } else throw e;\n}","preventionTips":["Distinguish AuthRequiredError from generic send failures and handle each differently.","Watch for Grok rate limits and back off between sends.","Dismiss dialogs that can intercept the send action.","Log send.reason to identify the exact failing step."],"tags":["browser-automation","submission","rate-limit"],"backgroundTag":"prompt-submission-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}