litellm - ✅(Solved) Fix [Bug]: Moonshot/Kimi K2.5 thinking mode breaks multi-turn tool calls — reasoning_content stripped from assistant messages in history [1 pull requests, 1 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#23765Fetched 2026-04-08 00:49:16
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Participants
Timeline (top)
labeled ×2referenced ×2closed ×1cross-referenced ×1

Error Message

API Error: 400 {"error":{"message":"litellm.BadRequestError: MoonshotException - thinking is enabled but reasoning_content is missing in assistant tool call message at index 8. Received Model

Fix Action

Fixed

PR fix notes

PR #23828: fix(moonshot): preserve reasoning_content on Pydantic Message objects in multi-turn tool calls

Description (problem / solution / changelog)

Problem

Moonshot/Kimi K2.5 thinking mode breaks multi-turn tool calls because "reasoning_content" was being stripped from assistant messages in conversation history.

The root cause was in the "fill_reasoning_content" method. The condition 'reasoning_content' not in msg doesn't work correctly for Pydantic Message objects because they don't support the in operator the same way as dicts.

Fix

Changed the condition from:

"reasoning_content" not in msg

to:

not msg.get("reasoning_content")

This works correctly for both dicts and Pydantic models because the .get() method is available on both types.

Changes

  • Modified: litellm/llms/moonshot/chat/transformation.py
  • Added 2 regression tests in tests/test_litellm/llms/moonshot/test_moonshot_chat_transformation.py

Fixes #23765

Changed files

  • litellm/llms/moonshot/chat/transformation.py (modified, +5/-3)
  • tests/test_litellm/llms/moonshot/test_moonshot_chat_transformation.py (modified, +69/-1)
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?

API Error: 400 {"error":{"message":"litellm.BadRequestError: MoonshotException - thinking is enabled but reasoning_content is missing in assistant tool call message at index 8. Received Model
Group=kimi\nAvailable Model Group Fallbacks=['claude-fallback']\nError doing the fallback: litellm.BadRequestError: You passed in model=claude-fallback. There are no healthy deployments for this modelNo
fallback model group found for original model_group=claude-fallback. Fallbacks=[{'kimi': ['claude-fallback']}, {'glm': ['claude-fallback']}]. Received Model Group=claude-fallback\nAvailable Model Group
Fallbacks=None\nError doing the fallback: litellm.BadRequestError: You passed in model=claude-fallback. There are no healthy deployments for this modelNo fallback model group found for original
model_group=claude-fallback. Fallbacks=[{'kimi': ['claude-fallback']}, {'glm': ['claude-fallback']}]","type":"invalid_request_error","param":null,"code":"400"}}

Steps to Reproduce

Relevant log output

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

latest

Twitter / LinkedIn details

No response

extent analysis

Fix Plan

The fix involves ensuring that the reasoning_content is properly included in the assistant tool call message and verifying the health of the model deployments.

  • Check the API request payload to ensure reasoning_content is present.
  • Verify that the model group claude-fallback has healthy deployments.
  • Update the fallback logic to handle cases where the primary model group has no healthy deployments.

Example Code

# Ensure reasoning_content is included in the API request payload
payload = {
    'model': 'claude-fallback',
    'reasoning_content': 'your_reasoning_content_here'
}

# Verify model group health
def check_model_group_health(model_group):
    # Implement logic to check model group health
    # Return True if healthy, False otherwise
    pass

# Update fallback logic
def get_fallback_model(model_group):
    if check_model_group_health(model_group):
        return model_group
    else:
        # Implement logic to select a healthy fallback model
        pass

Verification

  • Test the API request with the updated payload to ensure reasoning_content is included.
  • Verify that the model group claude-fallback has healthy deployments.
  • Test the fallback logic to ensure it selects a healthy model group.

Extra Tips

  • Regularly monitor model group health to prevent similar issues.
  • Implement robust error handling and logging to quickly identify and resolve issues.

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