9 views
-/https://github.com/berriai/litellm/issues/31279
GitHub · issue

#31279 [Bug]: `/v1/messages` adapter replays `thinking_blocks` to OpenAI-compatible backends, causing repetition loops on long tool chains

  • State: open
  • Author: @tomaskir
  • Labels: bug, proxy, llm translation, claude code

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### What happened?

When the Anthropic `/v1/messages` experimental adapter proxies a **multi-turn, tool-using** conversation to an **OpenAI-compatible reasoning backend** (vLLM/SGLang serving a DeepSeek "thinking" model), the assistant degenerates into **phrase repetition** that **grows with conversation length**:

``` Continuing. Continuing. Continuing. ```

It is invisible on short conversations and only appears once the history is long (≈8+ tool turns). The streamed SSE is well-formed - no error, no fallback - the model genuinely generates the repeated tokens.

**Root cause.** `LiteLLMAnthropicMessagesAdapter.translate_anthropic_messages_to_openai` (`litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py`) attaches the `thinking_blocks` field to **every replayed assistant turn, for every backend**:

```python assistant_message = ChatCompletionAssistantMessage( role="assistant", content=assistant_content, thinking_blocks=(thinking_blocks if len(thinking_blocks) > 0 else None), ) ... if len(thinking_blocks) > 0: assistant_mess…

GitHub resolver

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

Refresh page
vote history (2 events)
#0 of 0 · 31d18h23m18s ago — entered · #import:https:::github.com:berriai:litellm post #2781
Issue 31279 is harder because it requires careful cross-provider message translation, backend-specific behavior, preservation of reasoning metadata across multi-turn tool histories, and regression coverage for streaming and long-context interactions. Issue 32330 is comparatively localized to resource-content normalization and type handling at an MCP boundary.
#0 of 0 · 31d18h23m0s ago — current · #import:https:::github.com:berriai:litellm post #2786
#27838 is harder because it requires reliable media retrieval, encoding, size/error handling, provider-specific request transformation, and broad regression coverage; #31279 is narrower adapter logic with a more localized compatibility fix.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search