Skip to content

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

Closed

Description

@willy-scr

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

Activity

  1. github-actions commented on Jan 28, 2026

    @github-actions
    Contributor

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

    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.

  2. taxilian commented on Jan 28, 2026

    @taxilian

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

  3. rekram1-node commented on Jan 29, 2026

    @rekram1-node
    Contributor

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

  4. willy-scr commented on Jan 29, 2026

    @willy-scr
    Author

    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.

  5. willy-scr commented on Jan 29, 2026

    @willy-scr
    Author

    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

  6. zero-zrc0 commented on Feb 6, 2026

    @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.

  7. Clausinho commented on Feb 11, 2026

    @Clausinho

    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.

  8. jackjoliet commented on Feb 11, 2026

    @jackjoliet

    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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwindows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions