Skip to content

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

fix(webgpu): default blank or missing model normalization to Compass Tiny v2.1

Emre Sokullu4c02b93276c7
diff --git a/src/chrome/src/background.js b/src/chrome/src/background.js
index 91000aa0c..fd32ffba6 100644
--- a/src/chrome/src/background.js
+++ b/src/chrome/src/background.js
@@ -1,6 +1,6 @@
import { ProviderManager } from './providers/manager.js';
import {
- WEBGPU_MODEL_ID,
+ WEBGPU_COMPASS_TINY_V2_MODEL_ID,
WEBGPU_VISION_DOWNLOAD_STATE_KEY,
WEBGPU_VISION_DOWNLOAD_STATE_MESSAGE,
WEBGPU_VISION_MODEL_ID,
@@ -2178,7 +2178,7 @@ async function standaloneRunProviderId(msg) {
const config = providerManager.getAll().webgpu;
const download = await providerManager.getWebgpuDownloadStatus().catch(() => null);
if (!isShippedWebgpuPreset(config?.model) || download?.ready !== true) {
- throw new Error(`Download ${webgpuModelDisplayName(config?.model || WEBGPU_MODEL_ID)} in Settings > Providers > WebGPU or Apocalypse Mode > WebGPU before using WebGPU in standalone chat.`);
+ throw new Error(`Download ${webgpuModelDisplayName(config?.model || WEBGPU_COMPASS_TINY_V2_MODEL_ID)} in Settings > Providers > WebGPU or Apocalypse Mode > WebGPU before using WebGPU in standalone chat.`);
}
return providerId;
}
diff --git a/src/chrome/src/providers/manager.js b/src/chrome/src/providers/manager.js
index 8e60ff217..e4c24f432 100644
--- a/src/chrome/src/providers/manager.js
+++ b/src/chrome/src/providers/manager.js
@@ -19,6 +19,7 @@ import {
WEBGPU_VISION_ENABLED_KEY,
WEBGPU_VISION_MODEL_ID,
hasWebgpuVisionCache,
+ normalizeWebgpuModelId,
webgpuModelDisplayName,
webgpuModelDtype,
webgpuModelPreset,
@@ -1848,6 +1849,7 @@ export class ProviderManager {
configured: id !== WEBBRAIN_CLOUD_PROVIDER_ID && (markConfigured || current.configured === true),
};
if (id === 'webgpu' && Object.hasOwn(updates, 'model')) {
+ merged.model = normalizeWebgpuModelId(merged.model);
const preset = webgpuModelPreset(merged.model);
if (preset?.contextWindow && !Object.hasOwn(updates, 'contextWindow')) {
merged.contextWindow = preset.contextWindow;
diff --git a/src/chrome/src/providers/webgpu.js b/src/chrome/src/providers/webgpu.js
index 078e6f25d..dcb988864 100644
--- a/src/chrome/src/providers/webgpu.js
+++ b/src/chrome/src/providers/webgpu.js
@@ -129,7 +129,7 @@ export const WEBGPU_MODEL_PRESETS = Object.freeze([
supportsVision: false,
}),
]);
-export const WEBGPU_MODEL_NOT_READY_ERROR = `${WEBGPU_MODEL_ID} is not downloaded. Open Settings > Providers > WebGPU or Apocalypse Mode > WebGPU to download it before chatting.`;
+export const WEBGPU_MODEL_NOT_READY_ERROR = `${WEBGPU_COMPASS_TINY_V2_MODEL_ID} is not downloaded. Open Settings > Providers > WebGPU or Apocalypse Mode > WebGPU to download it before chatting.`;
// Chrome-only selection state. Keep this separate from the synced
// `visionModel` endpoint so enabling the fallback never overwrites a user's
// remote vision credentials or sends a Chromium-only provider type to Firefox.
@@ -180,7 +180,7 @@ export async function hasWebgpuVisionCache(modelId = WEBGPU_VISION_MODEL_ID) {
export function normalizeWebgpuModelId(value) {
let model = String(value || '').trim();
- if (!model) return WEBGPU_MODEL_ID;
+ if (!model) return WEBGPU_COMPASS_TINY_V2_MODEL_ID;
if (/^https?:\/\//i.test(model)) {
let url;
try {
diff --git a/src/chrome/src/ui/settings.js b/src/chrome/src/ui/settings.js
index 87c6ecd05..56fdc25c9 100644
--- a/src/chrome/src/ui/settings.js
+++ b/src/chrome/src/ui/settings.js
@@ -70,6 +70,7 @@ import {
WEBGPU_VISION_CONSENT_VERSION,
WEBGPU_VISION_CONSENT_VERSION_KEY,
WEBGPU_VISION_ENABLED_KEY,
+ normalizeWebgpuModelId,
} from '../providers/webgpu.js';
import { AUTO_GROUP_TABS_KEY } from '../tab-group-preference.js';
@@ -2765,7 +2766,11 @@ function renderWebgpuDownloadControl(id, state) {
function getDisplayedWebgpuModel(id = 'webgpu') {
const input = document.querySelector(`input[data-provider="${id}"][data-key="model"]`);
- return String(input?.value || providersData[id]?.model || '').trim();
+ try {
+ return normalizeWebgpuModelId(input?.value || providersData[id]?.model);
+ } catch {
+ return String(input?.value || providersData[id]?.model || WEBGPU_COMPASS_TINY_V2_MODEL_ID).trim();
+ }
}
async function refreshWebgpuDownloadControls() {
diff --git a/test/run.js b/test/run.js
index 9f87fdb73..07b13af98 100644
--- a/test/run.js
+++ b/test/run.js
@@ -62435,6 +62435,7 @@ test('Chrome exposes separate endpoint-free WebGPU text and vision providers', a
assert.equal(webgpuConfig.dtype, WEBGPU_DTYPE);
assert.equal(webgpuConfig.contextWindow, 32768);
const generalProvider = manager._createProvider('webgpu', webgpuConfig);
+ manager.providers.set('webgpu', generalProvider);
assert.ok(generalProvider instanceof WebGPUProvider);
assert.equal(generalProvider.promptTier, 'compact');
assert.equal(new WebGPUProvider({ model: WEBGPU_MODEL_ID }).promptTier, 'compact');
@@ -62462,6 +62463,12 @@ test('Chrome exposes separate endpoint-free WebGPU text and vision providers', a
assert.equal(new WebGPUProvider({ model: WEBGPU_BONSAI27_MODEL_ID }).dtype, 'q1');
assert.equal(new WebGPUProvider({ model: WEBGPU_BONSAI27_MODEL_ID }).requiresToolTemplate, false);
assert.equal(normalizeWebgpuModelId(' custom-owner/custom-model '), 'custom-owner/custom-model');
+ assert.equal(normalizeWebgpuModelId(''), WEBGPU_COMPASS_TINY_V2_MODEL_ID);
+ assert.equal(normalizeWebgpuModelId(null), WEBGPU_COMPASS_TINY_V2_MODEL_ID);
+ assert.equal(normalizeWebgpuModelId(' '), WEBGPU_COMPASS_TINY_V2_MODEL_ID);
+ assert.equal(new WebGPUProvider({}).model, WEBGPU_COMPASS_TINY_V2_MODEL_ID);
+ assert.equal(new WebGPUProvider({ model: '' }).model, WEBGPU_COMPASS_TINY_V2_MODEL_ID);
+ assert.equal(new WebGPUProvider({ model: ' ' }).model, WEBGPU_COMPASS_TINY_V2_MODEL_ID);
assert.throws(() => new WebGPUProvider({ model: 'not-a-repository' }), /owner\/repository/);
assert.throws(() => new WebGPUProvider({ model: 'https://example.com/owner/model' }), /huggingface\.co/);
assert.equal(generalProvider.supportsTools, true);
@@ -62512,6 +62519,12 @@ test('Chrome exposes separate endpoint-free WebGPU text and vision providers', a
assert.deepEqual(textDisposed, { ok: true, disposed: true });
assert.deepEqual(sentMessages[4], { type: 'webgpu-dispose' });
+ await manager.updateProvider('webgpu', { model: 'custom-owner/custom-model' });
+ assert.equal(manager.getAll().webgpu.model, 'custom-owner/custom-model');
+ await manager.updateProvider('webgpu', { model: '' });
+ assert.equal(manager.getAll().webgpu.model, WEBGPU_COMPASS_TINY_V2_MODEL_ID);
+ assert.equal(manager.getAll().webgpu.contextWindow, 32768);
+
const provider = await manager.getLocalVisionFallbackProvider();
assert.ok(provider instanceof WebGPUVisionProvider);
assert.equal(provider.name, 'webgpu-vision');