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.
This commit is contained in:
Roland Tannous 2026-04-08 11:18:49 +04:00
commit 5c658ba5e3

View file

@ -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: