litellm - ✅(Solved) Fix [Bug]: Moonshot/Kimi K2.6 - reasoning_content is missing in assistant tool call message during multi-turn tool calling [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#26156Fetched 2026-04-22 07:46:13
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
1
Author
Participants
Timeline (top)
labeled ×2commented ×1cross-referenced ×1referenced ×1

Error Message

Error: MoonshotException - thinking is enabled but reasoning_content is missing in assistant tool call message at index 2 (HTTPStatusError: Client error 400 Bad Request for url https://api.moonshot.cn/v1/chat/completions)

Root Cause

When using LiteLLM with the Moonshot provider (moonshot/kimi-k2.6) for multi-turn tool calling, the Moonshot API returns a 400 Bad Request error because reasoning_content is missing from the assistant tool call message in subsequent turns.

Fix Action

Workaround

Use a custom callback that intercepts outgoing HTTP requests and injects reasoning_content: " " into assistant tool-call messages that are missing it, as described in the comments of #21672.

PR fix notes

PR #26164: feat(moonshot): add kimi-k2.6 model with supports_reasoning to fix multi-turn tool calling

Description (problem / solution / changelog)

Summary

Fixes #26156 — Moonshot kimi-k2.6 was missing from model_prices_and_context_window.json, causing supports_reasoning() to return False. This prevented fill_reasoning_content() from being called in multi-turn tool-calling flows, which caused Moonshot API to return 400 Bad Request errors due to missing reasoning_content in assistant messages.

Root cause

MoonshotChatConfig.transform_request() calls fill_reasoning_content() only when supports_reasoning(model=model, custom_llm_provider="moonshot") returns True. Because kimi-k2.6 had no entry in the pricing JSON, supports_reasoning() returned False and the reasoning content was never injected.

This is the same class of bug as was fixed for kimi-k2.5 and kimi-k2-thinkingkimi-k2.6 is a reasoning model (thinking enabled by default) that requires the same treatment.

Changes

  • Add moonshot/kimi-k2.6 to model_prices_and_context_window.json with "supports_reasoning": true
  • Add same entry to litellm/model_prices_and_context_window_backup.json
  • Pricing is modeled after kimi-k2.5 — please verify with official Moonshot pricing docs if numbers differ

Test plan

  • Verify litellm.utils.supports_reasoning("kimi-k2.6", "moonshot") returns True
  • Multi-turn tool calling with moonshot/kimi-k2.6 no longer returns 400 from Moonshot API

🤖 Generated with Claude Code

Changed files

  • litellm/model_prices_and_context_window_backup.json (modified, +38562/-38546)
  • model_prices_and_context_window.json (modified, +38562/-38546)

Code Example

Error: MoonshotException - thinking is enabled but reasoning_content is missing in assistant tool call message at index 2
  (HTTPStatusError: Client error 400 Bad Request for url https://api.moonshot.cn/v1/chat/completions)
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

When using LiteLLM with the Moonshot provider (moonshot/kimi-k2.6) for multi-turn tool calling, the Moonshot API returns a 400 Bad Request error because reasoning_content is missing from the assistant tool call message in subsequent turns.

This is the same issue as #21672, which was fixed by PR #23580 — but the fix only covers kimi-k2.5, kimi-k2-thinking, and kimi-k2-thinking-turbo. The newly released kimi-k2.6 model is not included in the model_prices_and_context_window.json file, so supports_reasoning returns False and fill_reasoning_content() is never called.

Kimi K2.6 has thinking/reasoning enabled by default. The Moonshot API requires that reasoning_content from the assistant response be preserved and sent back in the conversation history during multi-step tool calling. The official API documentation (https://platform.moonshot.ai/docs/api/chat) describes the thinking parameter with a keep field for K2.6 that controls whether reasoning_content from historical turns is preserved:

Controls whether reasoning_content from previous turns is preserved across a multi-turn conversation, i.e. whether to enable Preserved Thinking. Defaults to null, meaning historical thinking is NOT preserved.

  • "all": Preserves reasoning_content from historical turns and provides it to the model as part of the context, enabling Preserved Thinking. When using this, keep the reasoning_content from every historical assistant message in messages as-is.

Steps to Reproduce

  1. Configure moonshot/kimi-k2.6 in LiteLLM proxy config
  2. Make a multi-turn tool calling request via /v1/messages (Anthropic format)
  3. On the second turn (after tool_result), Moonshot API returns 400

Relevant log output

Error: MoonshotException - thinking is enabled but reasoning_content is missing in assistant tool call message at index 2
  (HTTPStatusError: Client error 400 Bad Request for url https://api.moonshot.cn/v1/chat/completions)

What part of LiteLLM is this about?

SDK (litellm Python package), Proxy (LiteLLM Proxy Server)

What LiteLLM version are you on?

v1.83.10

Suggested Fix

Add moonshot/kimi-k2.6 to model_prices_and_context_window.json with "supports_reasoning": true so that the existing fill_reasoning_content() logic in MoonshotChatConfig applies to this model as well.

Additionally, K2.6 introduces a new thinking.keep parameter (vs K2.5's simpler thinking.type) that should be mapped from Anthropic's cache_control / thinking params.

Workaround

Use a custom callback that intercepts outgoing HTTP requests and injects reasoning_content: " " into assistant tool-call messages that are missing it, as described in the comments of #21672.

extent analysis

TL;DR

Add moonshot/kimi-k2.6 to model_prices_and_context_window.json with "supports_reasoning": true to enable the existing fill_reasoning_content() logic for this model.

Guidance

  • Verify that the model_prices_and_context_window.json file does not currently include moonshot/kimi-k2.6 with "supports_reasoning": true, which is causing supports_reasoning to return False and preventing fill_reasoning_content() from being called.
  • Update the model_prices_and_context_window.json file to include moonshot/kimi-k2.6 with the correct configuration to enable reasoning content preservation.
  • Consider implementing a custom callback to intercept outgoing HTTP requests and inject reasoning_content into assistant tool-call messages as a temporary workaround.
  • Review the official Moonshot API documentation to ensure correct usage of the thinking parameter and its keep field for K2.6.

Example

No code example is provided as the necessary changes are related to configuration files and API usage.

Notes

The provided fix assumes that the issue is solely due to the missing configuration for moonshot/kimi-k2.6 in model_prices_and_context_window.json. Additional issues may arise from the new thinking.keep parameter introduced in K2.6, which may require further adjustments.

Recommendation

Apply the suggested fix by adding moonshot/kimi-k2.6 to model_prices_and_context_window.json with "supports_reasoning": true, as this directly addresses the identified cause of the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING