Open-source AI browser agent for Chrome and Firefox (monorepo) ðŸ§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
Drop the stale session after a graph update; clear stale offline evidence
Claude532306025b12
diff --git a/scripts/models/bonsai/build_vision.py b/scripts/models/bonsai/build_vision.pyindex 4d40df926..09262c0f0 100644--- a/scripts/models/bonsai/build_vision.py+++ b/scripts/models/bonsai/build_vision.py@@ -222,7 +222,7 @@ def build(size, workspace, offline=False, skip_inference=False):# A rebuilt package needs fresh external validation. Keep the original# reports outside this directory, but never seal a stale success report# into newly generated model artifacts.- for filename in ("browser-validation.json", "native-vision-validation.json"):+ for filename in ("browser-validation.json", "offline-browser-validation.json", "native-vision-validation.json"):(output / filename).unlink(missing_ok=True)original_config = read_json(prism / "config.json")config = read_json(text / "config.json")diff --git a/src/chrome/src/offscreen/inference-worker.js b/src/chrome/src/offscreen/inference-worker.jsindex e6060640e..65cf8c82c 100644--- a/src/chrome/src/offscreen/inference-worker.js+++ b/src/chrome/src/offscreen/inference-worker.js@@ -1130,8 +1130,12 @@ async function downloadTextModel(payload, { onStarted } = {}) {await clearLegacyLfm25VlWrongPrecisionCache(modelId, dtype);if (await isTextModelReady(modelId, dtype)) {// An explicit download of a cached model is the update path for its graph.- if (WEBGPU_BONSAI2_VISION_MODEL_IDS.has(modelId)) {- await refreshBonsai2DecoderGraph(modelId, { allowNetwork: true });+ // Model operations are serialized, so no load can race this replacement.+ if (WEBGPU_BONSAI2_VISION_MODEL_IDS.has(modelId)+ && await refreshBonsai2DecoderGraph(modelId, { allowNetwork: true }) === 'updated'+ && visionRuntimeKey.startsWith(`vision|${modelId}|`)) {+ // The resident session was built from the replaced graph.+ await disposeVisionRuntime();}if (payload?.requireTools === true) {const runtime = await getDownloadedTextRuntime(modelId, dtype, device, { localFilesOnly: true });diff --git a/test/run.js b/test/run.jsindex a2b719dd0..f452d6f5c 100644--- a/test/run.js+++ b/test/run.js@@ -67572,6 +67572,8 @@ test('Bonsai 2 Vision worker replaces only a stale cached decoder graph', async}assert.match(workerSource, /refreshBonsai2DecoderGraph\(modelId, \{ allowNetwork: !localFilesOnly \}\)/,'runtime loads may download the graph only outside cache-only inference');+ assert.match(workerSource, /refreshBonsai2DecoderGraph\(modelId, \{ allowNetwork: true \}\) === 'updated'\s*&& visionRuntimeKey\.startsWith\(`vision\|\$\{modelId\}\|`\)\) \{[^}]*await disposeVisionRuntime\(\);/,+ 'an explicit update must drop the resident session built from the replaced graph');const entries = new Map([[graphUrl, 'scan graph'], [dataUrl, 'weights']]);const fetched = [];