Skip to content

Kimi API fails with tool calls when thinking mode is enabled #322

Closed

Description

@kskim

Bug: Kimi API fails with tool calls when thinking mode is enabled

Summary

Requests to the Kimi OpenAI-compatible API fail with a 400 Bad Request when using kimi-for-coding and tool calls while thinking mode is enabled.

Environment

Error

json { "error": { "message": "thinking is enabled but reasoning_content is missing in assistant tool call message at index 134", "type": "invalid_request_error" } }

Steps to Reproduce

  1. Send a chat completion request to the Kimi OpenAI-compatible endpoint.
  2. Use the kimi-for-coding model.
  3. Enable thinking/reasoning mode.
  4. Allow the model to generate one or more tool calls.
  5. The request fails with HTTP 400.

Expected Behavior

The request should either:

  • succeed when assistant tool call messages do not contain reasoning_content, or
  • the API documentation should clearly specify that reasoning_content is required for assistant tool call messages when thinking mode is enabled.

Actual Behavior

The API returns:

text 400 Bad Request thinking is enabled but reasoning_content is missing in assistant tool call message at index 134

Additional Notes

The request is sent through the OpenAI-compatible API interface. The error suggests that the server expects a reasoning_content field in assistant tool call messages when thinking mode is enabled, but this requirement is not handled by OpenAI-compatible clients.

It would be helpful to clarify:

  • Whether reasoning_content is mandatory for tool call messages.
  • How OpenAI-compatible clients should populate this field.
  • Whether compatibility mode should automatically handle missing reasoning_content.

Activity

  1. added
    bug
    priority: medium
    triage: reproducible
    on Jun 5, 2026
  2. 1jehuang commented on Jun 5, 2026

    @1jehuang
    Owner

    Reproduced and fixed in f8d25110.

    Root cause: the dedicated Kimi coding endpoint (https://api.kimi.com/coding/v1, default model kimi-for-coding) enables thinking server-side and requires reasoning_content on assistant tool-call messages. But jcode's request builder gated reasoning_content behind two conditions that both failed for this endpoint:

    1. is_kimi_model("kimi-for-coding") returns false (it only matches moonshotai/ and kimi-k2* variants).
    2. The Kimi profile runs as a direct OpenAI-compatible provider (supports_provider_features = false), so allow_reasoning/include_reasoning_content stayed false.

    As a result the assistant tool-call message was serialized as e.g. {"role":"assistant","tool_calls":[...]} with no reasoning_content, and the endpoint rejected the whole request with the 400 you saw.

    Fix: detect the dedicated Kimi coding endpoint (by profile id / api base / kimi* model name) and attach reasoning_content to assistant tool-call messages (a single space placeholder when no reasoning was persisted). Importantly the fix does NOT add the OpenRouter-specific top-level thinking field, since this endpoint manages thinking itself. Added a regression test that captures the outgoing request body and asserts the tool-call message carries a non-empty reasoning_content.

    Will close automatically on the next release.

  3. added
    triage: fixed-pending-release
    and removed
    triage: reproducible
    on Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority: mediumtriage: fixed-pending-release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions