π OpenHands: AI-Driven Development
Clean up empty content fix (revert #4935) (#5539)
Engel Nyst425ccb0fbb0a
diff --git a/openhands/core/message.py b/openhands/core/message.pyindex a5b67917ea..5fcd5a2b31 100644--- a/openhands/core/message.py+++ b/openhands/core/message.py@@ -105,14 +105,6 @@ class Message(BaseModel):message_dict: dict = {'content': content, 'role': self.role}- # pop content if it's empty- if not content or (- len(content) == 1- and content[0]['type'] == 'text'- and content[0]['text'] == ''- ):- message_dict.pop('content')-if role_tool_with_prompt_caching:message_dict['cache_control'] = {'type': 'ephemeral'}diff --git a/openhands/llm/debug_mixin.py b/openhands/llm/debug_mixin.pyindex f386613d6f..6a247471ee 100644--- a/openhands/llm/debug_mixin.py+++ b/openhands/llm/debug_mixin.py@@ -16,7 +16,7 @@ class DebugMixin:debug_message = MESSAGE_SEPARATOR.join(self._format_message_content(msg)for msg in messages- if msg.get('content', None)+ if msg['content'] is not None)if debug_message:diff --git a/openhands/llm/fn_call_converter.py b/openhands/llm/fn_call_converter.pyindex 491ef906ea..ae4d87f8d6 100644--- a/openhands/llm/fn_call_converter.py+++ b/openhands/llm/fn_call_converter.py@@ -321,7 +321,7 @@ def convert_fncall_messages_to_non_fncall_messages(first_user_message_encountered = Falsefor message in messages:role = message['role']- content = message.get('content', '')+ content = message['content']# 1. SYSTEM MESSAGES# append system prompt suffix to content