Description / 描述
AstrBot 在调用 Moonshot (Kimi K2.5) API 时发生报错,请求体中的对话历史包含了一条内容为空的助手消息,导致Kimi K2.5返回Error code: 400。
[2026-03-30 21:26:16.292] [Core] [WARN] [v4.22.2] [runners.tool_loop_agent_runner:350]: Chat Model moonshot/kimi-k2.5 request error: Error code: 400 - {'error': {'message': "Invalid request: the message at position 8 with role 'assistant' must not be empty", 'type': 'invalid_request_error'}}
[2026-03-30 21:32:10.426] [Core] [WARN] [v4.22.2] [runners.tool_loop_agent_runner:350]: Chat Model moonshot/kimi-k2.5 request error: Error code: 400 - {'error': {'message': "Invalid request: the message at position 8 with role 'assistant' must not be empty", 'type': 'invalid_request_error'}}
解决建议:
在 Provider 层(openai_source.py)添加消息清洗逻辑,在 HTTP 出口处过滤掉"assistant"的空消息
Use Case / 使用场景
这样修改后所有 OpenAI 兼容的模型(Moonshot、DeepSeek、GPT 等)都能受益,特别是严格限制role: assistant消息非空的模型。
Willing to Submit PR? / 是否愿意提交PR?
Code of Conduct
Description / 描述
AstrBot 在调用 Moonshot (Kimi K2.5) API 时发生报错,请求体中的对话历史包含了一条内容为空的助手消息,导致Kimi K2.5返回Error code: 400。
解决建议:
在 Provider 层(openai_source.py)添加消息清洗逻辑,在 HTTP 出口处过滤掉"assistant"的空消息
Use Case / 使用场景
这样修改后所有 OpenAI 兼容的模型(Moonshot、DeepSeek、GPT 等)都能受益,特别是严格限制role: assistant消息非空的模型。
Willing to Submit PR? / 是否愿意提交PR?
Code of Conduct