[PR #2548] [CLOSED] fix(tongyi): ensure user message exists for kimi models #2561

Closed
opened 2026-02-16 11:17:19 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-official-plugins/pull/2548
Author: @ZenKaiii
Created: 2/5/2026
Status: Closed

Base: mainHead: fix/tongyi-kimi-default-user-message


📝 Commits (1)

  • 3107eca fix(tongyi): ensure user message exists for kimi models

📊 Changes

1 file changed (+13 additions, -2 deletions)

View changed files

📝 models/tongyi/models/llm/llm.py (+13 -2)

📄 Description

Summary

Fix an issue where kimi series models fail when no user message is provided in the prompt.

Problem

Kimi models (kimi-k2.5, kimi-k2-thinking, Moonshot-Kimi-K2-Instruct) require at least one message with role=user in the input. When Dify LLM nodes only provide system messages, the API returns error about missing user role.

Solution

Added a check in _convert_prompt_messages_to_tongyi_messages() to ensure at least one user message exists for kimi series models. If no user message is found, a default user message with a single space is automatically added.

Changes

  • Modified _convert_prompt_messages_to_tongyi_messages() signature to accept model parameter
  • Updated both calls to pass the model argument (lines 262 and 273)
  • Added conditional logic to only apply the fix for kimi series models (model.startswith("kimi-") or model.startswith("Moonshot-Kimi-"))

Testing

  • Python syntax validated
  • The fix is now scoped specifically to kimi models, avoiding potential side effects on other models

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langgenius/dify-official-plugins/pull/2548 **Author:** [@ZenKaiii](https://github.com/ZenKaiii) **Created:** 2/5/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/tongyi-kimi-default-user-message` --- ### 📝 Commits (1) - [`3107eca`](https://github.com/langgenius/dify-official-plugins/commit/3107ecabc1935a00074e8590e003a92c0eea93aa) fix(tongyi): ensure user message exists for kimi models ### 📊 Changes **1 file changed** (+13 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `models/tongyi/models/llm/llm.py` (+13 -2) </details> ### 📄 Description ## Summary Fix an issue where kimi series models fail when no user message is provided in the prompt. ### Problem Kimi models (kimi-k2.5, kimi-k2-thinking, Moonshot-Kimi-K2-Instruct) require at least one message with role=user in the input. When Dify LLM nodes only provide system messages, the API returns error about missing user role. ### Solution Added a check in _convert_prompt_messages_to_tongyi_messages() to ensure at least one user message exists for kimi series models. If no user message is found, a default user message with a single space is automatically added. ### Changes - Modified _convert_prompt_messages_to_tongyi_messages() signature to accept model parameter - Updated both calls to pass the model argument (lines 262 and 273) - Added conditional logic to only apply the fix for kimi series models (model.startswith("kimi-") or model.startswith("Moonshot-Kimi-")) ### Testing - Python syntax validated - The fix is now scoped specifically to kimi models, avoiding potential side effects on other models --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 11:17:19 -05:00
yindo closed this issue 2026-02-16 11:17:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#2561