Kimi for Coding (k2p5) fails with tool calls when thinking enabled: reasoning_content is missing in assistant tool call message #7843

Closed
opened 2026-02-16 18:08:26 -05:00 by yindo · 8 comments
Owner

Originally created by @willy-scr on GitHub (Jan 28, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

Environment

  • OpenCode: v1.1.39
  • OS: Windows (running via WSL2 Ubuntu 22.04)
  • Provider: kimi-for-coding (via opencode auth login)
  • Model: k2p5 (Kimi K2.5)
  • API endpoint (from logs): https://api.kimi.com/coding/v1/messages
    Problem
    When using Kimi for Coding with thinking enabled, any session that triggers tool calls (e.g. Grep/Read) fails with HTTP 400.
    Actual
    OpenCode errors:
    error, status code: 400, message: thinking is enabled but reasoning_content is missing in assistant tool call message at index 101
    Sometimes the index changes as the conversation grows, e.g.:
    ... missing in assistant tool call message at index 104
    Expected
    Tool calls should work while thinking is enabled, or OpenCode should disable thinking / handle reasoning_content correctly for tool call messages (or provide a documented toggle/workaround).
    Reproduction steps
  1. opencode auth login → choose Kimi for Coding
  2. Start a session using model k2p5 (Kimi K2.5)
  3. Ask the agent to do something that triggers tools, e.g. “grep X in file Y” / “read file”
  4. Observe error 400 above.
    Logs (excerpt)
    From ~/.local/share/opencode/log/.log:
  • Request:
  • Response:
    • 400 thinking is enabled but reasoning_content is missing in assistant tool call message at index ...
      Notes / workaround
      Disabling thinking (thinking: disabled) avoids the crash, but removes visible “thinking”.
version'."},"query":{"type":"string","description":"The question or task you need help with. Be specific and include relevant details. Good: 'How to set up authentication with JWT in Express.js' or 'React useEffect cleanup function examples'. Bad: 'auth' or 'hooks'. IMPORTANT: Do not include any sensitive or confidential information such as API keys, passwords, credentials, or personal data in your query."}},"required":["libraryId","query"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}}],"tool_choice":{"type":"auto"},"stream":true},"statusCode":400,"responseHeaders":{"cf-cache-status":"DYNAMIC","cf-ray":"9c503405bf4c1f6e-SIN","connection":"keep-alive","content-length":"200","content-type":"application/json; charset=utf-8","date":"Wed, 28 Jan 2026 11:38:23 GMT","server":"cloudflare","strict-transport-security":"max-age=31536000; includeSubDomains"},"responseBody":"{\"error\":{\"type\":\"invalid_request_error\",\"message\":\"error, status code: 400, message: thinking is enabled but reasoning_content is missing in assistant tool call message at index 101\"},\"type\":\"error\"}","isRetryable":false,"data":{"type":"error","error":{"type":"invalid_request_error","message":"error, status code: 400, message: thinking is enabled but reasoning_content is missing in assistant tool call message at index 101"}}}} stream error
ERROR 2026-01-28T11:38:22 +3ms service=session.processor error=error, status code: 400, message: thinking is enabled but reasoning_content is missing in assistant tool call message at index 101 stack="AI_APICallError: error, status code: 400, message: thinking is enabled but reasoning_content is missing in assistant tool call message at index 101\n    at <anonymous> (../../node_modules/.bun/@ai-sdk+provider-utils@3.0.20+d6123d32214422cb/node_modules/@ai-sdk/provider-utils/dist/index.mjs:936:18)\n    at processTicksAndRejections (native:7:39)" process
INFO  2026-01-28T11:38:22 +0ms service=bus type=session.error publishing
INFO  2026-01-28T11:38:22 +2ms service=bus type=message.updated publishing

Plugins

dcp, auth antigravity

OpenCode version

v1.1.39

Steps to reproduce

  1. Run opencode auth login and select Kimi for Coding
  2. Start a new session using model k2p5
  3. Ask the agent to perform an action that triggers tool calls, e.g.:
    • “Grep subject_anchor in windows-app/story_presets.json
  4. Observe the request fails with HTTP 400:
    thinking is enabled but reasoning_content is missing in assistant tool call message at index ...

Workaround
If thinking is disabled, tool calls work.

Screenshot and/or share link

Image Image

Operating System

windows 11 pro, but i use WSL full opencode

Terminal

wezterm

Originally created by @willy-scr on GitHub (Jan 28, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description Environment - OpenCode: v1.1.39 - OS: Windows (running via WSL2 Ubuntu 22.04) - Provider: kimi-for-coding (via opencode auth login) - Model: k2p5 (Kimi K2.5) - API endpoint (from logs): https://api.kimi.com/coding/v1/messages Problem When using Kimi for Coding with thinking enabled, any session that triggers tool calls (e.g. Grep/Read) fails with HTTP 400. Actual OpenCode errors: error, status code: 400, message: thinking is enabled but reasoning_content is missing in assistant tool call message at index 101 Sometimes the index changes as the conversation grows, e.g.: ... missing in assistant tool call message at index 104 Expected Tool calls should work while thinking is enabled, or OpenCode should disable thinking / handle reasoning_content correctly for tool call messages (or provide a documented toggle/workaround). Reproduction steps 1. opencode auth login → choose Kimi for Coding 2. Start a session using model k2p5 (Kimi K2.5) 3. Ask the agent to do something that triggers tools, e.g. “grep X in file Y” / “read file” 4. Observe error 400 above. Logs (excerpt) From ~/.local/share/opencode/log/<timestamp>.log: - Request: - url=https://api.kimi.com/coding/v1/messages - model=k2p5 - thinking={"type":"enabled","budget_tokens":31999} - Response: - 400 thinking is enabled but reasoning_content is missing in assistant tool call message at index ... Notes / workaround Disabling thinking (thinking: disabled) avoids the crash, but removes visible “thinking”. ``` version'."},"query":{"type":"string","description":"The question or task you need help with. Be specific and include relevant details. Good: 'How to set up authentication with JWT in Express.js' or 'React useEffect cleanup function examples'. Bad: 'auth' or 'hooks'. IMPORTANT: Do not include any sensitive or confidential information such as API keys, passwords, credentials, or personal data in your query."}},"required":["libraryId","query"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}}],"tool_choice":{"type":"auto"},"stream":true},"statusCode":400,"responseHeaders":{"cf-cache-status":"DYNAMIC","cf-ray":"9c503405bf4c1f6e-SIN","connection":"keep-alive","content-length":"200","content-type":"application/json; charset=utf-8","date":"Wed, 28 Jan 2026 11:38:23 GMT","server":"cloudflare","strict-transport-security":"max-age=31536000; includeSubDomains"},"responseBody":"{\"error\":{\"type\":\"invalid_request_error\",\"message\":\"error, status code: 400, message: thinking is enabled but reasoning_content is missing in assistant tool call message at index 101\"},\"type\":\"error\"}","isRetryable":false,"data":{"type":"error","error":{"type":"invalid_request_error","message":"error, status code: 400, message: thinking is enabled but reasoning_content is missing in assistant tool call message at index 101"}}}} stream error ERROR 2026-01-28T11:38:22 +3ms service=session.processor error=error, status code: 400, message: thinking is enabled but reasoning_content is missing in assistant tool call message at index 101 stack="AI_APICallError: error, status code: 400, message: thinking is enabled but reasoning_content is missing in assistant tool call message at index 101\n at <anonymous> (../../node_modules/.bun/@ai-sdk+provider-utils@3.0.20+d6123d32214422cb/node_modules/@ai-sdk/provider-utils/dist/index.mjs:936:18)\n at processTicksAndRejections (native:7:39)" process INFO 2026-01-28T11:38:22 +0ms service=bus type=session.error publishing INFO 2026-01-28T11:38:22 +2ms service=bus type=message.updated publishing ``` ### Plugins dcp, auth antigravity ### OpenCode version v1.1.39 ### Steps to reproduce 1. Run `opencode auth login` and select **Kimi for Coding** 2. Start a new session using model **k2p5** 3. Ask the agent to perform an action that triggers tool calls, e.g.: - “Grep `subject_anchor` in `windows-app/story_presets.json`” 4. Observe the request fails with HTTP 400: `thinking is enabled but reasoning_content is missing in assistant tool call message at index ...` Workaround If thinking is disabled, tool calls work. ### Screenshot and/or share link <img width="1103" height="603" alt="Image" src="https://github.com/user-attachments/assets/8400d5d3-dec3-4202-becd-35c2eca9d110" /> <img width="1039" height="277" alt="Image" src="https://github.com/user-attachments/assets/9d9a9903-b0a3-45e6-8130-45b55bbe33b3" /> ### Operating System windows 11 pro, but i use WSL full opencode ### Terminal wezterm
yindo added the windowsbug labels 2026-02-16 18:08:26 -05:00
yindo closed this issue 2026-02-16 18:08:26 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 28, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #10788: DeepSeek API fails with missing reasoning_content field in assistant tool call messages - same root cause with different provider
  • #9397: DeepSeek with thinking enabled fails on tool calls - same error pattern and root cause
  • #4947: DeepSeek 3.2 missing reasoning_content - similar historical issue
  • #9364: Claude Extended Thinking fails with tool calls - same thinking + tool call issue on different provider
  • #8851: Kimi-K2 via OpenRouter tool call tokens in thinking block - related Kimi provider issue

This appears to be a regression affecting multiple providers (Kimi, DeepSeek, Claude) when thinking/reasoning is enabled and tool calls are attempted. Previous issues suggest this was fixed before but the solution may have been reverted.

Feel free to ignore if this is a distinct case from the above.

@github-actions[bot] commented on GitHub (Jan 28, 2026): This issue might be a duplicate of existing issues. Please check: - #10788: DeepSeek API fails with missing `reasoning_content` field in assistant tool call messages - same root cause with different provider - #9397: DeepSeek with thinking enabled fails on tool calls - same error pattern and root cause - #4947: DeepSeek 3.2 missing `reasoning_content` - similar historical issue - #9364: Claude Extended Thinking fails with tool calls - same thinking + tool call issue on different provider - #8851: Kimi-K2 via OpenRouter tool call tokens in thinking block - related Kimi provider issue This appears to be a regression affecting multiple providers (Kimi, DeepSeek, Claude) when thinking/reasoning is enabled and tool calls are attempted. Previous issues suggest this was fixed before but the solution may have been reverted. Feel free to ignore if this is a distinct case from the above.
Author
Owner

@taxilian commented on GitHub (Jan 28, 2026):

I'm seeing the same thing, seems likely to be a setting we need to tweak

@taxilian commented on GitHub (Jan 28, 2026): I'm seeing the same thing, seems likely to be a setting we need to tweak
Author
Owner

@rekram1-node commented on GitHub (Jan 28, 2026):

Hm it should be using the anthropic messages endpoint, not openai, reasoning_content makes it seem like it's using the openai one?

@rekram1-node commented on GitHub (Jan 28, 2026): Hm it should be using the anthropic messages endpoint, not openai, reasoning_content makes it seem like it's using the openai one?
Author
Owner

@willy-scr commented on GitHub (Jan 28, 2026):

This issue was resolved because of the dcp plugin.

Hm it should be using the anthropic messages endpoint, not openai, reasoning_content makes it seem like it's using the openai one?

This issue was resolved because of the dcp plugin.

@willy-scr commented on GitHub (Jan 28, 2026): This issue was resolved because of the dcp plugin. > Hm it should be using the anthropic messages endpoint, not openai, reasoning_content makes it seem like it's using the openai one? This issue was resolved because of the dcp plugin.
Author
Owner

@willy-scr commented on GitHub (Jan 28, 2026):

Hm it should be using the anthropic messages endpoint, not openai, reasoning_content makes it seem like it's using the openai one?

im will close this issue, thnk u so much @rekram1-node

@willy-scr commented on GitHub (Jan 28, 2026): > Hm it should be using the anthropic messages endpoint, not openai, reasoning_content makes it seem like it's using the openai one? im will close this issue, thnk u so much @rekram1-node
Author
Owner

@zero-zrc0 commented on GitHub (Feb 6, 2026):

I ran into this problem too. Could you please tell me how was it resolved afterwards?I tried using anthropic messages endpoint but it didnt work.

@zero-zrc0 commented on GitHub (Feb 6, 2026): I ran into this problem too. Could you please tell me how was it resolved afterwards?I tried using anthropic messages endpoint but it didnt work.
Author
Owner

@Clausinho commented on GitHub (Feb 11, 2026):

This issue was resolved because of the dcp plugin.

Hm it should be using the anthropic messages endpoint, not openai, reasoning_content makes it seem like it's using the openai one?

This issue was resolved because of the dcp plugin.

I am using https://github.com/Opencode-DCP/opencode-dynamic-context-pruning that @willy-scr recommended but I agree with @zero-zrc0

I ran into this problem too. Could you please tell me how was it resolved afterwards?I tried using anthropic messages endpoint but it didnt work.

Using this DCP plugin seems more like a workaround instead of actually fixing the provider. Unless it means we need a LiteLLM Proxy to properly seperate thinking tags and tool calls.

@Clausinho commented on GitHub (Feb 11, 2026): > This issue was resolved because of the dcp plugin. > > > Hm it should be using the anthropic messages endpoint, not openai, reasoning_content makes it seem like it's using the openai one? > > This issue was resolved because of the dcp plugin. I am using https://github.com/Opencode-DCP/opencode-dynamic-context-pruning that @willy-scr recommended but I agree with @zero-zrc0 > I ran into this problem too. Could you please tell me how was it resolved afterwards?I tried using anthropic messages endpoint but it didnt work. Using this DCP plugin seems more like a workaround instead of actually fixing the provider. Unless it means we need a LiteLLM Proxy to properly seperate thinking tags and tool calls.
Author
Owner

@jackjoliet commented on GitHub (Feb 11, 2026):

Might be a different stack, but I was facing the same issue with ai-sdk. Here's what solved it for me

// reasoning_content — Kimi's API requires this field on every assistant
// tool-call message when thinking mode is enabled.
const kimiProvider = createOpenAICompatible({
  name: 'moonshot',
  baseURL: 'https://api.moonshot.ai/v1',
  apiKey: KIMI_API_KEY,
  includeUsage: true,
  transformRequestBody: (body: Record<string, unknown>) => {
    const messages = body.messages
    if (!Array.isArray(messages)) return body
    for (const msg of messages) {
      if (
        msg.role === 'assistant' &&
        Array.isArray(msg.tool_calls) &&
        msg.tool_calls.length > 0 &&
        !msg.reasoning_content
      ) {
        msg.reasoning_content = '.'
      }
    }
    return body
  },
})
@jackjoliet commented on GitHub (Feb 11, 2026): Might be a different stack, but I was facing the same issue with ai-sdk. Here's what solved it for me ``` // reasoning_content — Kimi's API requires this field on every assistant // tool-call message when thinking mode is enabled. const kimiProvider = createOpenAICompatible({ name: 'moonshot', baseURL: 'https://api.moonshot.ai/v1', apiKey: KIMI_API_KEY, includeUsage: true, transformRequestBody: (body: Record<string, unknown>) => { const messages = body.messages if (!Array.isArray(messages)) return body for (const msg of messages) { if ( msg.role === 'assistant' && Array.isArray(msg.tool_calls) && msg.tool_calls.length > 0 && !msg.reasoning_content ) { msg.reasoning_content = '.' } } return body }, }) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7843