jackwener/OpenCLI · error · ArgumentError

not a valid Yuanbao session reference (got "${input}"); pass

Error message

not a valid Yuanbao session reference (got "${input}"); pass either a full https://yuanbao.tencent.com/chat/<agentId>/<convId> URL or a bare "<agentId>/<convId>" pair. A UUID alone is not enough — Yuanbao requires the agentId.

What it means

This is the fallback rejection in parseYuanbaoSessionId: the input was neither a Yuanbao chat URL nor an <agentId>/<convId> pair. The message explicitly calls out the most common mistaken form — a bare conversation UUID — since Yuanbao requires the agentId alongside it.

Source

Thrown at clis/yuanbao/shared.js:114

            throw new ArgumentError(
                'id',
                `not a valid Yuanbao chat URL (got "${input}"); expected https://yuanbao.tencent.com/chat/<agentId>/<convId>`,
            );
        }
        return { agentId, convId: convId.toLowerCase() };
    }
    const slashMatch = raw.match(/^([A-Za-z0-9_-]+)\/([0-9a-f-]{36})$/i);
    if (slashMatch) {
        const [, agentId, convId] = slashMatch;
        if (!AGENT_ID_RE.test(agentId) || !CONV_ID_RE.test(convId)) {
            throw new ArgumentError(
                'id',
                `not a valid Yuanbao "<agentId>/<convId>" pair (got "${input}"); agentId must be 4-40 word chars, convId must be a UUID`,
            );
        }
        return { agentId, convId: convId.toLowerCase() };
    }
    throw new ArgumentError(
        'id',
        `not a valid Yuanbao session reference (got "${input}"); pass either a full https://yuanbao.tencent.com/chat/<agentId>/<convId> URL or a bare "<agentId>/<convId>" pair. A UUID alone is not enough — Yuanbao requires the agentId.`,
    );
}

export async function getCurrentYuanbaoSessionId(page) {
    const url = await page.evaluate('window.location.href').catch(() => '');
    if (typeof url !== 'string') return null;
    const match = url.match(/yuanbao\.tencent\.com\/chat\/([A-Za-z0-9_-]+)\/([0-9a-f-]{36})(?:[/?#]|$)/i);
    if (!match) return null;
    const [, agentId, convId] = match;
    if (!AGENT_ID_RE.test(agentId) || !CONV_ID_RE.test(convId)) return null;
    return { agentId, convId: convId.toLowerCase() };
}

export async function getYuanbaoModelLabel(page) {
    const result = await page.evaluate(`(() => {
    const btn = document.querySelector('[dt-button-id="model_switch"]');

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass the full URL: https://yuanbao.tencent.com/chat/<agentId>/<convId>
  2. Or the pair: `<agentId>/<convId>` — both parts are required
  3. Get AgentId/SessionId from `yuanbao history` (columns Index, Title, AgentId, SessionId, Url) and use those, never the Title
  4. If you only have a UUID, list conversations and match it against the SessionId column to recover the agentId

Example fix

// before
await cli.open('9f8b7c6d-1234-4a5b-8c9d-0e1f2a3b4c5d');
// after
await cli.open('tencent-agent/9f8b7c6d-1234-4a5b-8c9d-0e1f2a3b4c5d');
Defensive patterns

Strategy: validation

Validate before calling

const isUrl = /yuanbao\.tencent\.com\/chat\//i.test(input);
const isPair = /^[A-Za-z0-9_-]+\/[0-9a-f-]{36}$/i.test(input);
if (!isUrl && !isPair) throw new Error('need a chat URL or <agentId>/<convId> pair; a bare UUID is not enough');

Type guard

const isUsableSessionRef = (v) => typeof v === 'string' && (
  /yuanbao\.tencent\.com\/chat\//i.test(v) || /^[A-Za-z0-9_-]+\/[0-9a-f-]{36}$/i.test(v.trim())
);

Try / catch

try {
  await cli.yuanbaoOpen(input);
} catch (e) {
  if (e.name === 'ArgumentError' && /not a valid Yuanbao session reference/.test(e.message)) {
    const sessions = await cli.yuanbaoHistory({ limit: 50 });
    const hit = sessions.find(s => s.SessionId?.startsWith(uuidFragment));
    if (hit) await cli.yuanbaoOpen(`${hit.AgentId}/${hit.SessionId}`);
  } else throw e;
}

Prevention

When it happens

Trigger: Passing a lone UUID ('9f8b7c6d-...'), a URL without the /chat/ path, a session title from `yuanbao history` instead of its AgentId/SessionId, or input with spaces/typos such as a trailing slash-separated pair with wrong segment count.

Common situations: Assuming convId alone identifies a conversation (it does not — agentId is mandatory); copying the Title column from history output; older scripts built for a CLI version that accepted UUID-only references.

Related errors


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