fix(converter): preserve thinking blocks as reasoning_content on assi…#14
Open
digachoy wants to merge 1 commit intonielspeter:mainfrom
Open
fix(converter): preserve thinking blocks as reasoning_content on assi…#14digachoy wants to merge 1 commit intonielspeter:mainfrom
digachoy wants to merge 1 commit intonielspeter:mainfrom
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…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:
reasoning_content, the field name Moonshot expects).thinkingby 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.