Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

WIP repeat option

Claude6710abcf1818
diff --git a/scripts/check-webgpu-ask.mjs b/scripts/check-webgpu-ask.mjs
index 292bb046a..59e333693 100644
--- a/scripts/check-webgpu-ask.mjs
+++ b/scripts/check-webgpu-ask.mjs
@@ -23,6 +23,8 @@
// --tasks a,b run only these tasks
// --timeout-ms N per-task deadline (default 10 minutes)
// --decoder-graph F install a replacement decoder graph in the cache first
+// --repeat N run each selected task N times (answers are sampled, so
+// rare failures need several runs to show)
import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
import http from 'node:http';
@@ -122,7 +124,8 @@ const tasks = [
{ name: 'image-german', page: '/image.html', text: 'Welche Farbe hat die Tasse auf dem Foto?', expect: /grün|green/i, screenshot: true },
{ name: 'image-spanish', page: '/image.html', text: '¿De qué color es la taza de la foto?', expect: /verde|green/i, screenshot: true },
{ name: 'text-german', page: '/pricing.html', text: 'Wie viel kostet der Pro-Tarif im Monat?', expect: /29/, screenshot: false },
-].filter(task => !taskFilter || taskFilter.has(task.name));
+].filter(task => !taskFilter || taskFilter.has(task.name))
+ .flatMap(task => Array.from({ length: Math.max(1, Number(option('--repeat', 1)) || 1) }, () => task));
await fs.mkdir(path.dirname(output), { recursive: true });
const result = { model, extension, startedAt: new Date().toISOString(), tasks: [] };
diff --git a/test/webgpu-decisions.mjs b/test/webgpu-decisions.mjs
index 93de50121..41e42fac6 100644
--- a/test/webgpu-decisions.mjs
+++ b/test/webgpu-decisions.mjs
@@ -245,7 +245,9 @@ test('a cancelled decision stops in the worker before using the model', async ()
const worker = await readFile(new URL('../src/chrome/src/offscreen/inference-worker.js', import.meta.url), 'utf8');
const run = worker.slice(worker.indexOf('async function runMultimodalDecision'), worker.indexOf('async function runText'));
assert.match(run, /prefixLength, stopIfCancelled\)/, 'prefill slices check for a cancel');
- assert.equal((run.match(/stopIfCancelled\(\);\n\s*const (?:output|logits) = await bonsai2ContinuationLogits/g) || []).length, 2,
+ const continuations = (run.match(/await bonsai2ContinuationLogits/g) || []).length;
+ assert.ok(continuations >= 2);
+ assert.equal((run.match(/stopIfCancelled\(\);\n\s*const (?:output|logits) = await bonsai2ContinuationLogits/g) || []).length, continuations,
'every continuation checks for a cancel');
});