Skip to content

fix(converter): preserve thinking blocks as reasoning_content on assi…#14

Open
digachoy wants to merge 1 commit intonielspeter:mainfrom
digachoy:fix/thinking-reasoning-content
Open

fix(converter): preserve thinking blocks as reasoning_content on assi…#14
digachoy wants to merge 1 commit intonielspeter:mainfrom
digachoy:fix/thinking-reasoning-content

Conversation

@digachoy
Copy link
Copy Markdown

…stant messages

When the client sends an assistant message that contains both an Anthropic 'thinking' block and a 'tool_use' block (a normal multi-turn tool-calling scenario when extended thinking is enabled), the proxy was silently dropping the thinking text while forwarding only the tool_calls.

Moonshot AI / Kimi rejects such requests with:
'thinking is enabled but reasoning_content is missing in assistant
tool call message at index N'

resulting in 500s on every follow-up turn after the first tool call — any Claude Code session that relies on the Telegram reply tool (or any other plugin tool-chain) becomes unrecoverable on Kimi once it has produced a thinking block.

Fix:

  • Add ReasoningContent string field to pkg/models.OpenAIMessage (serialized as reasoning_content, the field name Moonshot expects).
  • In ConvertRequest, handle content blocks of type thinking by collecting their text, and write the joined text as ReasoningContent on the outgoing assistant message alongside ToolCalls.

Providers that do not care about reasoning_content (OpenAI, OpenRouter for most models, Ollama) simply ignore the extra field.

…stant messages

When the client sends an assistant message that contains both an Anthropic
'thinking' block and a 'tool_use' block (a normal multi-turn tool-calling
scenario when extended thinking is enabled), the proxy was silently dropping
the thinking text while forwarding only the tool_calls.

Moonshot AI / Kimi rejects such requests with:
  'thinking is enabled but reasoning_content is missing in assistant
   tool call message at index N'

resulting in 500s on every follow-up turn after the first tool call — any
Claude Code session that relies on the Telegram reply tool (or any other
plugin tool-chain) becomes unrecoverable on Kimi once it has produced a
thinking block.

Fix:
- Add ReasoningContent string field to pkg/models.OpenAIMessage
  (serialized as `reasoning_content`, the field name Moonshot expects).
- In ConvertRequest, handle content blocks of type `thinking` by collecting
  their text, and write the joined text as ReasoningContent on the outgoing
  assistant message alongside ToolCalls.

Providers that do not care about reasoning_content (OpenAI, OpenRouter for
most models, Ollama) simply ignore the extra field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants