From 5c658ba5e3ab66ccd378cf71afc710a4ed4f111b Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Wed, 8 Apr 2026 11:18:49 +0400 Subject: [PATCH] fix: skip empty assistant messages in external provider requests Some providers (Mistral) reject assistant messages with empty content. Filter them out when building the message list for external providers. --- studio/backend/routes/inference.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py index b5f0cd3ebf..50453f88bd 100644 --- a/studio/backend/routes/inference.py +++ b/studio/backend/routes/inference.py @@ -887,6 +887,9 @@ def _build_external_messages( result = [] for msg in messages: if isinstance(msg.content, str): + # Skip assistant messages with empty content (some providers reject them) + if msg.role == "assistant" and not msg.content.strip(): + continue result.append({"role": msg.role, "content": msg.content}) elif isinstance(msg.content, list): if supports_vision: