Skip to content

Agent Zero AI framework

fix: skip empty content in _convert_messages to prevent errors

Alessandroa7df75a9dd49
diff --git a/models.py b/models.py
index bf584f763..dcc19a26c 100644
--- a/models.py
+++ b/models.py
@@ -361,6 +361,11 @@ class LiteLLMChatWrapper(SimpleChatModel):
if tool_call_id:
message_dict["tool_call_id"] = tool_call_id
+ # Skip messages with empty content
+ content = message_dict.get("content")
+ has_content = bool(content) if not isinstance(content, list) else len(content) > 0
+ if not has_content:
+ continue
result.append(message_dict)
if explicit_caching and result: