tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit b18ae5cfbc41945ea622878c33cb9eb215ab14d9
parent ca245b2e751014b9425c5da5dcd83c798beb316a
Author: Bryan Johns <bjohns@mozilla.com>
Date:   Wed, 24 Dec 2025 01:18:15 +0000

Bug 2007565 - Fixed errors caused by submitted empty assistant prompts r=ai-frontend-reviewers,ai-models-reviewers,Gijs,tzhang

Differential Revision: https://phabricator.services.mozilla.com/D277451

Diffstat:
Mbrowser/components/aiwindow/models/Chat.sys.mjs | 6+++++-
Mbrowser/components/genai/SmartAssistEngine.sys.mjs | 6+++++-
2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/browser/components/aiwindow/models/Chat.sys.mjs b/browser/components/aiwindow/models/Chat.sys.mjs @@ -59,7 +59,11 @@ export const Chat = { const fxAccountToken = await this._getFxAccountToken(); // We'll mutate a local copy of the thread as we loop - let convo = Array.isArray(messages) ? [...messages] : []; + // We also filter out empty assistant messages because + // these kinds of messages can produce unexpected model responses + let convo = Array.isArray(messages) + ? messages.filter(msg => !(msg.role == "assistant" && !msg.content)) + : []; // Helper to run the model once (streaming) on current convo const streamModelResponse = () => diff --git a/browser/components/genai/SmartAssistEngine.sys.mjs b/browser/components/genai/SmartAssistEngine.sys.mjs @@ -129,7 +129,11 @@ export const SmartAssistEngine = { const fxAccountToken = await this._getFxAccountToken(); // We'll mutate a local copy of the thread as we loop - let convo = Array.isArray(messages) ? [...messages] : []; + // We also filter out empty assistant messages because + // these kinds of messages can produce unexpected model responses + let convo = Array.isArray(messages) + ? messages.filter(msg => !(msg.role == "assistant" && !msg.content)) + : []; // Helper to run the model once (streaming) on current convo const streamModelResponse = () =>