Kimi API fails with tool calls when thinking mode is enabled
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
- Endpoint: https://api.kimi.com/coding/v1/chat/completions
- Model: kimi-for-coding
- Authentication: KIMI_API_KEY
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
- Send a chat completion request to the Kimi OpenAI-compatible endpoint.
- Use the kimi-for-coding model.
- Enable thinking/reasoning mode.
- Allow the model to generate one or more tool calls.
- 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.
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:
is_kimi_model("kimi-for-coding")returns false (it only matchesmoonshotai/andkimi-k2*variants).- The Kimi profile runs as a direct OpenAI-compatible provider (
supports_provider_features = false), soallow_reasoning/include_reasoning_contentstayed 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.