rough-boots-51677
07/27/2025, 3:55 PMrough-boots-51677
07/27/2025, 3:55 PMlittle-architect-38123
07/28/2025, 7:42 PMchilly-france-44439
07/28/2025, 8:00 PMnarrow-agent-26548
07/28/2025, 8:40 PMnarrow-agent-26548
07/28/2025, 8:44 PM_process_action method of ConversationMemory class, when an assistant message had empty content, the code was creating a message with an empty content list:
content=[TextContent(text=assistant_msg.content)]
if assistant_msg.content and assistant_msg.content.strip()
else [],
Solution Implemented
I modified the code to always include a TextContent with an empty string rather than an empty list:
content=[TextContent(text=assistant_msg.content or '')],
This ensures that even when the assistant message content is empty, we still include a TextContent with an empty string, which satisfies the requirements of LLM providers like Moonshot AI.
The changes have been committed to the repository with appropriate comments explaining the fix. All pre-commit hooks and linting checks have passed successfully.
This fix should resolve the issue with empty assistant messages in LLM calls, particularly when using the kimi-k2 model.chilly-france-44439
07/28/2025, 8:51 PMnarrow-agent-26548
07/28/2025, 8:51 PMnarrow-agent-26548
07/28/2025, 8:51 PM_process_action method of ConversationMemory class, where empty assistant messages were being created with an empty content list ([]) instead of a list containing an empty string. Some LLM providers like Moonshot AI require that assistant messages always have a string content, even if it's empty.
The fix:
• Changed the code to always include a TextContent with an empty string rather than an empty list
• Added a comment explaining why this is necessary
• Verified the change passes all linting checks
This empty message is necessary because:
1. It contains important tool_calls information for function calling
2. It maintains the proper conversation flow and role alternation
3. It satisfies API requirements for providers like Moonshot AI
The change is minimal and focused on the specific issue, modifying only the necessary code to fix the problem.