Skip to content

Commit 005a514

Browse files
joybnuuyclaude
andcommitted
fix: always include reasoning_content on assistant messages for proxy compat
Moonshot's API rejects assistant messages without reasoning_content when thinking is enabled (which proxies like OpenCode Go enable server-side). Empty string is also rejected — use a single space as fallback. Fixes tool-call failures through OpenCode Go proxy (anomalyco/opencode#10996). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 59c9edc commit 005a514

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • packages/kosong/src/kosong/chat_provider

‎packages/kosong/src/kosong/chat_provider/kimi.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,12 @@ def _convert_message(message: Message) -> ChatCompletionMessageParam:
327327
# Dropping `content` entirely is always accepted, so do that whenever
328328
# the visible content is effectively empty alongside a tool call.
329329
dumped_message.pop("content", None)
330-
if reasoning_content:
331-
dumped_message["reasoning_content"] = reasoning_content
330+
# Always include reasoning_content on assistant messages. Moonshot's API
331+
# requires this field when thinking is enabled (which proxies like OpenCode
332+
# Go may enable server-side). Use a single space when no thinking output
333+
# exists — empty string may be rejected.
334+
if message.role == "assistant":
335+
dumped_message["reasoning_content"] = reasoning_content or " "
332336
return cast(ChatCompletionMessageParam, dumped_message)
333337

334338

0 commit comments

Comments
 (0)