jackwener/OpenCLI · error · AuthRequiredError

Yuanbao opened a login gate instead of accepting the prompt.

Error message

Yuanbao opened a login gate instead of accepting the prompt. ${SESSION_HINT}

What it means

The prompt send attempt failed, and when the CLI re-checked the page it found a login gate — meaning the send was rejected because the session was not authenticated. This distinguishes auth-related send failures from other send failures (which use sendFailure).

Solutions

  1. Log into Yuanbao in the automation browser profile, then retry the command
  2. Clear cookies for the Yuanbao domain and complete a fresh login
  3. Check whether the account/agent requires special access and use an authorized account
  4. Retry shortly after re-login to avoid another mid-flow expiry

Example fix

// before: treating all send failures the same
if (!sendResult.ok) throw sendFailure(sendResult.reason);
// after: catch AUTH_REQUIRED and re-authenticate
try { await yuanbaoAsk(prompt); }
catch (e) { if (e.code === 'AUTH_REQUIRED') { await yuanbaoLogin(); } else { throw e; } }
Defensive patterns

Strategy: try-catch

Validate before calling

await ensureYuanbaoPage(page);
if (await hasLoginGate(page)) await yuanbaoLogin(page); // pre-send check mirrors the library's post-failure check

Type guard

function isSendOk(r) {
  return !!r && r.ok === true;
}

Try / catch

try {
  return await yuanbaoAsk(page, prompt);
} catch (e) {
  if (e.code === 'AUTH_REQUIRED') { await yuanbaoLogin(page); return yuanbaoAsk(page, prompt); }
  if (e.code === 'COMMAND_EXEC') { /* inspect e.message for send reason */ }
  throw e;
}

Prevention

When it happens

Trigger: sendYuanbaoMessage returns {ok:false} and a subsequent hasLoginGate(page) check is true during the yuanbao ask flow.

Common situations: Session expired between page load and prompt send; Yuanbao invalidated the cookie mid-session; anonymous users blocked from sending prompts on this agent.

Related errors


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

Appendix: source

Thrown at clis/yuanbao/ask.js:337

        const prompt = kwargs.prompt;
        const timeout = kwargs.timeout;
        if (!Number.isInteger(timeout) || timeout < 1) {
            throw new ArgumentError('--timeout must be a positive integer (seconds)');
        }
        const useSearch = normalizeBooleanFlag(kwargs.search, true);
        const useThink = normalizeBooleanFlag(kwargs.think, false);
        await ensureYuanbaoPage(page);
        if (await hasLoginGate(page)) {
            throw authRequired('Yuanbao opened a login gate before sending the prompt.');
        }
        await setYuanbaoInternetSearch(page, useSearch);
        await setYuanbaoDeepThink(page, useThink);
        const beforeAssistantMessages = await getYuanbaoAssistantMessages(page);
        const beforeLines = await getYuanbaoTranscriptLines(page);
        const sendResult = await sendYuanbaoMessage(page, prompt);
        if (!sendResult?.ok) {
            if (await hasLoginGate(page)) {
                throw authRequired('Yuanbao opened a login gate instead of accepting the prompt.');
            }
            throw sendFailure(sendResult?.reason, sendResult?.detail);
        }
        const response = await waitForYuanbaoResponse(page, beforeAssistantMessages.length, beforeLines, prompt, timeout);
        if (response === 'blocked') {
            throw authRequired('Yuanbao opened a login gate instead of returning a chat response.');
        }
        if (!response) {
            throw new TimeoutError('yuanbao ask', timeout, 'No Yuanbao response was observed before the timeout. Retry with --timeout, and verify the current browser session is still interactive.');
        }
        return [
            { Role: 'User', Text: prompt },
            { Role: 'Assistant', Text: response },
        ];
    },
});
export const __test__ = {
    collectYuanbaoTranscriptAdditions,

View on GitHub (pinned to 49907e53dc)