From 716466e7576e01a44c79ea55981129bd450e87cc Mon Sep 17 00:00:00 2001 From: Till JS Date: Fri, 10 Apr 2026 17:23:28 +0200 Subject: [PATCH] fix(shared-llm): sort candidate tiers privacy-first (browser before server) Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/shared-llm/src/orchestrator.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/shared-llm/src/orchestrator.ts b/packages/shared-llm/src/orchestrator.ts index 357b6bc3f..aee94ec1a 100644 --- a/packages/shared-llm/src/orchestrator.ts +++ b/packages/shared-llm/src/orchestrator.ts @@ -227,8 +227,12 @@ export class LlmOrchestrator { * - Rule 2: sensitive content excludes mana-server + cloud * Also always includes 'none' at the end if the task has runRules. */ private candidateTiers(task: LlmTask): LlmTier[] { - // Start from the user's allowed tiers, in their preference order - let tiers = this.settings.allowedTiers.filter((t) => TIER_RANK[t] >= TIER_RANK[task.minTier]); + // Sort by privacy gradient (most private first) so the browser tier + // always wins over mana-server when both are enabled, regardless of + // the order the user toggled them in settings. + let tiers = this.settings.allowedTiers + .filter((t) => TIER_RANK[t] >= TIER_RANK[task.minTier]) + .sort((a, b) => TIER_RANK[a] - TIER_RANK[b]); // Rule 2: sensitive content backstop if (task.contentClass === 'sensitive') {