Skip to content

Commit b363071

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 19421d5 commit b363071

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
@@ -323,8 +323,12 @@ def _convert_message(message: Message) -> ChatCompletionMessageParam:
323323
# Dropping `content` entirely is always accepted, so do that whenever
324324
# the visible content is effectively empty alongside a tool call.
325325
dumped_message.pop("content", None)
326-
if reasoning_content:
327-
dumped_message["reasoning_content"] = reasoning_content
326+
# Always include reasoning_content on assistant messages. Moonshot's API
327+
# requires this field when thinking is enabled (which proxies like OpenCode
328+
# Go may enable server-side). Use a single space when no thinking output
329+
# exists — empty string may be rejected.
330+
if message.role == "assistant":
331+
dumped_message["reasoning_content"] = reasoning_content or " "
328332
return cast(ChatCompletionMessageParam, dumped_message)
329333

330334

0 commit comments

Comments
 (0)