fix(memory): Fix empty string content handling in ConversationMemory (#8148)

Co-authored-by: lijie.20 <lijie.20@bytedance.com>
This commit is contained in:
SDGLBL 2025-04-30 03:03:13 +08:00 committed by GitHub
parent 0b728c0c79
commit 4cbbfd799c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -230,8 +230,8 @@ class ConversationMemory:
pending_tool_call_action_messages[llm_response.id] = Message(
role=getattr(assistant_msg, 'role', 'assistant'),
# tool call content SHOULD BE a string
content=[TextContent(text=assistant_msg.content or '')]
if assistant_msg.content is not None
content=[TextContent(text=assistant_msg.content)]
if assistant_msg.content and assistant_msg.content.strip()
else [],
tool_calls=assistant_msg.tool_calls,
)