Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

feat(bot): Error calling LLM: litellm.BadRequestError: MoonshotException - Invalid request: the message at position 10 with role 'assistant' must not be empty (#1026)

Linsiyuan977130b51392e
diff --git a/bot/vikingbot/agent/context.py b/bot/vikingbot/agent/context.py
index 70ea74823..e8b220f9f 100644
--- a/bot/vikingbot/agent/context.py
+++ b/bot/vikingbot/agent/context.py
@@ -341,8 +341,9 @@ Always be helpful, accurate, and concise. When using tools, think step by step:
"""
msg: dict[str, Any] = {"role": "assistant"}
- if content:
- msg["content"] = content
+ # Always include content — some providers (e.g. Moonshot) reject
+ # assistant messages without it, even when tool_calls are present.
+ msg["content"] = content or ""
if tool_calls:
msg["tool_calls"] = tool_calls