16 views
-/https://github.com/berriai/litellm/issues/27946
GitHub · issue

#27946 Anthropic → OpenAI conversion drops reasoning_content, breaks multi-turn with reasoning models

  • State: open
  • Author: @Biogod2020
  • Labels: llm translation

## Description

When LiteLLM converts Anthropic `/v1/messages` assistant responses (with `thinking` blocks) to OpenAI Chat Completions format, the thinking blocks are stored in a custom `thinking_blocks` field. The standard `reasoning_content` field is not set.

This causes multi-turn requests to reasoning models to fail with: ``` The `reasoning_content` in the thinking mode must be passed back to the API. ```

## Root cause

In `litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py`:

```python if len(thinking_blocks) > 0: assistant_message["thinking_blocks"] = thinking_blocks ```

The upstream API (DeepSeek, OpenAI o-series) expects `reasoning_content` at the top level of the assistant message dict in multi-turn conversations.

## Fix

```python if len(thinking_blocks) > 0: assistant_message["thinking_blocks"] = thinking_blocks first_thinking = thinking_blocks[0] assistant_message["reasoning_content"] = first_thinking.get("thinking", "") ```

## Steps to reproduce

1. LiteLLM proxy with Anthropic `/v1/messages` + `LITELLM_USE_CHAT_COMPLETIONS_URL_FOR_ANTHROPIC_MESSAGES=true` 2. Model: `deepseek/*` pointing to a reasoning endpoint via `api_bas…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (2 events)
#0 of 0 · 31d18h47m21s ago — entered · #import:https:::github.com:berriai:litellm post #2076
Cross-layer UI and backend persistence changes with security-sensitive credential handling and compatibility testing make the right issue substantially broader than the localized response-field mapping and regression coverage needed on the left.
#0 of 0 · 31d18h32m27s ago — current · #import:https:::github.com:berriai:litellm post #2322
29491 requires tracing streaming event translation across provider and downstream compatibility boundaries, with timing, chunking, and tool-payload regression risks; 27946 is a localized response-field mapping change with a comparatively narrow test surface.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search