Skip to content

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

feat: add Compass Tiny v2.1 WebGPU preset; self-heal sessions after device loss

Emre Sokullu0231219a8494
diff --git a/docs/providers-and-models.md b/docs/providers-and-models.md
index 6759de8fc..ca8bd8879 100644
--- a/docs/providers-and-models.md
+++ b/docs/providers-and-models.md
@@ -47,7 +47,7 @@ class BaseLLMProvider {
| `gpt4all` | `openai` | local | (loaded model) | Yes (default on) |
| `local_openai_proxy` | `openai` | local | (required) | Off / manual toggle |
| `unsloth` | `openai` | local | (required) | Off / manual toggle |
-| `webgpu` (Chromium) | `webgpu` | local | Eight shipped LFM2.5/Nanbeige/MiniCPM5/Bonsai presets; experimental custom HF ONNX repos | LFM2.5-VL presets |
+| `webgpu` (Chromium) | `webgpu` | local | Nine shipped LFM2.5/Nanbeige/MiniCPM5/Compass/Bonsai presets; experimental custom HF ONNX repos | LFM2.5-VL presets |
| `azure_openai` | `azure_openai` | cloud | (deployment) | Manual toggle |
| `aws_bedrock` | `aws_bedrock` | cloud | (model id) | No |
| `openai` | `openai` | cloud | `gpt-5.6-terra` | Model-name regex |
@@ -150,7 +150,7 @@ duplicate request.
### Local Providers
On Chromium, **WebGPU (In-browser)** is an endpoint-free local provider. Its
-Apocalypse text picker offers eight shipped presets:
+Apocalypse text picker offers nine shipped presets:
- [`LiquidAI/LFM2.5-2.6B-ONNX`](https://huggingface.co/LiquidAI/LFM2.5-2.6B-ONNX/)
(`q4f16`, about 1.55 GB) through the packaged Transformers.js 4.2 / ONNX
@@ -194,6 +194,15 @@ Apocalypse text picker offers eight shipped presets:
(`<function name="..."><param name="...">...</param></function>`, CDATA-wrapped
when values contain `<`, `&`, or newlines), which the local fallback parser
accepts. Its practical context is 16k.
+- [`webbrain-one/webbrain-compass-tiny-v2.1`](https://huggingface.co/webbrain-one/webbrain-compass-tiny-v2.1)
+ (`q4f16`, about 1.87 GB across two external-data shards), WebBrain's Compass
+ Tiny v2.1 fine-tune of MiniCPM5-2B for Compact tool routing (v2.1 export
+ revision with the WebGPU numerical-parity fix). Same default
+ `onnx/model_q4f16.onnx` layout and MiniCPM5 XML tool calls as the base export.
+ It runs greedy with thinking disabled (the worker default for non-reasoning
+ presets) at a practical 16k context. Experimental integration-testing release
+ under a noncommercial research license; see the repository README and
+ `PROVENANCE.json` before treating it as production.
- [`prism-ml/Bonsai-27B-gguf`](https://huggingface.co/prism-ml/Bonsai-27B-gguf)
(`Q1_0`, about 3.8 GB) through a dedicated vendored [bitgpu](https://github.com/stfurkan/bitgpu)
worker. Bonsai is opt-in: WebBrain never auto-downloads the 27B weights.
diff --git a/docs/remote-downloads.md b/docs/remote-downloads.md
index 24507c133..42f77c9ba 100644
--- a/docs/remote-downloads.md
+++ b/docs/remote-downloads.md
@@ -22,7 +22,7 @@ WebBrain is designed to minimize remote network dependencies. All downloads fall
| Component | Remote Server / Origin | Origin Description | Typical Size | Protocol / Method | Checksum & Integrity | Local Storage Destination |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
-| **WebGPU Text / Multimodal Models** | `huggingface.co` / Hugging Face CDN | Eight shipped presets: LiquidAI LFM2.5 2.6B, 1.2B Instruct, 1.2B Thinking, VL 1.6B, VL 3B, Michionlion Nanbeige4.2-3B, RASMUS MiniCPM5-2B, and prism-ml Bonsai 27B | ~0.76 – 4.0 GB per selected preset | HTTPS GET (Transformers.js/ONNX or bitgpu) | Hugging Face Git LFS SHA-256 hash | Browser Cache API & IndexedDB (`transformers-cache`) |
+| **WebGPU Text / Multimodal Models** | `huggingface.co` / Hugging Face CDN | Nine shipped presets: LiquidAI LFM2.5 2.6B, 1.2B Instruct, 1.2B Thinking, VL 1.6B, VL 3B, Michionlion Nanbeige4.2-3B, RASMUS MiniCPM5-2B, webbrain-one Compass Tiny v2.1, and prism-ml Bonsai 27B | ~0.76 – 4.0 GB per selected preset | HTTPS GET (Transformers.js/ONNX or bitgpu) | Hugging Face Git LFS SHA-256 hash | Browser Cache API & IndexedDB (`transformers-cache`) |
| **Local Vision Model** | `huggingface.co` / Hugging Face CDN | `webbrain-one/webbrain-vl-2-450M-onnx` weights for local screenshot description and UI analysis | ~810 MB | HTTPS GET (Transformers.js pipeline) | Hugging Face Git LFS SHA-256 hash | Browser Cache API & IndexedDB (`transformers-cache`) |
| **Emergency Text Pack & SQLite Index** | `github.com/webbrain-one/emergency-box-corpus` (GitHub Releases CDN) | Release assets for curated public-domain field references, prebuilt SQLite FTS5 database, and precomputed E5 embeddings | ~245 MB (compressed ZIP) | Resumable HTTP `Range: bytes={offset}-` streaming fetch | Strict **SHA-256** hash comparison against hardcoded release descriptor before activation | OPFS (`webbrain-offline-rag/emergency-box-text/`) & IndexedDB (`webbrain_offline_rag`) |
| **Multilingual Semantic Model** | `huggingface.co` / Hugging Face CDN (`Xenova/multilingual-e5-small`) | ONNX weights for multilingual query embedding and vector search / candidate reranking | ~134 MB | HTTPS GET (ONNX Runtime Web / Transformers.js) | SHA-256 verification via Transformers.js manifest | Browser Cache API & IndexedDB (`transformers-cache`) |
diff --git a/src/chrome/src/offscreen/inference-worker.js b/src/chrome/src/offscreen/inference-worker.js
index cc657e1ab..220d26d9b 100644
--- a/src/chrome/src/offscreen/inference-worker.js
+++ b/src/chrome/src/offscreen/inference-worker.js
@@ -355,11 +355,16 @@ function bindWebGpuDeviceDiagnostics(library) {
lastWebGpuDeviceLost = '';
device.addEventListener?.('uncapturederror', event => {
lastWebGpuDeviceError = String(event?.error?.message || event?.message || 'Unknown WebGPU validation error.');
+ markWebgpuRuntimeDirty();
console.error('[webgpu] uncaptured device error:', lastWebGpuDeviceError);
});
device.lost?.then(info => {
if (device !== observedWebGpuDevice) return;
lastWebGpuDeviceLost = String(info?.message || info?.reason || 'The WebGPU device was lost.');
+ // A lost device can poison resident sessions without any OrtRun error
+ // reaching the generate paths, so flag the runtimes dirty now: the next
+ // run disposes them and rebuilds instead of burning one failing turn.
+ markWebgpuRuntimeDirty();
console.error('[webgpu] device lost:', lastWebGpuDeviceLost);
}).catch(() => {});
}
@@ -380,11 +385,35 @@ async function enrichWebGpuExecutionError(error) {
const suffix = [
details.length ? `GPU detail: ${details.join(' ')}` : '',
adapter ? `Adapter: ${adapter}.` : '',
- 'Close other GPU-heavy tabs/apps and retry with a short prompt. If it persists, this GPU/driver cannot execute this model with the current WebGPU runtime.',
+ 'Close other GPU-heavy tabs/apps and retry with a short prompt; a retry re-creates the on-device session from the cached download, it does not re-download. If it persists, this GPU/driver cannot execute this model with the current WebGPU runtime.',
].filter(Boolean).join(' ');
return new Error(`${error?.message || String(error)} ${suffix}`);
}
+// A failed WebGPU run poisons the resident ORT session: the next run must
+// rebuild from cache instead of reusing the dead device.
+let webgpuRuntimeDirty = false;
+
+function markWebgpuRuntimeDirty() {
+ webgpuRuntimeDirty = true;
+}
+
+async function disposeWebgpuRuntimesIfDirty() {
+ if (!webgpuRuntimeDirty) return false;
+ // Consume the flag before disposing so a listener firing mid-dispose
+ // re-marks it instead of being silently cleared.
+ webgpuRuntimeDirty = false;
+ await disposeAllRuntimes();
+ return true;
+}
+
+async function handleWebGpuExecutionFailure(error) {
+ const enriched = await enrichWebGpuExecutionError(error);
+ markWebgpuRuntimeDirty();
+ await disposeAllRuntimes();
+ return enriched;
+}
+
function postProgress(modelId, event) {
if (modelId === activeTextDownloadModelId && !textDownloadCancelMode) {
const file = String(event?.file || event?.name || '');
@@ -497,6 +526,9 @@ async function getVisionRuntime(modelId, dtype, device, {
readiness = 'vision',
} = {}) {
const key = `vision|${modelId}|${device}|${JSON.stringify(dtype)}`;
+ // A device loss flagged between turns leaves both resident sessions poisoned;
+ // dispose them before the cached gate so we never hand out a dead session.
+ await disposeWebgpuRuntimesIfDirty();
if (visionRuntime && visionRuntimeKey === key) {
visionRuntimeOwner = owner;
return visionRuntime;
@@ -560,9 +592,17 @@ async function getVisionRuntime(modelId, dtype, device, {
try { await resource.dispose(); } catch {}
}
}
- throw processorResult.status === 'rejected'
+ const failure = processorResult.status === 'rejected'
? processorResult.reason
: modelResult.reason;
+ // A session that dies while loading (dead adapter) must not leave a
+ // half-built runtime behind; flag it so the next call rebuilds.
+ if (isWebGpuExecutionFailure(failure)) {
+ markWebgpuRuntimeDirty();
+ await disposeAllRuntimes();
+ throw await enrichWebGpuExecutionError(failure);
+ }
+ throw failure;
}
const processor = processorResult.value;
const model = modelResult.value;
@@ -674,6 +714,9 @@ function stopVisionDownload(modelId) {
async function getTextRuntime(modelId, dtype, device, { localFilesOnly = false } = {}) {
assertOnnxTextModel(modelId);
+ // Same poison gate as the vision path: never hand out a cached session after
+ // a device failure. The build below already starts from disposed runtimes.
+ await disposeWebgpuRuntimesIfDirty();
const key = `text|${modelId}|${device}|${JSON.stringify(dtype)}`;
if (textRuntime && textRuntimeKey === key) return textRuntime;
if (textRuntimeLoadPromise) {
@@ -705,6 +748,14 @@ async function getTextRuntime(modelId, dtype, device, { localFilesOnly = false }
local_files_only: localFilesOnly,
progress_callback: event => postProgress(modelId, event),
});
+ } catch (error) {
+ // A session that dies while loading must not poison the next call.
+ if (isWebGpuExecutionFailure(error)) {
+ markWebgpuRuntimeDirty();
+ await disposeAllRuntimes();
+ throw await enrichWebGpuExecutionError(error);
+ }
+ throw error;
} finally {
if (localFilesOnly && library.env) library.env.allowLocalModels = previousAllowLocalModels;
}
@@ -1087,12 +1138,22 @@ async function runVision(payload, requestId) {
const maxNewTokens = Number.isFinite(requestedTokens)
? Math.max(1, Math.min(1600, Math.round(requestedTokens)))
: 800;
- const outputs = await runtime.model.generate({
- ...inputs,
- do_sample: false,
- max_new_tokens: maxNewTokens,
- ...(stoppingCriteria ? { stopping_criteria: [stoppingCriteria] } : {}),
- });
+ lastWebGpuDeviceError = '';
+ lastWebGpuDeviceLost = '';
+ let outputs;
+ try {
+ outputs = await runtime.model.generate({
+ ...inputs,
+ do_sample: false,
+ max_new_tokens: maxNewTokens,
+ ...(stoppingCriteria ? { stopping_criteria: [stoppingCriteria] } : {}),
+ });
+ } catch (error) {
+ // A dead WebGPU device poisons the resident session: enrich, drop it,
+ // and let the next turn rebuild from the cached weights.
+ if (isWebGpuExecutionFailure(error)) throw await handleWebGpuExecutionFailure(error);
+ throw error;
+ }
if (cancelledVisionGenerations.has(requestId)) {
const error = new Error('Vision generation was cancelled.');
error.name = 'AbortError';
@@ -1249,7 +1310,7 @@ async function runMultimodalText(payload) {
max_new_tokens: maxNewTokens,
});
} catch (error) {
- if (isWebGpuExecutionFailure(error)) throw await enrichWebGpuExecutionError(error);
+ if (isWebGpuExecutionFailure(error)) throw await handleWebGpuExecutionFailure(error);
throw error;
}
const inputLength = inputs.input_ids.dims.at(-1);
@@ -1296,7 +1357,7 @@ async function runText(payload) {
: { enable_thinking: false },
});
} catch (error) {
- if (isWebGpuExecutionFailure(error)) throw await enrichWebGpuExecutionError(error);
+ if (isWebGpuExecutionFailure(error)) throw await handleWebGpuExecutionFailure(error);
throw error;
}
const generated = output?.[0]?.generated_text;
diff --git a/src/chrome/src/providers/webgpu.js b/src/chrome/src/providers/webgpu.js
index b89c0c253..7e4628fb4 100644
--- a/src/chrome/src/providers/webgpu.js
+++ b/src/chrome/src/providers/webgpu.js
@@ -12,6 +12,7 @@ export const WEBGPU_LFM25_VL_16B_MODEL_ID = 'LiquidAI/LFM2.5-VL-1.6B-ONNX';
export const WEBGPU_LFM25_VL_3B_MODEL_ID = 'LiquidAI/LFM2.5-VL-3B-ONNX';
export const WEBGPU_NANBEIGE42_3B_MODEL_ID = 'Michionlion/Nanbeige4.2-3B-ONNX-WebGPU';
export const WEBGPU_MINICPM5_2B_MODEL_ID = 'RASMUS/MiniCPM5-2B-ONNX';
+export const WEBGPU_COMPASS_TINY_V2_MODEL_ID = 'webbrain-one/webbrain-compass-tiny-v2.1';
export const WEBGPU_BONSAI27_MODEL_ID = 'prism-ml/Bonsai-27B-gguf';
export const WEBGPU_DTYPE = 'q4f16';
export const WEBGPU_BONSAI27_DTYPE = 'q1';
@@ -104,6 +105,20 @@ export const WEBGPU_MODEL_PRESETS = Object.freeze([
contextWindow: 16384,
supportsVision: false,
}),
+ Object.freeze({
+ id: WEBGPU_COMPASS_TINY_V2_MODEL_ID,
+ runtime: WEBGPU_RUNTIME_ONNX,
+ label: 'Compass Tiny v2',
+ size: '1.87 GB',
+ dtype: WEBGPU_DTYPE,
+ dtypeLabel: WEBGPU_DTYPE,
+ // WebBrain Compass Tiny v2 fine-tune of MiniCPM5-2B for Compact tool
+ // routing. Same 42-layer GQA shape as the base export, so the practical
+ // browser setting stays at 16k. Tested with thinking disabled and greedy
+ // decoding, which is the worker's default path for non-reasoning presets.
+ contextWindow: 16384,
+ supportsVision: false,
+ }),
Object.freeze({
id: WEBGPU_BONSAI27_MODEL_ID,
runtime: WEBGPU_RUNTIME_BITGPU,
diff --git a/src/chrome/src/ui/apocalypse-mode.html b/src/chrome/src/ui/apocalypse-mode.html
index d0a099f57..6bfccee9e 100644
--- a/src/chrome/src/ui/apocalypse-mode.html
+++ b/src/chrome/src/ui/apocalypse-mode.html
@@ -171,6 +171,10 @@
<input type="radio" name="webgpu-text-preset" value="RASMUS/MiniCPM5-2B-ONNX" data-webgpu-text-preset>
<span>MiniCPM5-2B</span>
</label>
+ <label class="webgpu-text-preset">
+ <input type="radio" name="webgpu-text-preset" value="webbrain-one/webbrain-compass-tiny-v2.1" data-webgpu-text-preset>
+ <span>Compass Tiny v2</span>
+ </label>
<label class="webgpu-text-preset">
<input type="radio" name="webgpu-text-preset" value="prism-ml/Bonsai-27B-gguf" data-webgpu-text-preset>
<span data-i18n="ap.models.text.bonsai">Basic text model</span>
diff --git a/test/run.js b/test/run.js
index 1cb1ccade..34c2e6228 100644
--- a/test/run.js
+++ b/test/run.js
@@ -976,6 +976,7 @@ const {
WEBGPU_LFM25_VL_3B_MODEL_ID,
WEBGPU_NANBEIGE42_3B_MODEL_ID,
WEBGPU_MINICPM5_2B_MODEL_ID,
+ WEBGPU_COMPASS_TINY_V2_MODEL_ID,
WEBGPU_BONSAI27_MODEL_ID,
WEBGPU_MODEL_ID,
WEBGPU_MODEL_PRESETS,
@@ -62328,6 +62329,7 @@ test('Chrome exposes separate endpoint-free WebGPU text and vision providers', a
{ id: WEBGPU_LFM25_VL_3B_MODEL_ID, label: 'LFM2.5-VL-3B', runtime: 'onnx-vl', contextWindow: 16384, supportsVision: true },
{ id: WEBGPU_NANBEIGE42_3B_MODEL_ID, label: 'Nanbeige4.2-3B', runtime: 'onnx', contextWindow: 4096, supportsVision: false },
{ id: WEBGPU_MINICPM5_2B_MODEL_ID, label: 'MiniCPM5-2B', runtime: 'onnx', contextWindow: 16384, supportsVision: false },
+ { id: WEBGPU_COMPASS_TINY_V2_MODEL_ID, label: 'Compass Tiny v2', runtime: 'onnx', contextWindow: 16384, supportsVision: false },
{ id: WEBGPU_BONSAI27_MODEL_ID, label: 'Basic text model', runtime: 'bitgpu', contextWindow: 4096, supportsVision: false },
]);
assert.equal(new WebGPUProvider({ model: WEBGPU_BONSAI27_MODEL_ID }).dtype, 'q1');
@@ -63158,6 +63160,7 @@ test('WebGPU worker follows local text-generation and WebBrain VL vision contrac
WEBGPU_LFM25_VL_3B_MODEL_ID,
WEBGPU_NANBEIGE42_3B_MODEL_ID,
WEBGPU_MINICPM5_2B_MODEL_ID,
+ WEBGPU_COMPASS_TINY_V2_MODEL_ID,
]) {
assert.match(apocalypseHtml, new RegExp(modelId.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')),
`${modelId} is missing from the Apocalypse WebGPU picker`);
@@ -63962,6 +63965,8 @@ test('WebGPU worker replays text tool history and applies model-specific generat
const previousPipelineOptions = globalThis.__webgpuPipelineOptions;
const previousHoldTextGeneration = globalThis.__holdWebgpuTextGeneration;
const previousReleaseTextGeneration = globalThis.__releaseWebgpuTextGeneration;
+ const previousInstanceExecutionError = globalThis.__webgpuInstanceExecutionError;
+ const previousVisionExecutionError = globalThis.__webgpuVisionExecutionError;
let workerListener = null;
const posted = [];
try {
@@ -64045,7 +64050,12 @@ test('WebGPU worker replays text tool history and applies model-specific generat
async from_pretrained() {
globalThis.__webgpuRuntimeCounts.visionModelLoads++;
return {
- generate: async () => ({ slice: () => ({}) }),
+ generate: async () => {
+ if (globalThis.__webgpuVisionExecutionError) {
+ throw new Error(String(globalThis.__webgpuVisionExecutionError));
+ }
+ return { slice: () => ({}) };
+ },
dispose: async () => { globalThis.__webgpuRuntimeCounts.visionModelDisposals++; },
};
},
@@ -64063,6 +64073,9 @@ test('WebGPU worker replays text tool history and applies model-specific generat
await new Promise(resolve => { globalThis.__releaseWebgpuTextGeneration = resolve; });
}
globalThis.__webgpuGenerationOptions = options;
+ if (globalThis.__webgpuInstanceExecutionError) {
+ throw new Error(String(globalThis.__webgpuInstanceExecutionError));
+ }
const content = modelId === 'LiquidAI/LFM2.5-2.6B-ONNX'
|| modelId === 'Michionlion/Nanbeige4.2-3B-ONNX-WebGPU'
? 'private model reasoning</think>Hello!'
@@ -64396,6 +64409,22 @@ test('WebGPU worker replays text tool history and applies model-specific generat
tokenizer_encode_kwargs: { preserve_thinking: false },
}, 'MiniCPM5 must use its quickstart sampling and the reasoning-template argument');
+ const compassPayload = {
+ ...textPayload,
+ modelId: WEBGPU_COMPASS_TINY_V2_MODEL_ID,
+ };
+ await dispatch('download-text', compassPayload);
+ assert.equal(globalThis.__webgpuPipelineOptions.options.model_file_name, undefined,
+ 'Compass Tiny v2 publishes the default model_q4f16.onnx graph name');
+ const compassResponse = await dispatch('text-chat', compassPayload);
+ assert.equal(compassResponse.content, 'text answer');
+ assert.deepEqual(globalThis.__webgpuGenerationOptions, {
+ do_sample: false,
+ max_new_tokens: 256,
+ tools: undefined,
+ tokenizer_encode_kwargs: { enable_thinking: false },
+ }, 'Compass Tiny v2 must stay on the greedy thinking-disabled path from its tested integration');
+
const lfmInstructPayload = {
...textPayload,
modelId: WEBGPU_LFM25_12B_INSTRUCT_MODEL_ID,
@@ -64416,6 +64445,67 @@ test('WebGPU worker replays text tool history and applies model-specific generat
const incompatible = posted.find(message => message.id === incompatibleId);
assert.equal(incompatible.ok, false);
assert.match(incompatible.error, /chat template that accepts tools/);
+
+ const warmedText = await dispatch('text-chat', textPayload);
+ assert.equal(warmedText.content, 'text answer', 'the healthy text runtime must be resident before simulating a device loss');
+ const textLoadsBeforePoison = globalThis.__webgpuRuntimeCounts.textLoads;
+ const textDisposalsBeforePoison = globalThis.__webgpuRuntimeCounts.textDisposals;
+ globalThis.__webgpuInstanceExecutionError =
+ "failed to call OrtRun(): BufferManager::Download mapAsync GPUBuffer failed: A valid external Instance reference no longer exists";
+ const poisonedTextId = requestId++;
+ await workerListener({
+ data: { id: poisonedTextId, type: 'text-chat', payload: textPayload },
+ });
+ const poisonedText = posted.find(message => message.id === poisonedTextId);
+ assert.equal(poisonedText.ok, false);
+ assert.match(poisonedText.error, /OrtRun|mapAsync/,
+ 'a dead WebGPU device must still surface the enriched execution error');
+ assert.match(poisonedText.error, /re-creates the on-device session/,
+ 'the enriched error must explain that a retry rebuilds the session');
+ assert.equal(globalThis.__webgpuRuntimeCounts.textDisposals, textDisposalsBeforePoison + 1,
+ 'an execution failure must dispose the poisoned text runtime');
+ assert.equal(globalThis.__webgpuRuntimeCounts.textLoads, textLoadsBeforePoison,
+ 'the failed turn itself must not trigger a rebuild');
+ globalThis.__webgpuInstanceExecutionError = '';
+ const recoveredText = await dispatch('text-chat', textPayload);
+ assert.equal(recoveredText.content, 'text answer');
+ assert.equal(globalThis.__webgpuRuntimeCounts.textLoads, textLoadsBeforePoison + 1,
+ 'the next turn after a device failure must rebuild the session from cache');
+ assert.equal(globalThis.__webgpuRuntimeCounts.textDisposals, textDisposalsBeforePoison + 1,
+ 'rebuilding must not dispose again');
+
+ const warmedVisionId = requestId++;
+ await workerListener({
+ data: { id: warmedVisionId, type: 'chat', payload: visionPayload },
+ });
+ assert.equal(posted.find(message => message.id === warmedVisionId)?.ok, true,
+ 'the healthy vision session must be resident before simulating a device loss');
+ const visionLoadsBeforePoison = globalThis.__webgpuRuntimeCounts.visionModelLoads;
+ const visionDisposalsBeforePoison = globalThis.__webgpuRuntimeCounts.visionModelDisposals;
+ const textDisposalsBeforeVisionPoison = globalThis.__webgpuRuntimeCounts.textDisposals;
+ globalThis.__webgpuVisionExecutionError = 'failed to call OrtRun(): mapAsync on GPUBuffer failed';
+ const poisonedVisionId = requestId++;
+ await workerListener({
+ data: { id: poisonedVisionId, type: 'chat', payload: visionPayload },
+ });
+ const poisonedVision = posted.find(message => message.id === poisonedVisionId);
+ assert.equal(poisonedVision.ok, false);
+ assert.match(poisonedVision.error, /OrtRun|mapAsync/,
+ 'a dead vision device must surface the enriched execution error');
+ assert.equal(globalThis.__webgpuRuntimeCounts.visionModelDisposals, visionDisposalsBeforePoison + 1,
+ 'an execution failure must dispose the poisoned vision session');
+ assert.equal(globalThis.__webgpuRuntimeCounts.textDisposals, textDisposalsBeforeVisionPoison + 1,
+ 'the shared corrupted device means the co-resident text session goes too');
+ globalThis.__webgpuVisionExecutionError = '';
+ const recoveredVisionId = requestId++;
+ await workerListener({
+ data: { id: recoveredVisionId, type: 'chat', payload: visionPayload },
+ });
+ const recoveredVision = posted.find(message => message.id === recoveredVisionId);
+ assert.equal(recoveredVision.ok, true);
+ assert.equal(recoveredVision.content, 'vision answer');
+ assert.equal(globalThis.__webgpuRuntimeCounts.visionModelLoads, visionLoadsBeforePoison + 1,
+ 'the next vision turn after a device failure must rebuild the session');
} finally {
if (previousSelf === undefined) delete globalThis.self;
else globalThis.self = previousSelf;
@@ -64433,6 +64523,10 @@ test('WebGPU worker replays text tool history and applies model-specific generat
else globalThis.__holdWebgpuTextGeneration = previousHoldTextGeneration;
if (previousReleaseTextGeneration === undefined) delete globalThis.__releaseWebgpuTextGeneration;
else globalThis.__releaseWebgpuTextGeneration = previousReleaseTextGeneration;
+ if (previousInstanceExecutionError === undefined) delete globalThis.__webgpuInstanceExecutionError;
+ else globalThis.__webgpuInstanceExecutionError = previousInstanceExecutionError;
+ if (previousVisionExecutionError === undefined) delete globalThis.__webgpuVisionExecutionError;
+ else globalThis.__webgpuVisionExecutionError = previousVisionExecutionError;
}
});