test(live): add provider filters + google skip rules

This commit is contained in:
Peter Steinberger
2026-01-10 21:16:54 +00:00
parent d45c27e51f
commit aa30995aa1
4 changed files with 67 additions and 3 deletions

View File

@@ -27,6 +27,7 @@ const ALL_MODELS =
const EXTRA_TOOL_PROBES = process.env.CLAWDBOT_LIVE_GATEWAY_TOOL_PROBE === "1";
const EXTRA_IMAGE_PROBES =
process.env.CLAWDBOT_LIVE_GATEWAY_IMAGE_PROBE === "1";
const PROVIDERS = parseFilter(process.env.CLAWDBOT_LIVE_GATEWAY_PROVIDERS);
const describeLive = LIVE && GATEWAY_LIVE ? describe : describe.skip;
@@ -63,6 +64,16 @@ function isMeaningful(text: string): boolean {
return true;
}
function isGoogleModelNotFoundText(text: string): boolean {
const trimmed = text.trim();
if (!trimmed) return false;
if (!/not found/i.test(trimmed)) return false;
if (/models\/.+ is not found for api version/i.test(trimmed)) return true;
if (/"status"\s*:\s*"NOT_FOUND"/.test(trimmed)) return true;
if (/"code"\s*:\s*404/.test(trimmed)) return true;
return false;
}
function randomImageProbeCode(len = 10): string {
const alphabet = "2345689ABCEF";
const bytes = randomBytes(len);
@@ -233,6 +244,7 @@ describeLive("gateway live (dev agent, profile keys)", () => {
const candidates: Array<Model<Api>> = [];
for (const model of wanted) {
const id = `${model.provider}/${model.id}`;
if (PROVIDERS && !PROVIDERS.has(model.provider)) continue;
if (filter && !filter.has(id)) continue;
try {
// eslint-disable-next-line no-await-in-loop
@@ -345,6 +357,14 @@ describeLive("gateway live (dev agent, profile keys)", () => {
throw new Error(`agent status=${String(payload?.status)}`);
}
const text = extractPayloadText(payload?.result);
if (
model.provider === "google" &&
isGoogleModelNotFoundText(text)
) {
// Catalog drift: model IDs can disappear or become unavailable on the API.
// Treat as skip when scanning "all models" for Google.
continue;
}
if (!isMeaningful(text)) throw new Error(`not meaningful: ${text}`);
if (
!/\bmicro\s*-?\s*tasks?\b/i.test(text) ||
@@ -453,7 +473,7 @@ describeLive("gateway live (dev agent, profile keys)", () => {
if (Math.abs(cand.length - imageCode.length) > 2) return best;
return Math.min(best, editDistance(cand, imageCode));
}, Number.POSITIVE_INFINITY);
if (!(bestDistance <= 1)) {
if (!(bestDistance <= 2)) {
throw new Error(
`image probe missing code (${imageCode}): ${imageText}`,
);