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

#25669 [Bug]: Anthropic multi-turn tool call history destroyed when messages use Anthropic content format (tool_use/tool_result in content blocks)

  • State: open
  • Author: @josh900
  • Labels: bug, proxy, llm translation, stale

### Check for existing issues

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

### What happened?

When using LiteLLM's `/v1/chat/completions` endpoint with Anthropic models, multi-turn conversations involving tool calls break in several ways when the client sends messages in Anthropic content block format (i.e. `tool_use` in assistant `content` list, `tool_result` in user `content` list) rather than OpenAI `tool_calls` array format:

1. `_is_orphaned_tool_result()` in `sanitize_messages_for_tool_calling()` only checks `tool_calls` array for matching tool IDs. It never checks `content[type=tool_use]` blocks. Result: every `tool_result` message is flagged as orphaned and stripped, destroying conversation history. The model never sees tool results and re-runs the same tools indefinitely in a loop.

2. `anthropic_messages_pt()` processes assistant messages with a content list but has no handler for `type=tool_use` blocks. They are silently dropped. Same loop effect.

3. `anthropic_messages_pt()` processes user messages with a content list but has no handler for `type=tool_result` blocks. They are silently dropped. Anthropic then errors: `tool_u…

GitHub resolver

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

Refresh page
vote history (2 events)
#0 of 0 · 31d18h11m45s ago — entered · #import:https:::github.com:berriai:litellm post #2658
The right issue is harder because it likely spans authentication flows, token-rotation state, database fallback, cache invalidation, expiration timing, and Enterprise-specific behavior, requiring careful compatibility and regression testing. The left issue is more localized to message sanitization and provider translation with targeted format-handling tests.
#0 of 0 · 31d17h59m20s ago — current · #import:https:::github.com:berriai:litellm post #2876
Issue 25669 is harder because it spans core message sanitization, provider translation, multi-turn state handling, and compatibility-focused testing. Issue 31936 is mainly a localized dashboard field-mapping correction with comparatively limited scope and risk.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search