jackwener/OpenCLI · error · CommandExecutionError

Failed to send Qianwen prompt

Error message

Failed to send Qianwen prompt

What it means

CommandExecutionError thrown when sendMessage fails to submit the prompt to the Qianwen chat UI (send.ok falsy), carrying sendMessage's reason as the message. If a login gate is detected instead, an AuthRequiredError is thrown rather than this error.

Source

Thrown at clis/qwen/ask.js:69

        await ensureOnQianwen(page);
        await dismissLoginModal(page);

        if (startFresh) {
            await startNewChat(page);
            await dismissLoginModal(page);
        }

        if (useThink) await setFeatureToggle(page, 'think', true);
        if (useResearch) await setFeatureToggle(page, 'research', true);

        // Anchor on the visible transcript BEFORE sending so waitForAnswer can
        // bind the reply to the newly sent prompt instead of an older answer.
        const baselineAnchor = await getBaselineChatAnchor(page);

        const send = await sendMessage(page, prompt);
        if (!send?.ok) {
            if (await hasLoginGate(page)) throw authRequired();
            throw new CommandExecutionError(send?.reason || 'Failed to send Qianwen prompt');
        }

        const result = await waitForAnswer(page, prompt, timeout, baselineAnchor);
        if (result.status === 'auth_required') throw authRequired();
        if (result.status === 'timeout') {
            throw new TimeoutError('qianwen ask', timeout, 'No Qianwen reply observed before timeout. Retry with --timeout increased.');
        }
        const assistant = result.assistant;
        if (!assistant) {
            throw new CommandExecutionError('No assistant reply found in Qianwen chat.');
        }
        const answer = wantMarkdown && assistant.html
            ? (bubbleHtmlToMarkdown(assistant.html) || assistant.text)
            : assistant.text;
        return [
            { Role: 'User', Text: prompt },
            { Role: 'Assistant', Text: answer },
        ];

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the send.reason embedded in the error to identify the exact DOM failure.
  2. Re-login if a login gate appeared, then retry.
  3. Retry after increasing pre-send wait times; refresh the page so the composer is fully hydrated.
  4. Update the library if the Qianwen UI selectors changed (check for a newer version).

Example fix

// before
const out = await qwenAsk(page, { prompt: 'hi' });
// after
try {
  const out = await qwenAsk(page, { prompt: 'hi' });
} catch (e) {
  if (e instanceof CommandExecutionError) {
    await page.reload();
    await page.wait(5);
    // retry once
  } else throw e;
}
Defensive patterns

Strategy: retry

Validate before calling

// ensure page is settled before sending
await page.wait(3);
if (await hasLoginGate(page)) { await qwenLogin(page); }

Type guard

function isSendFailure(e) {
  return e instanceof CommandExecutionError && !/No assistant reply|timeout/i.test(e.message);
}

Try / catch

try {
  await qwenAsk(page, { prompt });
} catch (e) {
  if (e instanceof AuthRequiredError) { await qwenLogin(page); }
  else if (isSendFailure(e)) {
    await page.reload(); await page.wait(5);
    await qwenAsk(page, { prompt }); // single retry
  } else { throw e; }
}

Prevention

When it happens

Trigger: sendMessage returns {ok:false} because the composer/submit button could not be found or clicked, the textarea was not editable, or the page state was unexpected; reason string propagates into this error.

Common situations: Qianwen UI markup changed after a frontend deploy; page still loading when send was attempted; modal/overlay (login, rate-limit, maintenance banner) intercepting clicks; session logged out mid-flow.

Related errors


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