{"record":{"id":"15e591fcb7c3c481","repo":"jackwener/OpenCLI","slug":"yuanbao-opened-a-login-gate-instead-of-accepting-t","errorCode":null,"errorMessage":"Yuanbao opened a login gate instead of accepting the prompt. ${SESSION_HINT}","messagePattern":"Yuanbao opened a login gate instead of accepting the prompt\\. (.+?)","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/yuanbao/ask.js","lineNumber":337,"sourceCode":"        const prompt = kwargs.prompt;\n        const timeout = kwargs.timeout;\n        if (!Number.isInteger(timeout) || timeout < 1) {\n            throw new ArgumentError('--timeout must be a positive integer (seconds)');\n        }\n        const useSearch = normalizeBooleanFlag(kwargs.search, true);\n        const useThink = normalizeBooleanFlag(kwargs.think, false);\n        await ensureYuanbaoPage(page);\n        if (await hasLoginGate(page)) {\n            throw authRequired('Yuanbao opened a login gate before sending the prompt.');\n        }\n        await setYuanbaoInternetSearch(page, useSearch);\n        await setYuanbaoDeepThink(page, useThink);\n        const beforeAssistantMessages = await getYuanbaoAssistantMessages(page);\n        const beforeLines = await getYuanbaoTranscriptLines(page);\n        const sendResult = await sendYuanbaoMessage(page, prompt);\n        if (!sendResult?.ok) {\n            if (await hasLoginGate(page)) {\n                throw authRequired('Yuanbao opened a login gate instead of accepting the prompt.');\n            }\n            throw sendFailure(sendResult?.reason, sendResult?.detail);\n        }\n        const response = await waitForYuanbaoResponse(page, beforeAssistantMessages.length, beforeLines, prompt, timeout);\n        if (response === 'blocked') {\n            throw authRequired('Yuanbao opened a login gate instead of returning a chat response.');\n        }\n        if (!response) {\n            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.');\n        }\n        return [\n            { Role: 'User', Text: prompt },\n            { Role: 'Assistant', Text: response },\n        ];\n    },\n});\nexport const __test__ = {\n    collectYuanbaoTranscriptAdditions,","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/yuanbao/ask.js#L319-L355","documentation":"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).","triggerScenarios":"sendYuanbaoMessage returns {ok:false} and a subsequent hasLoginGate(page) check is true during the yuanbao ask flow.","commonSituations":"Session expired between page load and prompt send; Yuanbao invalidated the cookie mid-session; anonymous users blocked from sending prompts on this agent.","solutions":["Log into Yuanbao in the automation browser profile, then retry the command","Clear cookies for the Yuanbao domain and complete a fresh login","Check whether the account/agent requires special access and use an authorized account","Retry shortly after re-login to avoid another mid-flow expiry"],"exampleFix":"// before: treating all send failures the same\nif (!sendResult.ok) throw sendFailure(sendResult.reason);\n// after: catch AUTH_REQUIRED and re-authenticate\ntry { await yuanbaoAsk(prompt); }\ncatch (e) { if (e.code === 'AUTH_REQUIRED') { await yuanbaoLogin(); } else { throw e; } }","handlingStrategy":"try-catch","validationCode":"await ensureYuanbaoPage(page);\nif (await hasLoginGate(page)) await yuanbaoLogin(page); // pre-send check mirrors the library's post-failure check","typeGuard":"function isSendOk(r) {\n  return !!r && r.ok === true;\n}","tryCatchPattern":"try {\n  return await yuanbaoAsk(page, prompt);\n} catch (e) {\n  if (e.code === 'AUTH_REQUIRED') { await yuanbaoLogin(page); return yuanbaoAsk(page, prompt); }\n  if (e.code === 'COMMAND_EXEC') { /* inspect e.message for send reason */ }\n  throw e;\n}","preventionTips":["Distinguish AUTH_REQUIRED from COMMAND_EXEC errors in your handler","Keep sessions alive during long flows; re-check the gate after each navigation","Update selectors if send failures become constant (DOM drift)","Retry sends once after a short wait before giving up"],"tags":["auth","browser-automation","yuanbao"],"backgroundTag":"login-gate-detected","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}