jackwener/OpenCLI · error · AuthRequiredError

Yuanbao opened a login gate before sending the prompt. ${SES

Error message

Yuanbao opened a login gate before sending the prompt. ${SESSION_HINT}

What it means

Before sending the prompt, the Yuanbao web page already shows a login gate (auth wall), so the CLI aborts with an AUTH_REQUIRED error rather than submitting a message that would fail. SESSION_HINT is appended to guide the user to fix their browser session.

Source

Thrown at clis/yuanbao/ask.js:328

    defaultFormat: 'plain',
    args: [
        { name: 'prompt', required: true, positional: true, help: 'Prompt to send' },
        { name: 'timeout', type: 'int', required: false, help: 'Max seconds to wait (default: 60)', default: 60 },
        { name: 'search', type: 'boolean', required: false, help: 'Enable Yuanbao internet search (default: true)', default: true },
        { name: 'think', type: 'boolean', required: false, help: 'Enable Yuanbao deep thinking (default: false)', default: false },
    ],
    columns: ['Role', 'Text'],
    func: async (page, kwargs) => {
        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.');

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open the browser profile used by the CLI and log into Yuanbao manually to refresh the session
  2. Clear Yuanbao cookies and re-login so no stale gate-triggering cookies remain
  3. Verify YUANBAO_URL points to the correct, non-login-redirecting host
  4. Re-run the command immediately after login while the session cookie is fresh

Example fix

// before: assuming a session exists
await ensureYuanbaoPage(page);
await sendYuanbaoMessage(page, prompt);
// after: caller checks and re-authenticates on AUTH_REQUIRED
try {
  await yuanbaoAsk(prompt);
} catch (e) {
  if (e.code === 'AUTH_REQUIRED') { await yuanbaoLogin(); return yuanbaoAsk(prompt); }
  throw e;
}
Defensive patterns

Strategy: validation

Validate before calling

import { hasLoginGate } from './yuanbao/page.js';
await ensureYuanbaoPage(page);
if (await hasLoginGate(page)) {
  await yuanbaoLogin(page); // re-auth before calling ask
}

Type guard

async function isYuanbaoSessionValid(page) {
  return !(await hasLoginGate(page));
}

Try / catch

try {
  return await yuanbaoAsk(page, prompt);
} catch (e) {
  if (e.code === 'AUTH_REQUIRED') {
    await yuanbaoLogin(page);
    return yuanbaoAsk(page, prompt);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling the yuanbao ask command when ensureYuanbaoPage leaves the page in a logged-out state and hasLoginGate(page) returns true prior to sendYuanbaoMessage.

Common situations: Expired Yuanbao/tencent browser cookies; headless browser profile never logged in; Yuanbao forced re-login after policy change or long inactivity; incognito profile without persisted session.

Related errors


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