jackwener/OpenCLI · error · ArgumentError

not a valid Yuanbao "<agentId>/<convId>" pair (got "${input}

Error message

not a valid Yuanbao "<agentId>/<convId>" pair (got "${input}"); agentId must be 4-40 word chars, convId must be a UUID

What it means

The input matched the bare <agentId>/<convId> pair pattern but one segment failed the stricter regexes: agentId must be 4-40 word characters and convId must be a canonical UUID. Note the loose slashMatch only requires 36 hex/dash chars, so strings like '----...' reach this validation and are rejected here with a precise message.

Source

Thrown at clis/yuanbao/shared.js:107

            'must be a non-empty Yuanbao chat URL or "<agentId>/<convId>" pair',
        );
    }
    const urlMatch = raw.match(/yuanbao\.tencent\.com\/chat\/([A-Za-z0-9_-]+)\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:[/?#]|$)/i);
    if (urlMatch) {
        const [, agentId, convId] = urlMatch;
        if (!AGENT_ID_RE.test(agentId) || !CONV_ID_RE.test(convId)) {
            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;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check agentId: 4-40 chars, only [A-Za-z0-9_-]
  2. Check convId: a real UUID, 8-4-4-4-12 hex digits
  3. Get exact AgentId and SessionId values from `yuanbao history` output
  4. Prefer passing the full chat URL — its regex is stricter and validates both segments at once

Example fix

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

Strategy: validation

Validate before calling

const [agentId, convId] = String(pair).split('/');
const ok = /^[A-Za-z0-9_-]{4,40}$/.test(agentId) &&
  /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(convId);
if (!ok) throw new Error('agentId must be 4-40 word chars; convId must be a UUID');

Type guard

const isValidPair = (v) => {
  if (typeof v !== 'string') return false;
  const [a, c] = v.split('/');
  return /^[A-Za-z0-9_-]{4,40}$/.test(a || '') && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(c || '');
};

Try / catch

try {
  await cli.yuanbaoOpen(pair);
} catch (e) {
  if (e.name === 'ArgumentError' && /agentId must be 4-40/.test(e.message)) {
    console.error('Check the <agentId>/<convId> pair format');
  } else throw e;
}

Prevention

When it happens

Trigger: Passing e.g. 'ab/<uuid>' (agentId too short), 'my.agent/<uuid>' (dot not allowed), or 'agent/not-a-uuid' (convId of 36 chars but wrong shape, like dashes-only or a 36-char non-UUID string).

Common situations: Users pasting only the conversation UUID with a placeholder prefix; splitting a URL incorrectly (e.g. taking extra path segments into agentId); generating ids from templates with unfilled variables like '${agentId}/${convId}'.

Related errors


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